/* =============================================
   WEIN — Stylesheet v2
   Design: Clean Ink — warm neutrals + vivid violet
   ============================================= */

/* ── Variables ── */
:root {
    --bg:          #F7F6F3;
    --surface:     #FFFFFF;
    --surface-2:   #F2F1EE;
    --text:        #141414;
    --text-2:      #555452;
    --text-3:      #9A9895;
    --border:      #E4E3DF;
    --radius:      14px;
    --radius-sm:   8px;
    --accent:      #6C47FF;
    --accent-h:    #5535E0;
    --accent-lt:   #EEE9FF;
    --danger:      #E5373A;
    --danger-h:    #C22C2F;
    --success:     #1A9E6A;
    --warning:     #E5981A;
    --warning-bg:  #FEF5E4;
    --shadow:      0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
    --shadow-pop:  0 4px 24px rgba(0,0,0,.12);
    --sidebar-bg:  #100F14;
    --sidebar-txt: #7D7B88;
    --sidebar-act: #6C47FF;
    --nav-h:       58px;
}

[data-theme="dark"] {
    --bg:          #0E0D11;
    --surface:     #18171D;
    --surface-2:   #211F28;
    --text:        #EDECF0;
    --text-2:      #9E9CAA;
    --text-3:      #5C5A68;
    --border:      #2A2830;
    --accent:      #8B6FFF;
    --accent-h:    #7558F5;
    --accent-lt:   #1E1A30;
    --danger:      #FF5A5D;
    --danger-h:    #E04043;
    --success:     #2ECC8F;
    --warning:     #FFB830;
    --warning-bg:  #1E1608;
    --shadow:      0 1px 4px rgba(0,0,0,.25), 0 4px 16px rgba(0,0,0,.3);
    --shadow-pop:  0 8px 32px rgba(0,0,0,.5);
    --sidebar-bg:  #09090C;
    --sidebar-txt: #5A5869;
    --sidebar-act: #8B6FFF;
}

/* ── Backward-compatible aliases (old variable names used in views) ── */
:root {
    --bg-primary:    var(--bg);
    --bg-secondary:  var(--surface);
    --bg-card:       var(--surface);
    --text-primary:  var(--text);
    --text-secondary:var(--text-2);
    --text-muted:    var(--text-3);
    --border-radius: var(--radius);
    --accent-light:  var(--accent-lt);
    --accent-hover:  var(--accent-h);
    --danger-hover:  var(--danger-h);
    --shadow-md:     var(--shadow-pop);
    --header-bg:     var(--surface);
    --nav-height:    var(--nav-h);
    --primary:       var(--accent);
    --bg-tertiary:   var(--surface-2);
}
[data-theme="dark"] {
    --primary:       var(--accent);
    --bg-tertiary:   var(--surface-2);
}
[data-theme="dark"] {
    --bg-primary:    var(--bg);
    --bg-secondary:  var(--surface);
    --bg-card:       var(--surface);
    --text-primary:  var(--text);
    --text-secondary:var(--text-2);
    --text-muted:    var(--text-3);
    --accent-light:  var(--accent-lt);
    --header-bg:     var(--surface);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .25s, color .25s;
    -webkit-font-smoothing: antialiased;
}

[dir="rtl"] body { font-family: system-ui, 'Segoe UI', Tahoma, sans-serif; }

/* ── Typography ── */
h1,h2,h3,h4,h5,h6 { font-weight: 700; color: var(--text); line-height: 1.25; }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-h); }
small, .text-muted { color: var(--text-3) !important; font-size: .8125rem; }

/* ── RTL helpers ── */
[dir="rtl"] .ms-auto  { margin-right: auto !important; margin-left: 0 !important; }
[dir="rtl"] .me-2     { margin-left: .5rem  !important; margin-right: 0 !important; }
[dir="rtl"] .me-3     { margin-left: 1rem   !important; margin-right: 0 !important; }
[dir="rtl"] .sidebar  { left: auto; right: 0; }
[dir="rtl"] .main-content { margin-left: 0; margin-right: 240px; }
[dir="rtl"] .table th,
[dir="rtl"] .table td { text-align: right; }
[dir="rtl"] .sidebar-nav a.active,
[dir="rtl"] .sidebar-nav a:hover { border-left: none; border-right: 3px solid var(--sidebar-act); }
[dir="rtl"] .notification-item { border-left: none; border-right: 4px solid var(--accent); }
[dir="rtl"] .alert-success,
[dir="rtl"] .alert-danger,
[dir="rtl"] .alert-warning,
[dir="rtl"] .alert-info { border-left: none; border-right: 4px solid currentColor; }

