/* =============================================================
   CWTB Admin — Top Navigation Bar
   Matches the main website navbar style for admin pages.
   Mobile: replaces sidebar with hamburger + fullscreen overlay.
   Desktop: top navbar replaces sidebar for consistent UX.
   ============================================================= */

/* ── Top header bar ── */
.admin-top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1100;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.admin-top-nav {
    padding: 1.1rem 0;
}

.admin-nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* ── Logo ── */
.admin-nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.admin-nav-logo-img {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
}

/* ── Desktop inline links (centered) ── */
.admin-nav-links {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.admin-nav-link {
    color: #999;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 6px 13px;
    border-radius: 7px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.admin-nav-link:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

.admin-nav-link.active {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

/* ── Mobile title (hidden on desktop) ── */
.admin-nav-mobile-title {
    display: none;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* ── Right-side actions ── */
.admin-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.admin-nav-user {
    font-size: 0.82rem;
    font-weight: 600;
    color: #888;
}

.admin-nav-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-left: auto;
}

.admin-nav-settings:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.admin-nav-settings.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ── Hamburger toggle (hidden on desktop) ── */
.admin-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.admin-menu-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ── Dropdown (hidden on desktop) ── */
.admin-dropdown-nav {
    display: none;
}

/* ── Hide old sidebar + adjust layout when top nav present ── */
.has-admin-nav .admin-sidebar {
    display: none !important;
}

.has-admin-nav .sidebar-toggle {
    display: none !important;
}

.has-admin-nav .mobile-overlay {
    display: none !important;
}

.has-admin-nav .admin-main {
    margin-left: auto !important;
    margin-right: auto !important;
    padding-top: 70px;
    padding-left: 2rem;
    padding-right: 2rem;
    width: 100% !important;
    max-width: 1200px;
    box-sizing: border-box !important;
}

.has-admin-nav .admin-layout {
    display: block;
}

/* =============================================================
   MOBILE (≤ 768px)
   ============================================================= */
@media (max-width: 768px) {
    /* Show mobile elements, hide desktop elements */
    .admin-nav-links { display: none; }
    .admin-nav-mobile-title { display: block; flex: 1; text-align: center; }
    .admin-menu-toggle { display: flex; }
    .admin-nav-user { display: none; }

    /* Hide logo on mobile, settings cog stays on left (it's now a direct child of container) */
    .admin-nav-logo { display: none; }
    .admin-nav-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    /* Settings cog on the left, absolute positioned like main site's theme-toggle */
    .admin-nav-settings {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        width: 42px; height: 42px;
        min-width: 42px;
        font-size: 1.1rem;
        z-index: 2;
        margin-left: 0;
        order: unset;
    }
    .admin-nav-mobile-title {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        font-size: 1rem;
        pointer-events: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60%;
    }
    .admin-nav-actions {
        margin-left: auto;
        gap: 0.6rem;
    }
    .admin-menu-toggle {
        width: 42px; height: 42px;
        font-size: 1.15rem;
    }

    .has-admin-nav .admin-main {
        margin-left: auto !important;
        margin-right: auto !important;
        padding-top: calc(max(env(safe-area-inset-top, 0px), 0px) + 85px) !important;
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100% !important;
        max-width: 100%;
        box-sizing: border-box !important;
    }

    .admin-top-header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    /* ── Fullscreen mobile menu overlay (matches main site exactly) ── */
    .admin-dropdown-nav {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%;
        height: 100%;
        min-height: 100svh;
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        background: rgba(10, 15, 28, 0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 9999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .admin-dropdown-nav.active {
        opacity: 1;
        visibility: visible;
    }

    /* Close button — plain X like main site */
    .admin-menu-close {
        position: absolute;
        top: 1.5rem;
        right: 1.5rem;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 2rem;
        cursor: pointer;
        padding: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    /* Hide user info section in overlay */
    .admin-dropdown-user-info {
        display: none;
    }

    /* Links — large centered text like main site */
    .admin-dropdown-link {
        display: block;
        padding: 1rem 2rem;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 1.75rem;
        font-weight: 600;
        text-align: center;
        transition: color 0.2s ease;
        background: none;
        border: none;
        width: auto;
        cursor: pointer;
        font-family: inherit;
        -webkit-tap-highlight-color: transparent;
    }

    .admin-dropdown-link:hover {
        background: transparent;
        color: var(--primary-color);
    }

    .admin-dropdown-link:active,
    .admin-dropdown-link.active {
        color: #60a5fa;
    }

    /* Hide icons in dropdown links for clean look */
    .admin-dropdown-link i {
        display: none;
    }

    .admin-dropdown-divider {
        display: none;
    }

    .admin-dropdown-logout {
        color: #ef4444 !important;
        font-size: 1.75rem;
        font-weight: 600;
    }

    .admin-dropdown-logout:active {
        color: #dc2626 !important;
    }
}

/* =============================================================
   ADMIN BACKGROUND
   Subtle dark gradient with mesh pattern for all admin screens.
   ============================================================= */
.admin-body {
    background:
        radial-gradient(ellipse at 10% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 60%),
        #0a0c12 !important;
    background-attachment: fixed !important;
}

/* =============================================================
   SMALL PHONES (≤ 360px)
   ============================================================= */
@media (max-width: 360px) {
    .admin-nav-mobile-title {
        font-size: 0.9rem;
    }
}
