/* ============================================================
   RWS Platform — Production Design System
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
    --primary: #2ecc71;
    --primary-dark: #27ae60;
    --primary-light: #a3f0c0;
    --secondary: #e67e22;
    --secondary-dark: #d35400;
    --accent: #f1c40f;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --info: #3498db;
    --dark: #2c3e50;
    --dark-lighter: #34495e;
    --muted: #7f8c8d;
    --light: #f8f9fa;
    --white: #ffffff;
    --glass: rgba(255, 255, 255, 0.78);
    --glass-border: rgba(255, 255, 255, 0.35);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.12);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 16px 48px rgba(31, 38, 135, 0.18);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(.4,0,.2,1);
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: #f0f2f5;
    background-image:
        radial-gradient(at 0% 0%, rgba(46,204,113,.08) 0, transparent 50%),
        radial-gradient(at 50% 0%, rgba(230,126,34,.06) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(241,196,15,.06) 0, transparent 50%);
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); }

img { max-width: 100%; height: auto; display: block; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--dark); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-800 { font-weight: 800; }
.text-primary { color: var(--primary) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--primary) !important; }
.text-warning { color: var(--secondary) !important; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem 2rem; }
.page-wrapper { display: flex; min-height: 100vh; }
.main-content { flex: 1; padding: 1.5rem 2rem; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: .5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Glass Card ───────────────────────────────────────────── */
.glass-card {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: transform var(--transition), box-shadow var(--transition);
}
.glass-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.glass-card.no-hover:hover { transform: none; box-shadow: var(--shadow); }

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid #eef0f2;
}

/* ── Top Navbar ───────────────────────────────────────────── */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 2rem;
    background: var(--glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.logo i { -webkit-text-fill-color: var(--primary); }

.nav-links {
    display: flex;
    gap: 0;
    list-style: none;
    align-items: center;
}
.nav-links a {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.1rem;
    border-radius: var(--radius-sm);
    color: var(--dark-lighter);
    font-weight: 600;
    font-size: .9rem;
    transition: all var(--transition);
    white-space: nowrap;
}
.nav-links a:hover,
.nav-links a.active {
    background: rgba(46,204,113,.1);
    color: var(--primary-dark);
}
.nav-links a.active { font-weight: 700; }

.nav-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 600;
    font-size: .9rem;
    color: var(--muted);
}
.nav-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .8rem;
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: 1.3rem;
    color: var(--dark);
    cursor: pointer;
    border-radius: var(--radius-sm);
    background: #f0f2f5;
    border: none;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 250px;
    background: var(--white);
    border-right: 1px solid #eef0f2;
    min-height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
    overflow: visible;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    z-index: 100;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
}

/* Auto-expand state - pushes content */
.sidebar.auto-expanded {
    width: 250px;
    min-width: 250px;
    opacity: 1;
    visibility: visible;
    overflow: visible;
    position: sticky;
    z-index: 100;
}

/* When sidebar is collapsed and hovered, show overlay version */
.sidebar.collapsed.has-focus,
.sidebar.collapsed:hover {
    width: 250px;
    min-width: 250px;
    opacity: 1;
    visibility: visible;
    overflow: visible;
    position: fixed;
    left: 0;
    top: 56px;
    height: calc(100vh - 56px);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    z-index: 101;
}

/* Sidebar pushes content - expanded state in layout */
.sidebar:not(.collapsed) {
    opacity: 1;
    visibility: visible;
}

.sidebar.collapsed .sidebar-content {
    padding: 1.5rem 0;
}

/* Visual strip indicator when sidebar is collapsed */
.sidebar-collapsed-indicator {
    display: none;
    position: fixed;
    left: 0;
    top: 56px;
    width: 4px;
    height: calc(100vh - 56px);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    z-index: 96;
    transition: width 0.2s ease;
}

body.sidebar-collapsed .sidebar-collapsed-indicator,
.sidebar.collapsed ~ .sidebar-collapsed-indicator {
    display: block;
}

