/* ============================================================
   FoodFlow Admin — Custom Theme
   Base: Bootstrap 5.3   Icons: Bootstrap Icons
   Font: Inter (Google Fonts)
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    --sidebar-width:      260px;
    --sidebar-bg:         #1a1d2e;
    --sidebar-hover:      #252840;
    --sidebar-active:     #f97316;
    --sidebar-text:       #a8aec8;
    --sidebar-text-hover: #ffffff;
    --topbar-height:      64px;
    --topbar-bg:          #ffffff;
    --body-bg:            #f4f6fc;
    --card-bg:            #ffffff;
    --card-radius:        12px;
    --card-shadow:        0 2px 16px rgba(0,0,0,.06);
    --accent:             #f97316;
    --accent-hover:       #ea6b05;
    --accent-soft:        #fff4ee;
    --success:            #22c55e;
    --danger:             #ef4444;
    --warning:            #f59e0b;
    --info:               #3b82f6;
    --text-primary:       #1e2235;
    --text-secondary:     #6b7280;
    --border-color:       #e9ecef;
    --transition:         .2s ease;
}

/* ── Reset / Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background:  var(--body-bg);
    color:       var(--text-primary);
    font-size:   .9rem;
    line-height: 1.6;
    overflow-x:  hidden;
}

a { text-decoration: none; color: inherit; }
a:hover { color: var(--accent); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    position:   fixed;
    top:        0;
    left:       0;
    width:      var(--sidebar-width);
    height:     100vh;
    background: var(--sidebar-bg);
    display:    flex;
    flex-direction: column;
    z-index:    1000;
    transition: width var(--transition);
    overflow:   hidden;
}

.sidebar-brand {
    display:         flex;
    align-items:     center;
    gap:             12px;
    padding:         16px 22px;
    border-bottom:   1px solid rgba(255,255,255,.08);
    min-height:      var(--topbar-height);
    overflow:        hidden;
    width:           100%;
    box-sizing:      border-box;
}

.sidebar-brand-logo {
    width:        46px;
    height:       46px;
    border-radius: 50%;
    object-fit:   cover;
    flex-shrink:  0;
    border:       2px solid rgba(255,255,255,.25);
    box-shadow:   0 2px 8px rgba(0,0,0,.35);
}

.sidebar-brand-text {
    overflow:    hidden;
    min-width:   0;
}

.sidebar-brand .brand-icon {
    width:            46px;
    height:           46px;
    background:       var(--accent);
    border-radius:    50%;
    display:          flex;
    align-items:      center;
    justify-content:  center;
    font-size:        1.3rem;
    flex-shrink:      0;
}

.sidebar-brand .brand-name {
    color:          #fff;
    font-weight:    700;
    font-size:      .82rem;
    line-height:    1.25;
    white-space:    normal;
    word-break:     break-word;
    letter-spacing: .01em;
}

.sidebar-brand .brand-sub {
    color:          rgba(255,255,255,.45);
    font-size:      .68rem;
    line-height:    1;
    margin-top:     3px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* Nav section headings */
.sidebar-section {
    padding:     18px 22px 6px;
    font-size:   .68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color:       rgba(168,174,200,.5);
    white-space: nowrap;
}

/* Nav items */
.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