/* ═══════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════ */
.admin-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
    padding: 1.375rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.5px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar-brand span { color: var(--sidebar-act); }

.sidebar-nav { flex: 1; padding: .75rem 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    color: var(--sidebar-txt);
    font-size: .875rem;
    font-weight: 500;
    transition: color .15s, background .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.04); border-left-color: rgba(255,255,255,.15); }
.sidebar-nav a.active { color: #fff; background: rgba(108,71,255,.12); border-left-color: var(--sidebar-act); }

.sidebar-nav .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.nav-section {
    padding: 1rem 1.25rem .3rem;
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,.2);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: .72rem;
    color: rgba(255,255,255,.2);
    text-align: center;
}

/* Main content */
.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

.topbar-title { font-size: .9375rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.page-content { padding: 1.5rem; flex: 1; }

/* ═══════════════════════════════════════
   PUBLIC LAYOUT
   ═══════════════════════════════════════ */
.public-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: .75rem;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.5px;
    flex-shrink: 0;
}
.nav-brand em { font-style: normal; color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: .25rem; }

.nav-links a {
    color: var(--text-2);
    font-size: .875rem;
    font-weight: 500;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.nav-links a:hover, .nav-links a.fw-600 { color: var(--text); background: var(--surface-2); }

.public-content { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; }

/* Public footer bar */
.public-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: .75rem;
    color: var(--text-3);
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ═══════════════════════════════════════
   CONTACT FAB
   ═══════════════════════════════════════ */
.contact-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .5rem;
}

[dir="rtl"] .contact-fab { right: auto; left: 1.5rem; align-items: flex-start; }

.contact-fab-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 16px rgba(108,71,255,.4);
    transition: transform .2s, box-shadow .2s;
}
.contact-fab-btn:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(108,71,255,.5); }

/* Contact modal */
.contact-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 3000;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.contact-modal-overlay.open { display: flex; }

.contact-modal {
    background: var(--surface);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem 1.5rem 2rem;
    animation: slideUp .25s cubic-bezier(.4,0,.2,1);
    position: relative;
}

@keyframes slideUp {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.contact-modal-handle {
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 0 auto 1.25rem;
}

.contact-modal h3 { font-size: 1rem; margin-bottom: 1.25rem; }

.contact-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 0;
    border-bottom: 1px solid var(--border);
}
.contact-row:last-child { border-bottom: none; }
.contact-row-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--accent-lt);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.contact-row-label { font-size: .75rem; color: var(--text-3); margin-bottom: .1rem; }
.contact-row-value { font-size: .9375rem; font-weight: 600; color: var(--text); }

.contact-call-btn {
    display: block;
    width: 100%;
    margin-top: 1.25rem;
    padding: .85rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .9375rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}
