/* ============================================================
   app.css — Global Design Tokens, Reset & Shared Components
   YLS B2B ERP · Laravel 12
============================================================ */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
    --primary:       #1E293B;
    --secondary:     #334155;
    --accent:        #F97316;
    --accent-light:  #FEF3E2;
    --accent-dark:   #EA6C05;
    --bg:            #F8FAFC;
    --card:          #FFFFFF;
    --border:        #E2E8F0;
    --border-light:  #F1F5F9;
    --success:       #22C55E;
    --success-light: #DCFCE7;
    --warning:       #F59E0B;
    --warning-light: #FEF3C7;
    --danger:        #EF4444;
    --danger-light:  #FEE2E2;
    --info:          #3B82F6;
    --info-light:    #DBEAFE;
    --purple:        #7C3AED;
    --purple-light:  #EDE9FE;
    --text-primary:  #1E293B;
    --text-secondary:#64748B;
    --text-muted:    #94A3B8;
    --text-inverse:  #FFFFFF;

    --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.05);
    --shadow-lg:  0 10px 40px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);
    --shadow-xl:  0 20px 60px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.07);

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;
    --radius-xl:  20px;

    --navbar-h:   68px;

    --font-body:    'Inter', system-ui, sans-serif;
    --font-display: 'Poppins', system-ui, sans-serif;

    --transition: all .22s cubic-bezier(.4,0,.2,1);
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a                   { text-decoration: none; color: inherit; }
ul, ol              { list-style: none; }
img                 { max-width: 100%; display: block; }
button              { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select,
textarea            { font-family: inherit; }

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--border-light); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── LAYOUT ────────────────────────────────────────────────── */
.app-wrapper  { display: flex; flex-direction: column; min-height: 100vh; }

.main-content {
    flex: 1;
    padding: 28px 28px 40px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* ── CARD ──────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card--mt { margin-top: 16px; }
.card--mb { margin-bottom: 16px; }

.card-body { padding: 20px; }
.card-body--no-bottom-pad { padding-bottom: 0; }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: .8375rem;
    font-weight: 600;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    font-family: var(--font-body);
}

.btn svg  { width: 15px; height: 15px; }
.btn-sm   { padding: 6px 13px; font-size: .78rem; }

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
    box-shadow: 0 3px 10px rgba(249,115,22,.3);
}

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 5px 16px rgba(249,115,22,.4);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--bg);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--accent);
    transition: var(--transition);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
}

.btn-link:hover { background: var(--accent-light); }
.btn-link svg   { width: 14px; height: 14px; }

/* Detail Button (in product cards) */
.btn-detail {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: var(--font-body);
    cursor: pointer;
}

.btn-detail svg   { width: 13px; height: 13px; }
.btn-detail:hover { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge--success { background: var(--success-light); color: var(--success); }
.badge--success::before { background: var(--success); }

.badge--warning { background: var(--warning-light); color: #B45309; }
.badge--warning::before { background: var(--warning); }

.badge--info    { background: var(--info-light);    color: #1D4ED8; }
.badge--info::before    { background: var(--info); }

.badge--danger  { background: var(--danger-light);  color: var(--danger); }
.badge--danger::before  { background: var(--danger); }

.badge--orange  { background: var(--accent-light);  color: var(--accent); }
.badge--orange::before  { background: var(--accent); }

/* ── SECTION COMPONENTS ────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header--flush { margin-bottom: 0; }

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title__text {
    font-family: var(--font-display);
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 700;
}

.section-count--success { background: var(--success-light); color: var(--success); }

/* ── PAGE HEADER ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-header__greet {
    display: flex;
    align-items: center;
    gap: 14px;
}

.greet-emoji {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--accent-light) 0%, #FDE68A 100%);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(249,115,22,.15);
}

.page-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-icon--orange { background: var(--accent-light);  color: var(--accent); }
.page-icon--blue   { background: var(--info-light);    color: var(--info); }
.page-icon--green  { background: var(--success-light); color: var(--success); }
.page-icon--purple { background: var(--purple-light);  color: var(--purple); }

.greet-text__title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.4px;
    line-height: 1.2;
}

.greet-text__sub {
    font-size: .8375rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.date-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 13px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: .8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.date-badge svg { color: var(--accent); }

/* ── LIVE DOT ──────────────────────────────────────────────── */
.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    color: var(--success);
    font-weight: 600;
}

.live-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ── TABLE SHARED ──────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

thead th {
    padding: 11px 16px;
    text-align: left;
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .5px;
    text-transform: uppercase;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.th-actions { width: 80px; }
.th-check   { width: 44px; }

tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--bg); }

tbody td {
    padding: 13px 16px;
    font-size: .8375rem;
    color: var(--text-primary);
    vertical-align: middle;
}

.td-date    { color: var(--text-secondary); font-size: .8rem; }
.td-center  { text-align: center; }
.td-code    { font-family: var(--font-display); font-size: .78rem; color: var(--text-muted); }
.td-phone   { color: var(--text-secondary); font-size: .8rem; }
.td-check   { width: 44px; }

.order-no {
    font-weight: 600;
    font-family: var(--font-display);
    color: var(--accent);
    font-size: .8rem;
}

.order-amount {
    font-weight: 700;
    font-family: var(--font-display);
    font-size: .875rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-top: 1px solid var(--border-light);
}

.table-footer__info {
    font-size: .8rem;
    color: var(--text-muted);
}

/* Action Button */
.action-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    background: none;
    border: none;
    cursor: pointer;
}

.action-btn:hover { background: var(--bg); color: var(--text-primary); }