.nav-item {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     10px 22px;
    color:       var(--sidebar-text);
    font-size:   .875rem;
    font-weight: 500;
    cursor:      pointer;
    transition:  all var(--transition);
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.nav-item i { font-size: 1.05rem; flex-shrink: 0; width: 20px; }

.nav-item:hover {
    background:  var(--sidebar-hover);
    color:       var(--sidebar-text-hover);
    border-left-color: rgba(249,115,22,.4);
}

.nav-item.active {
    background:  rgba(249,115,22,.12);
    color:       #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-item .badge-pill {
    margin-left: auto;
    background:  var(--accent);
    color:       #fff;
    font-size:   .65rem;
    font-weight: 700;
    padding:     2px 7px;
    border-radius: 30px;
}

/* Sub-nav (collapsible) */
.nav-submenu { padding-left: 12px; }
.nav-submenu .nav-item { padding-left: 54px; font-size: .84rem; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    position:   fixed;
    top:        0;
    left:       var(--sidebar-width);
    right:      0;
    height:     var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display:    flex;
    align-items: center;
    padding:    0 24px;
    gap:        16px;
    z-index:    999;
    transition: left var(--transition);
}

.topbar-title {
    font-size:   1rem;
    font-weight: 600;
    color:       var(--text-primary);
    flex:        1;
}

.topbar-title small {
    display:    block;
    font-size:  .75rem;
    font-weight: 400;
    color:      var(--text-secondary);
}

/* Order alert bell */
.order-bell {
    position: relative;
    width:    38px;
    height:   38px;
    border:   1px solid var(--border-color);
    border-radius: 10px;
    display:  flex;
    align-items: center;
    justify-content: center;
    cursor:   pointer;
    font-size: 1.1rem;
    color:    var(--text-secondary);
    transition: all var(--transition);
}
.order-bell:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.order-bell .bell-badge {
    position: absolute;
    top: -5px; right: -5px;
    background: var(--danger);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    display: none;
}
.order-bell.has-orders .bell-badge { display: flex; }
.order-bell.has-orders { animation: bellRing .5s ease; }

@keyframes bellRing {
    0%,100% { transform: rotate(0); }
    20%      { transform: rotate(-15deg); }
    40%      { transform: rotate(15deg); }
    60%      { transform: rotate(-10deg); }
    80%      { transform: rotate(10deg); }
}

/* Avatar dropdown */
.avatar-btn {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     6px 12px 6px 6px;
    border:      1px solid var(--border-color);
    border-radius: 30px;
    cursor:      pointer;
    transition:  all var(--transition);
    background:  transparent;
}
.avatar-btn:hover { background: var(--body-bg); border-color: var(--accent); }
.avatar-btn .avatar-circle {
    width:       32px;
    height:      32px;
    border-radius: 50%;
    background:  var(--accent);
    color:       #fff;
    font-weight: 700;
    font-size:   .85rem;
    display:     flex;
    align-items: center;
    justify-content: center;
}
.avatar-btn .avatar-name { font-size: .8rem; font-weight: 600; }
.avatar-btn .avatar-role { font-size: .7rem; color: var(--text-secondary); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top:  var(--topbar-height);
    padding:     28px;
    min-height:  calc(100vh - var(--topbar-height));
    transition:  margin-left var(--transition);
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background:   var(--card-bg);
    border-radius: var(--card-radius);
    border:        1px solid var(--border-color);
    box-shadow:    var(--card-shadow);
}

.card-header {
    padding:       16px 20px;
    border-bottom: 1px solid var(--border-color);
    background:    transparent;
    display:       flex;
    align-items:   center;
    gap:           10px;
}

.card-header .card-title {
    font-size:   .95rem;
    font-weight: 700;
    margin:      0;
    flex:        1;
}

.card-body { padding: 20px; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
    border-radius: var(--card-radius);
    padding:       22px;
    display:       flex;
    align-items:   center;
    gap:           18px;
    border:        1px solid var(--border-color);
    box-shadow:    var(--card-shadow);
    background:    var(--card-bg);
    transition:    transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.09); }

.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-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }
.stat-change { font-size: .75rem; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-accent {
    background:    var(--accent);
    border:        none;
    color:         #fff;
    font-weight:   600;
    border-radius: 8px;
    padding:       8px 18px;
    transition:    background var(--transition), transform var(--transition);
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); }

