/* =========================================================
   TALLY POS — Design System v4
   ========================================================= */

@import url('../vendor/fonts/cairo.css');

:root {
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-light: #eef2ff;
    --brand-glow: rgba(79, 70, 229, .25);

    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --info: #0ea5e9;
    --info-light: #f0f9ff;

    --sidebar-bg: #111827;
    --sidebar-bg-2: #1f2937;
    --sidebar-text: #9ca3af;
    --sidebar-text-active: #ffffff;

    --surface: #ffffff;
    --bg: #f4f6fb;
    --border: #e5e7eb;
    --text: #1f2937;
    --text-muted: #6b7280;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 28px rgba(16, 24, 40, .12);
    --transition: all .22s cubic-bezier(.4, 0, .2, 1);

    --sidebar-w: 260px;
    --topbar-h: 68px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    font-size: .95rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.01em; }

::selection { background: var(--brand-glow); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== ENTRANCE ANIMATIONS ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popIn {
    from { opacity: 0; transform: scale(.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.animate-in { animation: fadeInUp .5s cubic-bezier(.4, 0, .2, 1) both; }
.animate-pop { animation: popIn .35s cubic-bezier(.4, 0, .2, 1) both; }
.stagger > * { animation: fadeInUp .5s cubic-bezier(.4, 0, .2, 1) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .09s; }
.stagger > *:nth-child(3) { animation-delay: .15s; }
.stagger > *:nth-child(4) { animation-delay: .21s; }
.stagger > *:nth-child(5) { animation-delay: .27s; }
.stagger > *:nth-child(6) { animation-delay: .33s; }

/* ===== LAYOUT — Sidebar + Topbar ===== */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.25rem 1.35rem;
    color: #fff;
    font-weight: 800;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    text-decoration: none;
}
.sidebar-brand .brand-dot {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), #818cf8);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
    box-shadow: 0 4px 10px var(--brand-glow);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem; }
.sidebar-nav .nav-section-label {
    color: #6b7280;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    padding: .9rem .75rem .35rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .62rem .8rem;
    margin-bottom: .2rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 600;
    font-size: .89rem;
    position: relative;
    transition: var(--transition);
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; transition: var(--transition); }
.sidebar-link:hover { background: rgba(255, 255, 255, .06); color: #fff; transform: translateX(3px); }
[dir="rtl"] .sidebar-link:hover { transform: translateX(-3px); }
.sidebar-link.active {
    background: linear-gradient(90deg, var(--brand), var(--brand-dark));
    color: #fff;
    box-shadow: 0 4px 14px var(--brand-glow);
}
.sidebar-link.active i { color: #fff; }

.sidebar-footer { padding: .9rem; border-top: 1px solid rgba(255, 255, 255, .07); }

.main-wrap {
    margin-inline-start: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    transition: var(--transition);
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(8px);
}

.sidebar-toggle-btn {
    display: none;
    border: none;
    background: var(--brand-light);
    color: var(--brand);
    width: 38px; height: 38px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar-toggle-btn:hover { background: var(--brand); color: #fff; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(17, 24, 39, .5);
    z-index: 1035;
    animation: fadeIn .2s ease;
}

.lang-switch a {
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 700;
    font-size: .78rem;
    transition: var(--transition);
}
.lang-switch a.active, .lang-switch a:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

.user-chip { display: flex; align-items: center; gap: .6rem; padding: .35rem .7rem .35rem .4rem; border-radius: 100px; background: var(--bg); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), #818cf8);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex-shrink: 0;
}

.content-area { padding: 1.6rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-105%); }
    [dir="rtl"] .sidebar { transform: translateX(105%); }
    .sidebar.show { transform: translateX(0); }
    .main-wrap { margin-inline-start: 0; }
    .sidebar-toggle-btn { display: inline-flex; }
    .sidebar-backdrop.show { display: block; }
}

/* ===== CARDS / SURFACES ===== */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 700; padding: .95rem 1.15rem; }
.card-body { padding: 1.15rem; }

.hover-lift { transition: var(--transition); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card .stat-label { color: var(--text-muted); font-size: .82rem; font-weight: 600; margin-bottom: .15rem; }
.stat-card .stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.15; }
.stat-card .stat-sub { font-size: .78rem; color: var(--text-muted); }

.stat-icon.bg-brand { background: var(--brand-light); color: var(--brand); }
.stat-icon.bg-success { background: var(--success-light); color: var(--success); }
.stat-icon.bg-warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.bg-danger { background: var(--danger-light); color: var(--danger); }
.stat-icon.bg-info { background: var(--info-light); color: var(--info); }

/* ===== BUTTONS ===== */
.btn { border-radius: var(--radius-sm); font-weight: 700; transition: var(--transition); letter-spacing: .01em; }
.btn:active { transform: scale(.97); }
.btn-primary, .btn-success, .btn-danger { border: none; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); }
.btn-primary:hover { box-shadow: 0 6px 16px var(--brand-glow); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); }
.btn-success:hover { box-shadow: 0 6px 16px rgba(16, 185, 129, .3); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #dc2626); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); }
.btn-lg { border-radius: 12px; }

/* ===== TABLES / FORMS / BADGES ===== */
.table { --bs-table-hover-bg: var(--brand-light); }
.table thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-muted); border-bottom-width: 1px; font-weight: 700; background: #fafbfd;
}
.table tbody tr { transition: var(--transition); }
.table-hover tbody tr:hover { background: var(--brand-light); }