.contact-call-btn:hover { background: var(--accent-h); color: #fff; }

/* ═══════════════════════════════════════
   CARDS
   ═══════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: .9375rem;
    gap: .5rem;
    flex-wrap: wrap;
}

.card-body { padding: 1.25rem; }

/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .875rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.125rem 1rem;
    box-shadow: var(--shadow);
}

.stat-card .stat-number {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: .25rem;
}
.stat-card .stat-label { font-size: .8rem; color: var(--text-3); font-weight: 500; }
.stat-card.warning .stat-number { color: var(--warning); }
.stat-card.danger  .stat-number { color: var(--danger); }
.stat-card.success .stat-number { color: var(--success); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 600;
    transition: background .15s, transform .1s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.3;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover { background: var(--danger-h); color: #fff; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-warning   { background: var(--warning);  color: #fff; }
.btn-warning:hover { opacity: .9; }
.btn-ghost     { background: transparent; color: var(--text-2); padding: .4rem .7rem; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm        { padding: .35rem .75rem; font-size: .8125rem; }
.btn-icon      { padding: .45rem; width: 34px; height: 34px; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.table th {
    background: var(--surface-2);
    color: var(--text-3);
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover   { background: var(--surface-2); }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.badge-open      { background: #DCFCE7; color: #166534; }
.badge-closed    { background: #FEE2E2; color: #991B1B; }
.badge-sorting   { background: #FEF9C3; color: #854D0E; }
.badge-sent      { background: #DBEAFE; color: #1E40AF; }
.badge-shipping  { background: #EDE9FE; color: #5B21B6; }
.badge-delivery  { background: #FAE8FF; color: #6B21A8; }
.badge-delivered { background: #DCFCE7; color: #166534; }
.badge-available { background: #DCFCE7; color: #166534; }
.badge-soldout   { background: #FEE2E2; color: #991B1B; }
.badge-hidden    { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.badge-updated   { background: #FEF9C3; color: #854D0E; }

[data-theme="dark"] .badge-open,
[data-theme="dark"] .badge-delivered,
[data-theme="dark"] .badge-available { background: #052e16; color: #86efac; }
[data-theme="dark"] .badge-closed,
[data-theme="dark"] .badge-soldout   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-sorting,
[data-theme="dark"] .badge-updated   { background: #422006; color: #fcd34d; }
[data-theme="dark"] .badge-sent      { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-shipping  { background: #2e1065; color: #c4b5fd; }
[data-theme="dark"] .badge-delivery  { background: #3b0764; color: #e9d5ff; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: .375rem;
    letter-spacing: .01em;
}

.form-control {
    width: 100%;
    padding: .625rem .875rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .9375rem;
    font-family: inherit;
    transition: border .15s, box-shadow .15s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,71,255,.15);
}

select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9895' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .875rem center; padding-right: 2.25rem; }
[dir="rtl"] select.form-control { background-position: left .875rem center; padding-right: .875rem; padding-left: 2.25rem; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-error { color: var(--danger); font-size: .8rem; margin-top: .3rem; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Alerts ── */
.alert {
    padding: .875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-weight: 500;
}

.alert-success { background: #DCFCE7; color: #166534; border-left: 4px solid #22c55e; }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: #854D0E; border-left: 4px solid var(--warning); }
.alert-info    { background: #DBEAFE; color: #1E40AF; border-left: 4px solid #3b82f6; }

[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; }
[data-theme="dark"] .alert-danger  { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: #422006; color: #fcd34d; }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; }

/* ── Modals ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .2s cubic-bezier(.4,0,.2,1);
}

@keyframes modalIn {
    from { transform: translateY(-16px) scale(.98); opacity: 0; }
    to   { transform: translateY(0)     scale(1);   opacity: 1; }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 700;
    gap: .5rem;
}

.modal-body   { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.25rem; color: var(--text-3); line-height: 1;
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--surface-2); color: var(--danger); }

/* ── Product Grid / List ── */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
}
.product-card:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }

.product-card img {
    width: 100%; height: 180px;
    object-fit: cover; background: var(--surface-2);
    display: block;
}
.product-card .product-body    { padding: 1rem; }
.product-card .product-title   { font-weight: 700; margin-bottom: .4rem; font-size: .9375rem; }
.product-card .product-price   { color: var(--accent); font-weight: 800; font-size: 1.125rem; }

/* List view */
.products-list .product-card   { display: flex; align-items: center; gap: 1rem; }
.products-list .product-card img { width: 80px; height: 80px; flex-shrink: 0; border-radius: var(--radius-sm); }

/* ── Notification items ── */
.notification-item {
    padding: .875rem 1rem;
    border-left: 4px solid var(--accent);
    background: var(--accent-lt);
    border-radius: var(--radius-sm);
    margin-bottom: .75rem;
}

/* ── View toggle ── */
.view-toggle { display: flex; gap: .25rem; }
.view-toggle button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .375rem .6rem;
    cursor: pointer;
    color: var(--text-3);
    font-size: .9rem;
    transition: background .15s, color .15s;
}
.view-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Page Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header h1 { font-size: 1.3125rem; }

/* ── Status dot ── */
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-inline-end: .4rem; }
.dot-open      { background: #22c55e; }
.dot-closed    { background: var(--danger); }
.dot-sorting   { background: var(--warning); }
.dot-shipping  { background: #6366f1; }
.dot-delivered { background: #059669; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-3); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state p { font-size: .9375rem; }

/* ── Admin login page ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem 2rem;
}
.login-logo {
    text-align: center;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: 2rem;
    color: var(--text);
}
.login-logo em { font-style: normal; color: var(--accent); }

/* ═══════════════════════════════════════
   RESPONSIVE — MOBILE FIRST
   ═══════════════════════════════════════ */

/* Tablet & mobile: hide sidebar, full-width content */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.25);
    }
    [dir="rtl"] .sidebar.open { box-shadow: -4px 0 24px rgba(0,0,0,.25); }

    /* Overlay when sidebar open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 999;
    }
    .sidebar-overlay.open { display: block; }

    .main-content { margin-left: 0 !important; margin-right: 0 !important; }

    .page-content   { padding: 1rem; }
    .public-content { padding: 1rem 1rem 5rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
    .form-row   { grid-template-columns: 1fr; gap: .75rem; }

    .products-grid { grid-template-columns: 1fr !important; }

    .modal {
        width: 100% !important;
        max-width: none !important;
        max-height: 85vh;
        border-radius: var(--radius) var(--radius) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
    }
    .modal-overlay { align-items: flex-end; padding: 0; }

    .page-header h1 { font-size: 1.125rem; }

    .topbar { padding: 0 1rem; }

    /* Nav links on mobile: tighter */
    .nav-links a { padding: .35rem .5rem; font-size: .8125rem; }
    .nav-brand   { font-size: 1rem; }

    /* Table scroll hint */
    .table-wrapper { border-radius: var(--radius-sm); }

    /* Bigger touch targets */
    .btn { min-height: 40px; }
    .form-control { padding: .75rem .875rem; font-size: 1rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .topbar-title { max-width: 140px; }
}

/* ═══════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════ */
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-1        { gap: .5rem; }
.gap-2        { gap: 1rem; }
.mt-1         { margin-top: .5rem; }
.mt-2         { margin-top: 1rem; }
.mb-1         { margin-bottom: .5rem; }
.mb-2         { margin-bottom: 1rem; }
.mb-3         { margin-bottom: 1.5rem; }
.me-1         { margin-inline-end: .25rem; }
.me-2         { margin-inline-end: .5rem; }
.me-3         { margin-inline-end: 1rem; }
.ms-auto      { margin-inline-start: auto; }
.text-right   { text-align: end; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.w-100        { width: 100%; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Shared page patterns — used across the admin and customer flows */
.page-stack { display: grid; gap: 1.25rem; }
.page-intro, .customer-header-card, .co-header {
    background: linear-gradient(135deg, var(--accent-lt), var(--surface));
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: clamp(1rem, 3vw, 1.75rem);
    box-shadow: var(--shadow);
}
.page-intro { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-intro h1, .customer-page-title, .co-title { font-size: clamp(1.25rem, 3vw, 1.8rem); margin: 0; color: var(--text); }
.page-intro p, .customer-page-subtitle, .co-sub { color: var(--text-2); margin: .35rem 0 0; }
.idx-header, .pub-idx-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.idx-title { margin: 0; font-size: clamp(1.25rem, 3vw, 1.5rem); }
.filter-bar, .pub-filter-bar, .co-search-form { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filter-search-wrap, .pub-search-wrap { position: relative; flex: 1 1 220px; min-width: 0; }
.filter-icon, .pub-filter-icon { position: absolute; inset-inline-start: .9rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-3); }
.filter-input, .pub-filter-input, .filter-select, .pub-filter-select {
    min-height: 42px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit;
}
.filter-input, .pub-filter-input { width: 100%; padding: .65rem .875rem .65rem 2.45rem; }
[dir="rtl"] .filter-input, [dir="rtl"] .pub-filter-input { padding: .65rem 2.45rem .65rem .875rem; }
.filter-select, .pub-filter-select { padding: .65rem .875rem; min-width: 160px; }
.content-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.content-grid--wide { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.form-card { max-width: 680px; }
.form-card--compact { max-width: 540px; }
.action-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.table-wrapper { position: relative; }
.table-wrapper::after { content: ''; position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: 20px; pointer-events: none; background: linear-gradient(90deg, transparent, var(--surface)); opacity: .7; }
.table td .d-flex { min-width: max-content; }
.topbar-user { font-size: .8125rem; color: var(--text-3); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dashboard */
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dashboard-hero h1 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.8rem); }
.dashboard-hero p { margin: .35rem 0 0; color: var(--text-2); }
.system-status { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .75rem; border-radius: 999px; background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); font-size: .8125rem; font-weight: 700; }
.system-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.dashboard-grid .card { min-width: 0; }

/* Customer order cards */
.customer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.customer-card, .co-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.customer-card { transition: transform .2s, box-shadow .2s, border-color .2s; }
.customer-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); border-color: var(--accent); }
.customer-card-body { padding: 1.25rem; }
.customer-name { color: var(--text); font-size: 1.05rem; font-weight: 750; }
.customer-id { color: var(--text-3); font-size: .8125rem; margin-top: .2rem; }
.customer-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 1.25rem 0; }
.info-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; min-width: 0; }
.info-label { display: block; color: var(--text-3); font-size: .75rem; margin-bottom: .25rem; }
.info-value { color: var(--text); font-weight: 650; font-size: .875rem; overflow-wrap: anywhere; }
.meta-section { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; color: var(--text-2); font-size: .8125rem; }
.status-badge, .co-badge { display: inline-flex; padding: .3rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.status-badge.updated, .co-badge.updated { background: var(--warning-bg); color: var(--warning); }
.actions-wrapper { display: flex; gap: .625rem; }
.btn-view, .btn-delete { flex: 1; min-height: 42px; border: 0; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; padding: .55rem .75rem; font: inherit; font-weight: 700; cursor: pointer; }
.btn-view { background: var(--accent); color: #fff; }.btn-delete { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.empty-state-card { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 3rem 1.25rem; text-align: center; }.empty-icon { font-size: 2.75rem; margin-bottom: .75rem; }
.co-show-wrap { display: grid; gap: 1.25rem; }.co-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }.co-top-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }.co-card-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 700; }.co-card-body { padding: 1.25rem; display: grid; gap: .75rem; }.co-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }.co-lbl { color: var(--text-3); font-size: .8125rem; }.co-val { color: var(--text); font-weight: 650; text-align: end; overflow-wrap: anywhere; }.co-divider { border: 0; border-top: 1px solid var(--border); }.co-total-val, .price-set { color: var(--success); }.price-pending { color: var(--warning); }.price-form-row { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }.price-input-wrap { flex: 0 1 190px; }.price-label { display: block; font-size: .8125rem; font-weight: 650; color: var(--text-2); margin-bottom: .375rem; }.price-preview { flex: 1 1 220px; padding: .875rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }.preview-row { display: flex; justify-content: space-between; gap: .75rem; padding: .25rem 0; color: var(--text-2); font-size: .8125rem; }.preview-total { margin-top: .35rem; padding-top: .6rem; border-top: 1px solid var(--border); color: var(--text); font-weight: 700; }

