@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Poppins:wght@500;600;700&display=swap');

:root {
    --admin-bg: #103140;
    --admin-sidebar: #133040;
    --admin-card: rgba(19, 48, 64, 0.7);
    --admin-text: #ffffff;
    --admin-muted: #b8c3c5;
    --admin-accent: #b8b6aa;
    --admin-accent-dark: #97958b;
    --admin-border: rgba(255, 255, 255, 0.08);
    --admin-radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--admin-bg);
    color: var(--admin-text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: 260px;
    background-color: var(--admin-sidebar);
    border-right: 1px solid var(--admin-border);
    padding: 36px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
}

.sidebar h2 {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 44px;
    text-align: center;
    font-size: 1.45rem;
    letter-spacing: 0.02em;
}
.sidebar h2 span { color: var(--admin-accent); }

.sidebar a {
    color: var(--admin-muted);
    text-decoration: none;
    padding: 13px 18px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 3px solid transparent;
}

.sidebar a:hover, .sidebar a.active {
    background: rgba(184, 182, 170, 0.1);
    color: var(--admin-accent);
    border-left: 3px solid var(--admin-accent);
    padding-left: 22px;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 44px;
    width: calc(100% - 260px);
    transition: all 0.3s ease;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 44px;
    border-bottom: 1px solid var(--admin-border);
    padding-bottom: 20px;
}

.dashboard-header h1 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 2rem;
    letter-spacing: -0.02em;
}

/* =============================================
   DASHBOARD STAT CARDS
   ============================================= */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 44px;
}

.stat-card {
    background: var(--admin-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--admin-border);
    padding: 28px;
    border-radius: var(--admin-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(16,49,64,0.15);
}

.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(16,49,64,0.3);
    border-color: rgba(184, 182, 170, 0.3);
}

.stat-card-info {
    display: flex;
    flex-direction: column;
}

.stat-card-info h3 {
    font-size: 2.3rem;
    color: #ffffff;
    margin-bottom: 4px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    line-height: 1.1;
}

.stat-card-info p {
    color: var(--admin-muted);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin: 0;
}

