:root {
    --admin-bg: #f4f7fa;
    --sidebar-bg: #1a1c23;
    --sidebar-hover: #24262d;
    --accent-purple: #8e44ad;
    --accent-pink: #d91656;
    --accent-blue: #3498db;
    --text-dark: #2c3e50;
    --text-light: #95a5a6;
}

.admin-body {
    background: var(--admin-bg);
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.admin-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.admin-logo {
    padding: 0 25px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.2rem;
    font-weight: 700;
}

.admin-logo img { width: 35px; }

.admin-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.admin-nav a {
    padding: 15px 25px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: 0.3s;
    font-size: 0.95rem;
}

.admin-nav a i { width: 20px; text-align: center; }

.admin-nav a:hover, .admin-nav a.active {
    background: var(--sidebar-hover);
    color: white;
    border-left: 4px solid var(--accent-pink);
}

.admin-nav a.active i { color: var(--accent-pink); }

.nav-divider {
    height: 1px;
    background: #333;
    margin: 20px 25px;
}

.badge {
    background: var(--accent-pink);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: auto;
}

/* Main Content */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.admin-header {
    height: 70px;
    background: var(--surface-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-search {
    background: #f1f5f9;
    padding: 8px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 300px;
}

.header-search input {
    background: none;
    border: none;
    font-size: 0.9rem;
    width: 100%;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-avatar {
    width: 35px;
    height: 35px;
    background: var(--accent-purple);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.admin-content {
    padding: 30px;
}

.admin-tab {
    display: none;
    animation: fadeIn 0.4s ease;
}

.admin-tab.active { display: block; }

/* Stats */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-bottom: 30px;
}

.admin-stat-card {
    background: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.stat-main h3 { font-size: 0.9rem; color: #64748b; margin-bottom: 10px; }
.stat-main h2 { font-size: 1.8rem; font-weight: 700; color: var(--text-dark); margin-bottom: 5px; }

.trend { font-size: 0.85rem; font-weight: 600; }
.trend.up { color: #10b981; }

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }
.stat-icon.pink { background: #fff1f2; color: #e11d48; }
.stat-icon.blue { background: #f0f9ff; color: #0284c7; }

/* Charts area */
.admin-charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
}

.chart-container, .recent-sales {
    background: var(--surface-color);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.mock-chart {
    height: 250px;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    padding-top: 30px;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
}

.bar {
    flex: 1;
    background: #e2e8f0;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: 0.3s;
}

.bar:hover { background: #cbd5e1; }
.bar.highlight { background: var(--accent-pink); }

.bar-tooltip {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1c23;
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 100;
}

.bar-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1a1c23;
}

.bar:hover .bar-tooltip {
    opacity: 1;
    top: -45px;
}

.bar span {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #64748b;
}

/* Tables */
.admin-table-container {
    background: var(--surface-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f8fafc;
    text-align: left;
    padding: 15px 25px;
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 18px 25px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    color: #334155;
}

.status-tag {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-tag.received, .status-tag.pending { background: #e0f2fe; color: #0369a1; }
.status-tag.confirmed { background: #f3e8ff; color: #6b21a8; }
.status-tag.preparing, .status-tag.prepared { background: #fef3c7; color: #92400e; }
.status-tag.delivery, .status-tag.out_for_delivery { background: #ffedd5; color: #c2410c; }
.status-tag.ready_for_pickup { background: #ede9fe; color: #5b21b6; }
.status-tag.completed, .status-tag.delivered { background: #dcfce7; color: #166534; }
.status-tag.rejected { background: #fee2e2; color: #991b1b; }

/* Admin Modal Actions */
.admin-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 25px;
}

.admin-modal-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.admin-modal-actions button:only-child {
    grid-column: span 2;
}

.btn-confirm {
    background: #10b981;
    color: white;
}
.btn-confirm:hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}

.btn-reject {
    background: #ef4444;
    color: white;
}
.btn-reject:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239,68,68,0.25);
}

.btn-prepare {
    background: #3b82f6;
    color: white;
}
.btn-prepare:hover {
    background: #2563eb;
    box-shadow: 0 4px 12px rgba(59,130,246,0.25);
}

.btn-ready {
    background: #8b5cf6;
    color: white;
}
.btn-ready:hover {
    background: #7c3aed;
    box-shadow: 0 4px 12px rgba(139,92,246,0.25);
}

.btn-dispatch {
    background: #f59e0b;
    color: white;
}
.btn-dispatch:hover {
    background: #d97706;
    box-shadow: 0 4px 12px rgba(245,158,11,0.25);
}

.action-btn {
    padding: 8px 15px;
    border: 1px solid #e2e8f0;
    background: var(--surface-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    transition: 0.2s;
}

.action-btn:hover { background: #f1f5f9; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Inventory Grid */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.inventory-card {
    background: var(--surface-color);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.inventory-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 12px;
}

/* Modal Styling */
.admin-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--surface-color);
    margin: 5vh auto;
    padding: 30px;
    border-radius: 15px;
    width: 500px;
    max-width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: slideDown 0.4s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close-modal:hover { color: var(--accent-pink); }

.modal-header { margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.modal-item-list { list-style: none; padding: 0; }
.modal-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f9f9f9; }
.modal-item:last-child { border: none; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Admin Responsive Styles ───────────────────────── */

/* Tablet (768px - 1024px) */
@media all and (max-width:1024px) {
    .admin-sidebar {
        width: 220px;
    }
    
    .admin-nav a {
        padding: 14px 20px;
        font-size: 0.9rem;
    }
    
    .admin-logo {
        padding: 0 20px 30px;
        font-size: 1.1rem;
    }
    
    .admin-logo img {
        width: 32px;
    }
    
    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .admin-charts-row {
        grid-template-columns: 1fr;
    }
    
    .header-search {
        width: 200px;
    }
    
    .admin-content {
        padding: 25px;
    }
}

/* Mobile (≤768px) */
@media all and (max-width:768px) {
    .admin-layout {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 300px;
        max-width: 85%;
        height: 100vh;
        position: fixed;
        top: 0;
        left: -100%;
        z-index: 2000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    
    .admin-sidebar.active {
        left: 0;
    }
    
    .admin-logo {
        padding: 20px;
        justify-content: space-between;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .admin-nav {
        padding: 20px 0;
        overflow-y: auto;
        flex: 1;
    }
    
    .nav-section-label {
        padding: 0 20px 10px;
        font-size: 0.75rem;
    }
    
    .admin-main {
        margin-left: 0;
        width: 100%;
    }
    
    .admin-header {
        padding: 0 20px;
        height: 64px;
    }
    
    .header-search {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: #f1f5f9;
        font-size: 20px;
        cursor: pointer;
        color: var(--text-dark);
        transition: all 0.2s;
    }
    
    .mobile-menu-toggle:hover {
        background: #e2e8f0;
    }
    
    .admin-content {
        padding: 20px;
    }
    
    .admin-stats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .admin-stat-card {
        padding: 24px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .stat-main h2 {
        font-size: 1.8rem;
    }
    
    .stat-icon {
        width: 56px;
        height: 56px;
        font-size: 1.4rem;
    }
    
    .admin-charts-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .chart-container, .recent-sales {
        padding: 24px;
    }
    
    .mock-chart {
        height: 200px;
        padding-top: 20px;
    }
    
    .admin-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }
    
    table {
        min-width: 650px;
    }
    
    th {
        padding: 16px 20px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    td {
        padding: 16px 20px;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    .status-tag {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .inventory-card {
        padding: 16px;
        border-radius: 12px;
    }
    
    .inventory-card img {
        height: 140px;
        border-radius: 8px;
    }
    
    .modal-content {
        width: 95%;
        max-width: 500px;
        margin: 20px auto;
        padding: 24px;
        border-radius: 16px;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .admin-modal-actions {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .admin-modal-actions button:only-child {
        grid-column: span 1;
    }
    
    .admin-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 1500;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .admin-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .sidebar-footer {
        padding: 20px;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
    /* 1. Force the layout container to take full width of the screen */
    .admin-layout {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 16px !important; /* Proper padding for mobile edges */
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    /* 2. Force all cards (System Status, Revenue, Orders) to span edge-to-edge */
    .admin-layout > div,
    .metric-card,
    .card,
    [class*="status"],
    [class*="card"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    /* 3. Fix the top header alignment to span fully across the top */
    .admin-layout > header, 
    .top-header,
    header {
        width: 100% !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 0 !important;
        margin: 0 0 20px 0 !important;
    }
}
