/* Global Styles */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: #1e293b;
    /* Fallback for no blur support */
    --glass-bg-blur: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --input-bg: rgba(15, 23, 42, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    padding-top: 70px;
    /* Space for fixed navbar */
}

/* Navbar */
.navbar {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-item {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
    padding: 0.5rem;
    border-radius: 6px;
    white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.logout {
    color: #f87171;
}

.nav-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Hamburger Button */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    gap: 5px;
    background: none;
    border: none;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #f8fafc;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Responsive - iPhone 13 (390px wide) and all mobile */
@media (max-width: 768px) {
    .navbar {
        height: auto;
        min-height: 56px;
        padding: 0 1rem;
    }

    .nav-container {
        flex-wrap: wrap;
        padding: 8px 0;
        gap: 0;
    }

    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        padding: 4px 0 8px 0;
        align-items: flex-start;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-item {
        font-size: 0.95rem;
        padding: 0.75rem 0.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        width: 100%;
        border-radius: 0;
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    /* Push notification button on mobile */
    #push-btn {
        font-size: 0.85rem !important;
        padding: 0.75rem 0.5rem !important;
        border: none !important;
        border-bottom: 1px solid rgba(255,255,255,0.05) !important;
        border-radius: 0 !important;
        margin-right: 0 !important;
        width: 100%;
    }

    body {
        padding-top: 56px;
    }
}
/* Layout Containers */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Dashboard Grid System */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* Glass Card */
.card {
    background: var(--glass-bg-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
}

.card-header {
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

/* Stat Cards */
.stat-card {
    text-align: center;
    padding: 2rem 1rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
    line-height: 1;
}

/* Lists & Tables */
.scrollable-list {
    max-height: 350px;
    overflow-y: auto;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.list-item:last-child {
    border-bottom: none;
}

.user-info div:first-child {
    font-weight: 600;
    color: #e2e8f0;
}

.user-info div:last-child {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Forms & Inputs */
input,
select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: white;
    outline: none;
}

input:focus {
    border-color: var(--primary-color);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    width: 100%;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    /* Changed from just opacity to display none for safety */
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1e293b;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

/* User Card (Mobile friendly list item) */
.user-card-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
}

/* Responsive Design */
@media (max-width: 768px) {

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        /* Stack everything on mobile */
    }

    .navbar {
        padding: 0 1rem;
        height: auto;
        min-height: 60px;
    }

    .nav-container {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
        padding-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .nav-item {
        font-size: 0.85rem;
        padding: 0.3rem 0.6rem;
    }

    body {
        padding-top: 100px;
        /* More space for wrapped navbar */
    }

    .stat-value {
        font-size: 2rem;
    }

    .container {
        padding: 1rem;
    }

    /* Fix header and card headers stacking on mobile */
    .card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    /* Ensure chart filter buttons wrap nicely */
    .range-filters {
        flex-wrap: wrap;
        width: 100%;
    }
}

/* Authentication Pages */
.auth-page {
    padding-top: 0 !important;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at 50% 50%, #1e1b4b 0%, #020617 100%);
}

/* Glass Card - Auth Specific */
.auth-page .glass-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
    overflow: hidden;
}

.auth-page .glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
    pointer-events: none;
}

/* Logo */
.auth-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-radius: 20px;
    margin: 0 auto 1.5rem auto;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
    color: white;
}

.auth-logo svg {
    width: 40px;
    height: 40px;
}

/* Typography */
.auth-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.025em;
}

.auth-page .text-muted {
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Form Elements */
.auth-page .form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.auth-page .form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 0.5rem;
    margin-left: 0.25rem;
}

.input-icon-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
    transition: color 0.2s;
}

.auth-input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
}

.auth-input:focus {
    border-color: #6366f1;
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.auth-input:focus+.input-icon,
.input-icon-wrapper:focus-within .input-icon {
    color: #818cf8;
}

/* MFA Input */
.mfa-input {
    width: 100%;
    padding: 1rem;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5em;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-variant-numeric: tabular-nums;
    transition: all 0.2s;
}

.mfa-input:focus {
    border-color: #6366f1;
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

/* Buttons */
.auth-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    filter: brightness(1.1);
}

.auth-btn:active {
    transform: translateY(0);
}

.resend-link {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s;
    padding: 0.5rem;
}

.resend-link:hover {
    color: #6366f1;
    text-decoration: underline;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    text-align: left;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #86efac;
}

/* Timer */
#timer {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    margin: 1rem 0 2rem 0;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.05em;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

#expired-msg {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f87171;
    margin: 1.5rem 0;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.hidden {
    display: none !important;
}