body.sidebar-collapsed:hover .sidebar-collapsed-indicator,
.sidebar-collapsed-indicator:hover {
    width: 6px;
}

/* Modern Hamburger menu button */
.sidebar-hamburger {
    display: none;
    position: fixed;
    left: 20px;
    top: 76px;
    width: 48px;
    height: 48px;
    background: var(--white);
    border: none;
    border-radius: 12px;
    box-shadow: 
        0 4px 12px rgba(0,0,0,0.08),
        0 2px 4px rgba(0,0,0,0.04),
        inset 0 1px 0 rgba(255,255,255,0.8);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 98;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--dark);
    font-size: 1.2rem;
}

.sidebar-hamburger::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-hamburger:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 
        0 8px 24px rgba(46,204,113,0.2),
        0 4px 8px rgba(0,0,0,0.08);
    color: var(--primary-dark);
}

.sidebar-hamburger:hover::before {
    opacity: 1;
}

.sidebar-hamburger:active {
    transform: translateY(0) scale(0.98);
}

.sidebar.collapsed ~ .sidebar-hamburger,
body.sidebar-collapsed .sidebar-hamburger {
    display: flex;
}

/* Invisible trigger area for hover expansion */
.sidebar-trigger-area {
    display: none;
    position: fixed;
    left: 0;
    top: 56px;
    width: 60px;
    height: calc(100vh - 56px);
    z-index: 97;
    cursor: pointer;
}

.sidebar.collapsed ~ .sidebar-trigger-area,
body.sidebar-collapsed .sidebar-trigger-area {
    display: block;
}

/* Backdrop when sidebar is expanded on hover */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.15);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body:has(.sidebar.collapsed.has-focus) .sidebar-backdrop,
body:has(.sidebar.collapsed:hover) .sidebar-backdrop,
.sidebar-hamburger:hover ~ .sidebar-backdrop,
.sidebar-trigger-area:hover ~ .sidebar-backdrop {
    display: block;
    opacity: 1;
}

.sidebar-content {
    padding: 1.5rem 0;
    overflow-y: auto;
    height: 100%;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-section-title {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar.collapsed.has-focus .nav-text,
.sidebar.collapsed.has-focus .sidebar-section-title,
.sidebar.collapsed:hover .nav-text,
.sidebar.collapsed:hover .sidebar-section-title {
    opacity: 1;
    transition: opacity 0.2s ease 0.1s;
}

.sidebar-section { padding: 0 1rem; margin-bottom: 1.5rem; }

.sidebar-section-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: 0 .75rem;
    margin-bottom: .5rem;
    transition: opacity var(--transition);
}

.sidebar-nav { list-style: none; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem .9rem;
    border-radius: 10px;
    color: var(--dark-lighter);
    font-weight: 500;
    font-size: .9rem;
    transition: all 0.25s ease;
    margin-bottom: 4px;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.sidebar-nav a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 0 2px 2px 0;
    transition: height 0.25s ease;
}

.sidebar-nav a:hover { 
    background: rgba(46,204,113,0.06); 
    color: var(--primary-dark);
    transform: translateX(4px);
}

.sidebar-nav a:hover::before {
    height: 60%;
}

.sidebar-nav a.active {
    background: rgba(46,204,113,.1);
    color: var(--primary-dark);
    font-weight: 600;
}

.sidebar-nav a.active::before {
    height: 70%;
}

.sidebar-nav a i { 
    width: 22px; 
    text-align: center; 
    font-size: 1rem; 
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.sidebar-nav a:hover i {
    transform: scale(1.1);
}

.sidebar.collapsed .sidebar-nav a {
    padding: .75rem;
    justify-content: center;
}

.sidebar.collapsed:hover .sidebar-nav a,
.sidebar.collapsed.has-focus .sidebar-nav a {
    justify-content: flex-start;
    padding: .75rem .9rem;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    color: var(--dark);
    cursor: pointer;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    margin-right: 0.5rem;
    transition: all var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(46,204,113,.1);
    color: var(--primary-dark);
}

.nav-left {
    display: flex;
    align-items: center;
}

.logo-text {
    transition: opacity var(--transition);
}

.sidebar.collapsed ~ .main-content .logo-text {
    opacity: 1;
}

/* Main content adjustment for collapsed sidebar */
.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    transition: margin-left var(--transition);
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 800; }
.page-header .subtitle { font-size: .9rem; color: var(--muted); margin-top: .15rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid #eef0f2;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card:hover::after { opacity: 1; }
.stat-card .stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-bottom: .75rem;
}
.stat-card .stat-icon.green  { background: rgba(46,204,113,.12); color: var(--primary); }
.stat-card .stat-icon.orange { background: rgba(230,126,34,.12); color: var(--secondary); }
.stat-card .stat-icon.blue   { background: rgba(52,152,219,.12); color: var(--info); }
.stat-card .stat-icon.red    { background: rgba(231,76,60,.12);  color: var(--danger); }
.stat-card .stat-icon.yellow { background: rgba(241,196,15,.12); color: var(--accent); }

.stat-card .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    font-family: var(--font);
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:active { transform: scale(.97); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(46,204,113,.25);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(46,204,113,.35); color: white; }

.btn-secondary {
    background: var(--secondary);
    color: white;
    box-shadow: 0 2px 8px rgba(230,126,34,.25);
}
.btn-secondary:hover { background: var(--secondary-dark); color: white; }

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px rgba(231,76,60,.2);
}
.btn-danger:hover { background: var(--danger-dark); color: white; }