.btn-outline-accent {
    border:        1.5px solid var(--accent);
    color:         var(--accent);
    background:    transparent;
    font-weight:   600;
    border-radius: 8px;
    padding:       8px 18px;
}
.btn-outline-accent:hover { background: var(--accent); color: #fff; }

/* ── Tables ──────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
    background:    #f8f9fc;
    font-size:     .75rem;
    font-weight:   700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color:         var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding:       12px 16px;
    white-space:   nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; border-color: var(--border-color); }
.table tbody tr:hover { background: #fafbff; }

/* ── Badges ──────────────────────────────────────────────────── */
.status-badge { font-size: .75rem; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.bg-purple { background-color: #7c3aed !important; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .83rem; color: var(--text-primary); }
.form-control, .form-select {
    border-radius: 8px;
    border:        1.5px solid var(--border-color);
    font-size:     .875rem;
    padding:       9px 14px;
    transition:    border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow:   0 0 0 3px rgba(249,115,22,.12);
}
.form-text { font-size: .75rem; }

/* Image upload preview */
.img-upload-wrap {
    border:        2px dashed var(--border-color);
    border-radius: 12px;
    padding:       20px;
    text-align:    center;
    cursor:        pointer;
    transition:    border-color var(--transition), background var(--transition);
}
.img-upload-wrap:hover { border-color: var(--accent); background: var(--accent-soft); }
.img-preview {
    width:         90px;
    height:        90px;
    object-fit:    cover;
    border-radius: 10px;
    border:        2px solid var(--border-color);
}

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap:   wrap;
    gap:         12px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.page-header p  { color: var(--text-secondary); margin: 2px 0 0; font-size: .85rem; }
.breadcrumb { font-size: .8rem; }
.breadcrumb-item.active { color: var(--text-secondary); }

/* ── Order Live Board ────────────────────────────────────────── */
.order-card {
    border-radius: var(--card-radius);
    border:        1px solid var(--border-color);
    background:    var(--card-bg);
    padding:       16px;
    transition:    box-shadow var(--transition);
    position:      relative;
    overflow:      hidden;
}
.order-card::before {
    content:       '';
    position:      absolute;
    left:          0; top: 0; bottom: 0;
    width:         4px;
}
.order-card.pending::before    { background: var(--warning); }
.order-card.confirmed::before  { background: var(--info); }
.order-card.cooking::before    { background: #06b6d4; }
.order-card.ready::before      { background: var(--text-secondary); }
.order-card.on_the_way::before { background: #7c3aed; }

.order-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
    border:        none;
    border-radius: 10px;
    font-size:     .875rem;
    border-left:   4px solid transparent;
}
.alert-success { border-left-color: var(--success); background: #f0fdf4; color: #166534; }
.alert-danger  { border-left-color: var(--danger);  background: #fef2f2; color: #991b1b; }
.alert-warning { border-left-color: var(--warning); background: #fffbeb; color: #92400e; }
.alert-info    { border-left-color: var(--info);    background: #eff6ff; color: #1e40af; }

/* ── Sidebar Collapsed (mobile) ──────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .topbar { left: 0; }
    .main-content { margin-left: 0; }
    .sidebar-overlay {
        display:    none;
        position:   fixed;
        inset:      0;
        background: rgba(0,0,0,.5);
        z-index:    999;
    }
    .sidebar-overlay.show { display: block; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.text-accent { color: var(--accent) !important; }
.bg-accent   { background-color: var(--accent) !important; }
.rounded-10  { border-radius: 10px !important; }
.rounded-12  { border-radius: 12px !important; }

/* Loading spinner overlay */
.page-loader {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.75);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.spinner-accent { color: var(--accent); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f3f5; }
::-webkit-scrollbar-thumb { background: #cdd0d8; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ── Dashboard Welcome ───────────────────────────────────────── */
.dash-welcome {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    flex-wrap:       wrap;
    gap:             12px;
    background:      linear-gradient(135deg, #1a1d2e 0%, #252840 100%);
    border-radius:   16px;
    padding:         24px 28px;
    color:           #fff;
}
.dash-welcome h1 {
    font-size:   1.4rem;
    font-weight: 800;
    margin:      0;
    color:       #fff;
}
.dash-welcome p {
    margin:    4px 0 0;
    font-size: .85rem;
    color:     rgba(255,255,255,.65);
}
.dash-welcome p strong { color: rgba(255,255,255,.9); }
.dash-welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-welcome .btn-accent { background: var(--accent); border: none; }
.dash-welcome .btn-outline-secondary {
    border-color: rgba(255,255,255,.25);
    color: rgba(255,255,255,.85);
    background: rgba(255,255,255,.07);
}
.dash-welcome .btn-outline-secondary:hover {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.4);
    color: #fff;
}

/* ── Dashboard Stat Cards ────────────────────────────────────── */
.dash-stat {
    border-radius: 14px;
    padding:       20px 18px;
    position:      relative;
    overflow:      hidden;
    display:       flex;
    flex-direction: column;
    gap:           4px;
    transition:    transform var(--transition), box-shadow var(--transition);
    min-height:    130px;
}
.dash-stat:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,.12); }

.dash-stat::after {
    content: '';
    position: absolute;
    right: -18px; bottom: -18px;
    width: 90px; height: 90px;
    border-radius: 50%;
    opacity: .12;
    background: #fff;
}

.dash-stat--orange { background: linear-gradient(135deg, #f97316, #fb923c); color: #fff; }
.dash-stat--green  { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; }
.dash-stat--blue   { background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff; }
.dash-stat--purple { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }

.dash-stat-icon {
    font-size:   1.6rem;
    opacity:     .9;
    line-height: 1;
    margin-bottom: 6px;
}
.dash-stat-value {
    font-size:   1.65rem;
    font-weight: 800;
    line-height: 1;
}
.dash-stat-label {
    font-size: .75rem;
    font-weight: 600;
    opacity: .85;
    margin-top: 3px;
}
.dash-stat-sub {
    font-size: .7rem;
    opacity: .7;
    margin-top: 4px;
}
.dash-stat-badge {
    display:      inline-block;
    background:   rgba(255,255,255,.22);
    border-radius: 20px;
    padding:      2px 10px;
    font-size:    .68rem;
    font-weight:  700;
    margin-top:   6px;
    width:        fit-content;
}

/* ── Quick Actions ───────────────────────────────────────────── */
.quick-actions {
    display:               grid;
    grid-template-columns: repeat(6, 1fr);
    gap:                   10px;
}
.quick-action {
    display:         flex;
    flex-direction:  column;
    align-items:     center;
    justify-content: center;
    gap:             6px;
    background:      var(--card-bg);
    border:          1.5px solid var(--border-color);
    border-radius:   12px;
    padding:         14px 10px;
    font-size:       .75rem;
    font-weight:     600;
    color:           var(--text-primary);
    text-align:      center;
    transition:      all var(--transition);
    cursor:          pointer;
}
.quick-action i {
    font-size: 1.25rem;
    color:     var(--accent);
}
.quick-action:hover {
    border-color: var(--accent);
    background:   var(--accent-soft);
    color:        var(--accent);
    transform:    translateY(-2px);
    box-shadow:   0 4px 16px rgba(249,115,22,.15);
}

/* ── Top Items List ──────────────────────────────────────────── */
.top-item-row {
    display:       flex;
    align-items:   center;
    gap:           12px;
    padding:       11px 16px;
    border-bottom: 1px solid var(--border-color);
    transition:    background var(--transition);
}
.top-item-row:hover { background: #fafbff; }

.top-item-rank {
    width:         28px;
    height:        28px;
    border-radius: 8px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-size:     .8rem;
    font-weight:   800;
    flex-shrink:   0;
    background:    var(--body-bg);
    color:         var(--text-secondary);
}
.top-item-rank.rank-gold   { background: #fef9c3; color: #b45309; }
.top-item-rank.rank-silver { background: #f1f5f9; color: #64748b; }
.top-item-rank.rank-bronze { background: #fef2f2; color: #c2410c; }

/* ── Revenue Summary ─────────────────────────────────────────── */
.rev-summary-row {
    display:       flex;
    align-items:   center;
    gap:           14px;
    padding:       13px 16px;
    border-bottom: 1px solid var(--border-color);
}
.rev-summary-icon {
    width:         38px;
    height:        38px;
    border-radius: 10px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    font-size:     1.05rem;
    flex-shrink:   0;
}
.rev-summary-label { font-size: .75rem; color: var(--text-secondary); font-weight: 500; }
.rev-summary-val   { font-size: .95rem; font-weight: 800; }

/* ── Responsive dashboard ────────────────────────────────────── */
@media (max-width: 767.98px) {
    .dash-welcome { padding: 18px 20px; }
    .dash-welcome h1 { font-size: 1.15rem; }
    .dash-stat { min-height: 110px; padding: 16px 14px; }
    .dash-stat-value { font-size: 1.3rem; }
    .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 400px) {
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
}