/* Public navigation and status journey */
.public-menu-toggle { display: none; width: 42px; height: 42px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; padding: .65rem; }.public-menu-toggle span { display: block; height: 2px; background: currentColor; margin: 4px 0; border-radius: 2px; transition: transform .2s, opacity .2s; }.public-menu-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }.public-menu-toggle.open span:nth-child(2) { opacity: 0; }.public-menu-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.order-timeline { display: grid; grid-template-columns: repeat(7, minmax(90px, 1fr)); gap: .5rem; overflow-x: auto; padding: .25rem 0 .75rem; }.timeline-step { display: grid; gap: .4rem; justify-items: center; min-width: 90px; color: var(--text-3); font-size: .75rem; text-align: center; }.timeline-step::before { content: ''; width: 12px; height: 12px; border: 3px solid var(--border); border-radius: 50%; background: var(--surface); }.timeline-step.is-current, .timeline-step.is-complete { color: var(--accent); font-weight: 700; }.timeline-step.is-current::before, .timeline-step.is-complete::before { border-color: var(--accent); background: var(--accent); }.timeline-step.is-complete::before { box-shadow: 0 0 0 4px var(--accent-lt); }

@media (max-width: 768px) {
    .public-nav { height: 64px; padding: 0 1rem; }.public-menu-toggle { display: block; order: 2; }.nav-links { display: none; position: absolute; top: calc(100% + 1px); inset-inline: 0; padding: .75rem 1rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-pop); flex-direction: column; align-items: stretch; gap: .35rem; }.nav-links.open { display: flex; }.nav-links a, .nav-links form, .nav-links form .btn { width: 100%; }.nav-links a { padding: .8rem .875rem; }.nav-links form .btn { justify-content: flex-start; }.topbar-user { display: none; }.content-grid, .content-grid--wide, .dashboard-grid, .co-top-grid { grid-template-columns: 1fr; }.customer-grid { grid-template-columns: 1fr; }.customer-header-card { padding: 1rem; }.co-header { padding: 1rem; }.customer-info-grid { gap: .5rem; }.price-input-wrap, .price-preview, .price-submit-btn { width: 100%; flex-basis: 100%; }.actions-wrapper .btn-view, .actions-wrapper form { flex: 1; }.actions-wrapper form .btn-delete { width: 100%; }.table { min-width: 620px; }.table-wrapper { margin: 0; }.card-header { padding: .875rem 1rem; }.card-body { padding: 1rem; }.modal-header, .modal-body, .modal-footer { padding-inline: 1rem; }.modal-footer .btn { flex: 1; }.order-timeline { grid-template-columns: repeat(7, 84px); }
}
@media (max-width: 420px) { .stats-grid { grid-template-columns: 1fr 1fr; }.customer-info-grid { grid-template-columns: 1fr; }.meta-section { display: grid; grid-template-columns: 1fr 1fr; }.page-header > .d-flex, .page-header > .action-row { width: 100%; }.page-header > .d-flex .btn, .page-header > .action-row .btn { flex: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* Legacy dashboard markup is intentionally normalized here while its data structure stays unchanged. */
.dashboard-shell > div:first-child { background: linear-gradient(135deg, var(--accent-lt), var(--surface)) !important; border-color: var(--border) !important; box-shadow: var(--shadow) !important; }
.dashboard-shell h1, .dashboard-shell [style*="color: #fff"], .dashboard-shell [style*="color:#fff"] { color: var(--text) !important; }
.dashboard-shell p, .dashboard-shell [style*="color: #9ca3af"], .dashboard-shell [style*="color:#9ca3af"] { color: var(--text-2) !important; }
.dashboard-shell > div:nth-child(2) > div { background: var(--surface) !important; border-color: var(--border) !important; box-shadow: var(--shadow); border-radius: var(--radius) !important; }
.dashboard-shell > div:nth-child(2) > div > div:first-child { color: var(--accent) !important; }
.dashboard-shell > div:nth-child(2) > div > div:last-child { color: var(--text-3) !important; }
.dashboard-shell .card { background: var(--surface) !important; border-color: var(--border) !important; border-radius: var(--radius) !important; }
.dashboard-shell .card-header, .dashboard-shell .card-body, .dashboard-shell .table th, .dashboard-shell .table td { border-color: var(--border) !important; }
.dashboard-shell .table tr, .dashboard-shell .table td { background: transparent !important; color: var(--text) !important; }
.dashboard-shell .table a { color: var(--accent) !important; }
.justify-content-between { justify-content: space-between; }.align-items-start { align-items: flex-start; }.flex-column { flex-direction: column; }.mb-4 { margin-bottom: 2rem; }
@media (max-width: 768px) { .page-content [style*="grid-template-columns:1fr 1fr"], .public-content [style*="grid-template-columns:1fr 1fr"], .page-content [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: 1fr !important; } }
@media (min-width: 992px) { .flex-lg-row { flex-direction: row; }.align-items-lg-center { align-items: center; } }