.stat-card-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(184, 182, 170, 0.12);
    color: var(--admin-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover .stat-card-icon {
    background: var(--admin-accent);
    color: var(--admin-bg);
    transform: rotate(8deg) scale(1.08);
}

/* =============================================
   FORMS, CARDS & TABLES
   ============================================= */
.admin-card {
    background: var(--admin-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--admin-border);
    padding: 36px;
    border-radius: var(--admin-radius);
    margin-bottom: 36px;
    box-shadow: 0 8px 24px rgba(16,49,64,0.15);
}

.admin-card h3 {
    margin-bottom: 24px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.35rem;
    color: #ffffff;
    border-left: 3px solid var(--admin-accent);
    padding-left: 12px;
}

.admin-form input, .admin-form textarea, .admin-form select {
    width: 100%;
    padding: 13px 18px;
    background: rgba(16, 49, 64, 0.45);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    color: #ffffff;
    margin-bottom: 24px;
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    transition: all 0.25s ease;
}

.admin-form input:focus, .admin-form textarea:focus, .admin-form select:focus {
    outline: none;
    border-color: var(--admin-accent);
    background: rgba(16, 49, 64, 0.7);
    box-shadow: 0 0 0 3px rgba(184, 182, 170, 0.15);
}

.admin-form select option {
    background: var(--admin-sidebar);
    color: #ffffff;
}

.admin-form label {
    display: block;
    margin-bottom: 10px;
    color: var(--admin-muted);
    font-size: 0.88rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    background: var(--admin-accent);
    color: var(--admin-bg);
    border: none;
    padding: 13px 26px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(184, 182, 170, 0.15);
}

.btn:hover {
    background: var(--admin-accent-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(184, 182, 170, 0.3);
}

.btn-danger {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
}

/* =============================================
   TABLES
   ============================================= */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th, .admin-table td {
    padding: 18px 16px;
    text-align: left;
    border-bottom: 1px solid var(--admin-border);
}

.admin-table th {
    color: var(--admin-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    background: rgba(255, 255, 255, 0.02);
}

.admin-table td {
    color: #f8fafc;
    font-size: 0.92rem;
}

.admin-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* =============================================
   ALERTS & NOTIFICATION
   ============================================= */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    font-weight: 500;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

/* =============================================
   RESPONSIVENESS
   ============================================= */
@media(max-width: 991px) {
    .sidebar { width: 80px; padding: 36px 10px; }
    .sidebar h2 { display: none; }
    .sidebar a span { display: none; }
    .sidebar a { justify-content: center; padding: 16px; }
    .main-content { margin-left: 80px; width: calc(100% - 80px); padding: 30px; }
}

@media(max-width: 768px) {
    body { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--admin-border);
    }
    .sidebar h2 { display: none; }
    .main-content { margin-left: 0; width: 100%; padding: 24px; }
}

/* =============================================
   MOBILE HAMBURGER TOGGLE & SLIDE-IN DRAWER
   (new rules only — existing rules above unchanged)
   ============================================= */

/* Hamburger button — hidden on desktop, shown on mobile */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 201;
    width: 42px;
    height: 42px;
    background: var(--admin-sidebar);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--admin-accent);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Animated X when sidebar is open */
.sidebar.active ~ * .sidebar-toggle span:nth-child(1),
#adminSidebar.active ~ script + * #adminSidebarToggle span:nth-child(1) { transform: none; }

/* Overlay — hidden by default */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile: sidebar hidden off-screen, slides in on .active */
@media (max-width: 768px) {
    body { flex-direction: column; }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 260px !important;
        height: 100vh !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        padding: 36px 20px !important;
        border-right: 1px solid var(--admin-border) !important;
        border-bottom: none !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 200;
        overflow-y: auto;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Restore link and heading visibility inside open drawer */
    .sidebar h2 {
        display: block !important;
        margin-top: 40px;
    }

    .sidebar a {
        justify-content: flex-start !important;
        padding: 13px 18px !important;
    }

    .sidebar a span {
        display: inline !important;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 24px;
        padding-top: 72px; /* prevent content hiding behind toggle button */
    }
}

/* Tablet icon-strip (991px) — hamburger not needed, sidebar always visible */
@media (min-width: 769px) and (max-width: 991px) {
    .sidebar-toggle { display: none; }
}

/* =============================================
   ADMIN TOPBAR  (username + logout bar)
   ============================================= */
.admin-topbar {
    position: fixed;
    top: 0;
    left: 260px;           /* aligns with sidebar width on desktop */
    right: 0;
    height: 56px;
    background-color: var(--admin-sidebar);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px 0 16px;
    z-index: 99;
    transition: left 0.3s ease;
}

/* Left spacer — reserved for the hamburger button area on mobile */
.admin-topbar-spacer {
    display: block;
    width: 42px;    /* matches hamburger button width */
}

/* Right cluster: user icon + name + logout */
.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.admin-topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--admin-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
}

.admin-topbar-user i {
    font-size: 1.1rem;
    color: var(--admin-accent);
}

.admin-topbar-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.admin-topbar-logout:hover {
    background: rgba(239, 68, 68, 0.22);
    color: #ff8080;
    border-color: rgba(239, 68, 68, 0.45);
}

/* Push main-content down so topbar never overlaps page content */
.main-content {
    padding-top: calc(44px + 56px); /* original padding-top (implicit 0) + topbar height */
}

/* ── Desktop: topbar left edge aligns with sidebar ── */
@media (min-width: 992px) {
    .admin-topbar {
        left: 260px;
    }
    .main-content {
        padding-top: 56px;      /* topbar height; horizontal padding unchanged */
    }
}

/* ── Tablet icon-strip (769–991px): sidebar is 80px wide ── */
@media (min-width: 769px) and (max-width: 991px) {
    .admin-topbar {
        left: 80px;
    }
    .main-content {
        padding-top: 56px;
    }
}

/* ── Mobile (≤768px): topbar spans full width, spacer shows hamburger gap ── */
@media (max-width: 768px) {
    .admin-topbar {
        left: 0;
        padding-left: 62px;   /* leaves room for the fixed hamburger button */
    }
    .admin-topbar-spacer {
        display: none;        /* not needed; padding handles the gap */
    }
    .main-content {
        padding-top: 80px;    /* topbar 56px + extra breathing room */
    }
}