.btn-outline {
    background: transparent;
    color: var(--dark-lighter);
    border: 1px solid #dfe6e9;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(46,204,113,.04); }

.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-lg { padding: .8rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .5rem; width: 36px; height: 36px; }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: .35rem;
}
.form-group label .required { color: var(--danger); }

.form-control {
    width: 100%;
    padding: .65rem .9rem;
    border-radius: var(--radius-sm);
    border: 1.5px solid #dfe6e9;
    background: var(--white);
    font-size: .9rem;
    font-family: var(--font);
    color: var(--dark);
    transition: all var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,.1);
}
.form-control::placeholder { color: #b2bec3; }

select.form-control { cursor: pointer; appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; gap: .5rem; align-items: flex-end; }

.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.form-check label { margin-bottom: 0; cursor: pointer; }

/* ── Data Table ───────────────────────────────────────────── */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    border: 1px solid #eef0f2;
    background: var(--white);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: .85rem 1rem;
    background: #f8f9fb;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    border-bottom: 2px solid #eef0f2;
    white-space: nowrap;
}
.data-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid #f4f5f6;
    vertical-align: middle;
    font-size: .9rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #fafbfc; }
.data-table .actions { display: flex; gap: .35rem; }

/* Action groups for better organization */
.data-table .actions-wrap {
    flex-wrap: wrap;
    gap: .5rem;
}