.form-control, .form-select { border-radius: var(--radius-sm); border-color: var(--border); transition: var(--transition); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-glow); }

.badge { font-weight: 700; letter-spacing: .01em; border-radius: 7px; }

.alert { border: none; border-radius: var(--radius-sm); }
.alert-warning { background: var(--warning-light); color: #92400e; }

.live-pulse { animation: pulseRing 2s infinite; }

/* ===== POS / CASHIER SCREEN ===== */
#searchResults .list-group-item { border-radius: var(--radius-sm) !important; margin-bottom: .4rem; border: 1px solid var(--border); transition: var(--transition); }
#searchResults .list-group-item:hover { border-color: var(--brand); background: var(--brand-light); transform: translateX(2px) scale(1.005); }
#searchResults { max-height: 460px; overflow-y: auto; padding-inline-end: .25rem; }

#cartBody tr { animation: fadeInUp .3s ease both; }

.pos-total-box { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; border-radius: var(--radius); padding: 1rem 1.15rem; }

/* ===== Auth / login ===== */
.auth-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 10% -10%, #eef2ff 0%, transparent 60%),
                radial-gradient(1000px 500px at 110% 110%, #ecfdf5 0%, transparent 60%),
                var(--bg);
}
.auth-card { animation: popIn .4s cubic-bezier(.4,0,.2,1) both; }

.page-fade { animation: fadeIn .3s ease both; }

/* ===== QUICK PICK GRID (POS) ===== */
.quick-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: .5rem;
}
.quick-pick-btn {
    display: flex; flex-direction: column; align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem .35rem;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.quick-pick-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand); }
.quick-pick-btn:active { transform: scale(.96); }
.quick-pick-img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; margin-bottom: .3rem; }
.quick-pick-img-empty { display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--text-muted); }
.quick-pick-name { font-size: .72rem; text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; }
.quick-pick-price { font-size: .72rem; font-weight: 700; color: var(--brand); margin-top: .15rem; }

/* ===== PRODUCT THUMBNAILS ===== */
.product-thumb {
    width: 42px; height: 42px;
    border-radius: 9px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--bg);
}
.product-thumb-empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ===== TOASTS ===== */
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-16px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-10px) scale(.96); }
}
#toastStack {
    position: fixed;
    top: 1.25rem;
    inset-inline-end: 1.25rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: 340px;
}
.app-toast {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--brand);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: .8rem 1rem;
    font-size: .87rem;
    font-weight: 600;
    animation: toastIn .32s cubic-bezier(.4,0,.2,1) both;
}
.app-toast.leaving { animation: toastOut .22s ease both; }
.app-toast.success { border-inline-start-color: var(--success); }
.app-toast.danger  { border-inline-start-color: var(--danger); }
.app-toast.warning { border-inline-start-color: var(--warning); }
.app-toast i { font-size: 1.15rem; margin-top: .05rem; }
.app-toast.success i { color: var(--success); }
.app-toast.danger i  { color: var(--danger); }
.app-toast.warning i { color: var(--warning); }
.app-toast.info i    { color: var(--brand); }