/* ── CUSTOMER CELL ─────────────────────────────────────────── */
.customer-cell {
    display: flex;
    align-items: center;
    gap: 9px;
}

.customer-initial {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
    color: #FFFFFF;
    flex-shrink: 0;
}

.ci-a { background: linear-gradient(135deg, #3B82F6, #6366F1); }
.ci-b { background: linear-gradient(135deg, #22C55E, #16A34A); }
.ci-c { background: linear-gradient(135deg, #F97316, #EF4444); }
.ci-d { background: linear-gradient(135deg, #A855F7, #7C3AED); }
.ci-e { background: linear-gradient(135deg, #F59E0B, #D97706); }

.customer-name { font-weight: 500; font-size: .8375rem; }
.customer-sub  { font-size: .73rem; color: var(--text-muted); }

/* ── PRODUCT CARD (shared) ─────────────────────────────────── */
.product-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(249,115,22,.2);
}

.product-card__img {
    height: 140px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--border-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.product-placeholder-svg { width: 90px; height: 90px; }

.product-stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: .67rem;
    font-weight: 700;
}

.product-stock-badge--in  { background: var(--success-light); color: var(--success); }
.product-stock-badge--low { background: var(--warning-light); color: #B45309; }
.product-stock-badge--out { background: var(--danger-light);  color: var(--danger); }

.product-card__body { padding: 14px 16px; }

.product-category {
    font-size: .7rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.product-name {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}

.product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.product-price {
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text-primary);
}

.product-stock-count {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--text-muted);
}

/* ── FILTER BAR ────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.filter-bar__search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 360px;
    color: var(--text-muted);
}

.filter-bar__input {
    flex: 1;
    height: 34px;
    border: none;
    outline: none;
    font-size: .8375rem;
    color: var(--text-primary);
    background: transparent;
}

.filter-bar__input::placeholder { color: var(--text-muted); }

.filter-bar__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-bar__select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    color: var(--text-secondary);
    background: var(--bg);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.filter-bar__select:focus { border-color: var(--accent); }

.filter-bar__date {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .8rem;
    color: var(--text-secondary);
    background: var(--bg);
    outline: none;
    transition: var(--transition);
}

.filter-bar__date:focus { border-color: var(--accent); }

/* ── VIEW TOGGLE ───────────────────────────────────────────── */
.view-toggle {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle__btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
}

.view-toggle__btn--active {
    background: var(--primary);
    color: #FFFFFF;
}

/* ── CHECKBOX ──────────────────────────────────────────────── */
.checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ── STATUS TABS ───────────────────────────────────────────── */
.status-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.status-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--card);
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.status-tab:hover { background: var(--bg); color: var(--text-primary); }

.status-tab--active {
    background: var(--primary);
    color: #FFFFFF;
    border-color: var(--primary);
}

.status-tab__count {
    padding: 1px 7px;
    border-radius: 99px;
    font-size: .68rem;
    font-weight: 700;
    background: rgba(255,255,255,.15);
    color: inherit;
}

.status-tab--active .status-tab__count { background: rgba(255,255,255,.2); }

.status-tab__count--success { background: var(--success-light); color: var(--success); }
.status-tab__count--warning { background: var(--warning-light); color: #B45309; }
.status-tab__count--info    { background: var(--info-light);    color: #1D4ED8; }
.status-tab__count--danger  { background: var(--danger-light);  color: var(--danger); }

/* ── UTILITY COLORS ────────────────────────────────────────── */
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: #B45309; }
.text-muted   { color: var(--text-muted); }
.fw-600       { font-weight: 600; }

/* ── TOOLTIP ───────────────────────────────────────────────── */
[data-tooltip] { position: relative; }

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #FFFFFF;
    font-size: .72rem;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 9999;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ── TOAST ─────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 280px;
    max-width: 340px;
    animation: slideInRight .3s ease;
    position: relative;
}

.toast.removing { animation: fadeIn .25s ease reverse; }

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon.success { background: var(--success-light); color: var(--success); }
.toast-icon.info    { background: var(--info-light);    color: var(--info); }
.toast-icon.warning { background: var(--warning-light); color: var(--warning); }

.toast-body  { flex: 1; }
.toast-title { font-size: .8125rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.toast-msg   { font-size: .775rem; color: var(--text-secondary); line-height: 1.4; }

.toast-close {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    flex-shrink: 0;
    cursor: pointer;
}

.toast-close:hover { background: var(--bg); color: var(--text-primary); }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 0 var(--radius-lg);
    animation: toastProgress 4s linear forwards;
}

/* ── APP FOOTER ────────────────────────────────────────────── */
.app-footer {
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 16px 28px;
}

.footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1440px;
    margin: 0 auto;
}

.footer__left     { display: flex; align-items: center; gap: 12px; }
.footer__copy     { font-size: .78rem; color: var(--text-muted); }
.footer__version  { font-size: .72rem; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); padding: 2px 7px; border-radius: 4px; }
.footer__nav      { display: flex; gap: 16px; }
.footer__link     { font-size: .78rem; color: var(--text-muted); transition: var(--transition); }
.footer__link:hover { color: var(--text-primary); }

/* ── ANIMATIONS ────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .5; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* Animation Utilities */
.animate-fade-up  { animation: fadeInUp .5s ease forwards; }
.animate-fade-in  { animation: fadeIn .4s ease forwards; }

.delay-1 { animation-delay: .05s; opacity: 0; }
.delay-2 { animation-delay: .10s; opacity: 0; }
.delay-3 { animation-delay: .15s; opacity: 0; }
.delay-4 { animation-delay: .20s; opacity: 0; }

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}