.action-group {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .65rem;
    border-radius: 50px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: capitalize;
}
.badge-success { background: rgba(46,204,113,.12); color: #1a9953; }
.badge-warning { background: rgba(230,126,34,.12); color: #b5651d; }
.badge-danger  { background: rgba(231,76,60,.12);  color: #c0392b; }
.badge-info    { background: rgba(52,152,219,.12);  color: #2471a3; }
.badge-muted   { background: #f0f2f5; color: var(--muted); }
.badge-primary { background: rgba(46,204,113,.12);  color: var(--primary-dark); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeOverlay .2s ease;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp .3s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eef0f2;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: #f0f2f5;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
    transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: white; }
.modal-body { padding: 1.5rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #eef0f2;
}

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
    padding: .85rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    animation: fadeIn .4s ease;
}
.flash-success { background: rgba(46,204,113,.1); color: #1a9953; border: 1px solid rgba(46,204,113,.2); }
.flash-error   { background: rgba(231,76,60,.1);  color: #c0392b; border: 1px solid rgba(231,76,60,.2); }
.flash-info    { background: rgba(52,152,219,.1);  color: #2471a3; border: 1px solid rgba(52,152,219,.2); }

/* ── Toolbar / Filter Bar ─────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: .75rem 1rem;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid #eef0f2;
}
.toolbar .form-control { width: auto; min-width: 180px; }
.toolbar .search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.toolbar .search-box input { padding-left: 2.2rem; }
.toolbar .search-box i {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: .85rem;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.5rem; overflow-x: auto; padding-bottom: 2px; }
.tab-btn {
    padding: .6rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: .9rem;
    color: var(--muted);
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-top: 1.5rem;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 .5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .85rem;
    transition: all var(--transition);
    border: 1px solid #eef0f2;
    color: var(--dark-lighter);
}
.pagination a:hover { background: #f4f6f8; color: var(--primary); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-weight: 700; margin-bottom: .25rem; color: var(--dark-lighter); }
.empty-state p { font-size: .9rem; }

/* ── Status Timeline ──────────────────────────────────────── */
.status-steps { display: flex; align-items: center; gap: 0; margin: 1rem 0; flex-wrap: wrap; }
.status-step {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
    position: relative;
}
.status-step.completed { color: var(--primary-dark); }
.status-step.current { color: var(--secondary); font-weight: 800; }
.status-step::after {
    content: '→';
    margin-left: .5rem;
    color: #dfe6e9;
}
.status-step:last-child::after { display: none; }

/* ── Receipt / Print ──────────────────────────────────────── */
.receipt {
    background: var(--white);
    border: 1px dashed #ccc;
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    max-width: 400px;
    margin: 0 auto;
    font-size: .85rem;
}
.receipt-header { text-align: center; border-bottom: 1px dashed #ccc; padding-bottom: .75rem; margin-bottom: .75rem; }
.receipt-footer { text-align: center; border-top: 1px dashed #ccc; padding-top: .75rem; margin-top: .75rem; font-size: .75rem; color: var(--muted); }

/* ── Mobile Bottom Nav (Driver/Picker) ─────────────────────── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    z-index: 1000;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.07);
}
.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 58px;
}
.bottom-nav-items li {
    flex: 1;
    display: flex;
}
.bottom-nav-items a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .12rem;
    min-height: 52px;
    padding: .35rem .5rem;
    color: var(--muted);
    font-size: .63rem;
    font-weight: 600;
    transition: color .2s ease, background .2s ease;
    text-decoration: none;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    border-radius: 0;
}
.bottom-nav-items a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    transform: scaleX(0);
    transition: transform .2s ease;
}
.bottom-nav-items a i {
    font-size: 1.2rem;
    transition: transform .2s ease;
    line-height: 1;
}
.bottom-nav-items a span { display: block; line-height: 1; }
.bottom-nav-items a.active,
.bottom-nav-items a:hover {
    color: var(--primary);
    background: rgba(46, 204, 113, 0.06);
}
.bottom-nav-items a.active::after { transform: scaleX(1); }
.bottom-nav-items a.active i { transform: scale(1.1); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

.fade-in { animation: fadeIn .5s ease forwards; }

/* ── Auth Page ─────────────────────────────────────────────── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    padding: 2rem;
}
.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    animation: slideUp .5s ease;
}
.auth-card .auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-card .auth-logo h2 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-card .auth-logo p { color: var(--muted); font-size: .9rem; }

/* ── Public Menu Page ──────────────────────────────────────── */
.menu-hero {
    text-align: center;
    padding: 3rem 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--dark), var(--dark-lighter));
    color: white;
}
.menu-hero h1 { color: white; font-size: 2rem; margin-bottom: .5rem; }
.menu-hero p { opacity: .8; }

.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.menu-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    border: 1px solid #eef0f2;
}
.menu-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.menu-card img { width: 100%; height: 180px; object-fit: cover; }
.menu-card .menu-card-body { padding: 1rem; }
.menu-card h3 { font-size: 1rem; margin-bottom: .25rem; }
.menu-card .price { color: var(--primary); font-weight: 800; font-size: 1.1rem; }

/* ── Error Pages ──────────────────────────────────────────── */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.error-page .error-code { font-size: 6rem; font-weight: 900; color: var(--primary); line-height: 1; }
.error-page h2 { font-size: 1.75rem; margin: .5rem 0; }
.error-page p { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Print Styles ─────────────────────────────────────────── */
@media print {
    .top-nav, .sidebar, .bottom-nav, .btn, .toolbar, .modal-overlay, .no-print { display: none !important; }
    body { background: white; }
    .main-content { padding: 0; }
    .receipt { border: none; max-width: 100%; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .sidebar { display: none; }
    .main-content { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .top-nav { padding: .6rem 1rem; }
    .mobile-menu-btn { display: flex !important; }
    .nav-links {
        display: none;
        position: fixed;
        top: 55px;
        left: 0; right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid #eef0f2;
        box-shadow: 0 8px 20px rgba(0,0,0,.1);
        z-index: 999;
    }
    .nav-links.active { display: flex; animation: fadeIn .3s ease; }
    .nav-links a { padding: .85rem 1rem; font-size: 1rem; border-radius: var(--radius-sm); }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .toolbar { flex-direction: column; }
    .toolbar .search-box { width: 100%; }
    .toolbar .form-control { width: 100%; min-width: auto; }
    .menu-grid { grid-template-columns: 1fr; }

    .bottom-nav { display: block; }
    .mobile-pad { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)); }

    .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; max-height: 85vh; }
    .container { padding: 1rem; }
    h1 { font-size: 1.35rem; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .auth-card { padding: 1.5rem; }
}

/* ── Billing Cart Styles ──────────────────────────────────── */

/* Cart container and items */
.cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    max-height: calc(100vh - 450px);
}

.cart-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: #fff;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    border: 1px solid #eef0f2;
    transition: all var(--transition);
    animation: fadeIn 0.3s ease;
}

.cart-item-row:hover {
    border-color: var(--primary-light);
    box-shadow: 0 2px 8px rgba(46,204,113,0.08);
}

.ci-details {
    flex: 1;
    min-width: 0;
}

.ci-details strong {
    display: block;
    font-size: 0.9rem;
    color: var(--dark);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ci-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.ci-total {
    font-weight: 800;
    color: var(--primary-dark);
    font-size: 0.95rem;
    min-width: 60px;
    text-align: right;
}

/* Quantity control compact */
.qty-control-compact {
    display: flex;
    align-items: center;
    background: #f8f9fb;
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid #dfe6e9;
}

.btn-qty-sm {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--dark-lighter);
    transition: all var(--transition);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-qty-sm:hover {
    background: var(--primary);
    color: white;
}

.qty-control-compact .qty-val {
    width: 36px;
    text-align: center;
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--dark);
}

/* Remove button */
.btn-remove-sm {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #cbd5e1;
    transition: all var(--transition);
    border-radius: 50%;
    font-size: 0.9rem;
}

.btn-remove-sm:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

/* Empty cart state */
.empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--muted);
    text-align: center;
    height: 100%;
}

.empty-cart i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
    color: var(--primary);
}

.empty-cart p {
    font-size: 0.9rem;
}

/* Cart card specific */
.cart-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid #eef0f2;
}

.cart-card .card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eef0f2;
    flex-shrink: 0;
}

.cart-card .cart-details {
    padding: 1rem 1.25rem;
    border-top: 1px solid #eef0f2;
    flex-shrink: 0;
    background: #fafbfc;
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Card header flex utility */
.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header-flex h3 {
    margin: 0;
}

/* Summary box in cart */
.summary-box {
    background: #fff;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
    border: 1px solid #eef0f2;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.summary-row.total-row {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--primary-dark);
    border-top: 2px solid var(--primary-light);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.summary-grid .form-group {
    margin-bottom: 0;
}

.summary-grid .form-group label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.summary-grid .form-control {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* Cart actions */
.cart-actions {
    margin-top: 1rem;
}

.cart-actions .form-group {
    margin-bottom: 0.75rem;
}

/* Billing layout improvements */
.billing-container {
    display: grid;
    grid-template-columns: 1fr 380px 280px;
    gap: 1.5rem;
    height: calc(100vh - 200px);
    min-height: 500px;
}

.billing-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.billing-section .card,
.billing-section .glass-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Menu section scrollable content */
.menu-categories-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Items grid */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.item-card-mini {
    background: #fff;
    border: 1px solid #eef0f2;
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-card-mini:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transform: translateY(-2px);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 700;
    font-size: 0.9rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-price {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 800;
}

.btn-add-mini {
    background: #f0f7ff;
    color: var(--primary);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.item-card-mini:hover .btn-add-mini {
    background: var(--primary);
    color: #fff;
}

/* Recent bills list */
.recent-bills-list {
    flex: 1;
    overflow-y: auto;
}

.history-item {
    padding: 0.75rem;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.2s;
    border-radius: var(--radius-sm);
}

.history-item:hover {
    background: #f8fafc;
}

.hi-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    align-items: center;
}

.hi-number {
    font-weight: 800;
    color: var(--dark);
    font-size: 0.85rem;
}

.hi-time {
    font-size: 0.75rem;
    color: #999;
}

.hi-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    align-items: center;
}

.hi-customer {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.hi-total {
    font-weight: 800;
    color: var(--primary-dark);
}

.hi-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

.btn-icon-link {
    font-size: 0.9rem;
    color: #64748b;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-icon-link:hover {
    background: #f0f2f5;
    color: var(--primary);
}

.btn-icon-link.text-warning:hover {
    background: rgba(230, 126, 34, 0.1);
    color: var(--secondary);
}

.btn-icon-link.text-info:hover {
    background: rgba(52, 152, 219, 0.1);
    color: var(--info);
}

/* Pulse button animation */
.pulse-btn {
    position: relative;
    overflow: visible;
}

.pulse-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: calc(var(--radius-sm) + 4px);
    border: 2px solid transparent;
    transition: all 0.3s;
}

.pulse-btn:hover::after {
    border-color: var(--primary-light);
    animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.05); opacity: 0; }
}

/* Search box in billing */
.search-box {
    position: relative;
    width: 200px;
}

.search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
}

.search-box input {
    padding: 8px 10px 8px 32px;
    width: 100%;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    transition: all var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,204,113,0.1);
    outline: none;
}

/* Category group */
.category-group {
    margin-bottom: 1.5rem;
}

.category-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-left: 0.25rem;
}

/* Badge primary for item count */
.badge-primary {
    background: rgba(46,204,113,0.12);
    color: var(--primary-dark);
}

/* Print-specific improvements */
@media print {
    .billing-container {
        height: auto;
        display: block;
    }
    
    .billing-section.menu-section,
    .billing-section.history-section {
        display: none !important;
    }
    
    .billing-section.cart-section {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .cart-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .cart-actions .btn-primary {
        display: none;
    }
    
    .cart-actions::after {
        content: 'Thank you for your business!';
        display: block;
        text-align: center;
        padding: 1rem;
        font-style: italic;
        color: #666;
        border-top: 1px dashed #ccc;
        margin-top: 1rem;
    }
}

/* Responsive billing layout */
@media (max-width: 1400px) {
    .billing-container {
        grid-template-columns: 1fr 320px 260px;
    }
}

@media (max-width: 1100px) {
    .billing-container {
        grid-template-columns: 1fr 340px;
    }
    .billing-section.history-section {
        display: none;
    }
}

@media (max-width: 992px) {
    .billing-container {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }
    
    .billing-section {
        max-height: none;
    }
    
    .menu-categories-list {
        max-height: 400px;
    }
    
    .cart-items-container {
        max-height: 300px;
    }
    
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 576px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .item-card-mini {
        padding: 0.6rem;
    }
    
    .cart-item-row {
        padding: 0.6rem;
    }
    
    .ci-actions {
        gap: 0.5rem;
    }
    
    .qty-control-compact .qty-val {
        width: 30px;
        font-size: 0.85rem;
    }
    
    .btn-qty-sm {
        width: 24px;
        height: 24px;
        font-size: 0.85rem;
    }
}
