:root {
    --bg-color: #0c0c0e;
    --card-bg: rgba(255, 255, 255, 0.05);
    --primary: #7c4dff;
    --primary-glow: rgba(124, 77, 255, 0.4);
    --secondary: #00e5ff;
    --text-main: #ffffff;
    --text-dim: #a0a0a0;
    --glass-border: rgba(255, 255, 255, 0.1);
    --menu-bg: rgba(12, 12, 14, 0.95);
    --cyan: #00e5ff;
    --surface: rgba(255, 255, 255, 0.04);
    --surface2: rgba(255, 255, 255, 0.08);
}

body.light-theme {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --primary: #1e3a8a;
    --primary-glow: rgba(30, 58, 138, 0.2);
    --secondary: #0d9488;
    --text-main: #0f172a;
    --text-dim: #52525b;
    --glass-border: rgba(0, 0, 0, 0.08);
    --menu-bg: rgba(255, 255, 255, 0.98);

    /* Compatibility for dashboards (admin, security, etc) */
    --bg: #f8fafc;
    --surface: rgba(0, 0, 0, 0.03);
    --surface2: rgba(0, 0, 0, 0.06);
    --border: rgba(0, 0, 0, 0.08);
    --text: #1e293b;
    --muted: #64748b;
    --accent-color: #1e3a8a;

    /* Brand Colors for Light Theme (Better Contrast) */
    --gold: #b45309;
    --orange: #c2410c;
    --purple: #1e3a8a;
    --cyan: #0369a1;
    --green: #15803d;
    --red: #b91c1c;
    --amber: #d97706;
    --primary: #1e3a8a;
    --purple: #1e3a8a;
}

body.light-theme .glass-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

body.light-theme .menu-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .theme-btn {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .theme-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .stat-card {
    background: #fff;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

body.light-theme h1 {
    background: none;
    -webkit-text-fill-color: initial;
    color: #374151; /* Neutral dark gray for subheadings */
}

body.light-theme .logo-text,
body.light-theme .nav-logo-text {
    color: #1e3a8a !important;
}

body.light-theme .subtitle,
body.light-theme h2,
body.light-theme h3 {
    color: #4b5563 !important;
}

body.light-theme .logo-img {
    filter: invert(15%) sepia(91%) saturate(2251%) hue-rotate(204deg) brightness(97%) contrast(101%);
}

body.light-theme .subtitle {
    color: var(--text-dim) !important;
    opacity: 0.9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

body.dashboard-page {
    align-items: flex-start;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    width: 100%;
    max-width: 450px;
    position: relative;
    z-index: 1;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: var(--primary);
    filter: blur(80px);
    opacity: 0.3;
    z-index: -1;
}

h1,
.page-title-main {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 5px;
    text-align: left;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .page-title-main {
    background: none;
    -webkit-text-fill-color: initial;
    color: #374151;
}

.branding-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 30px;
}

.branding-header h1 {
    margin-bottom: 0;
    line-height: 1;
}

.branding-header p.subtitle {
    margin-bottom: 0;
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.2;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 12px;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
}

/* Fix for browser autofill making inputs white */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--bg-color) inset !important;
    -webkit-text-fill-color: var(--text-main) !important;
    transition: background-color 5000s ease-in-out 0s;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 14px 20px;
    background-color: var(--card-bg) !important;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main) !important;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group select option {
    background-color: #1a1a1e;
    color: #ffffff;
}

body.light-theme .input-group select option {
    background-color: #ffffff;
    color: #0f172a;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--surface2) !important;
    box-shadow: 0 0 15px var(--primary-glow);
}

button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, #a272ff 100%);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px var(--primary-glow);
}

button:active {
    transform: translateY(0);
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

.alert-error {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.alert-success {
    background: rgba(0, 230, 118, 0.1);
    color: #00e676;
    border: 1px solid rgba(0, 230, 118, 0.2);
}

.dashboard-container {
    width: 90%;
    max-width: 1200px;
    margin: 40px auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: relative;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 40px;
    /* Space below the community admin line */
}

.header-branding {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Tight gap as per image */
}

.logo {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    line-height: 1.1;
}

.logo-img {
    height: 25px;
    width: auto;
    object-fit: contain;
}

body:not(.light-theme) .logo-img {
    filter: invert(48%) sepia(79%) saturate(2556%) hue-rotate(186deg) brightness(103%) contrast(107%);
}

.logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    background: none !important;
    -webkit-text-fill-color: initial !important;
    color: #0093ff;
    letter-spacing: -0.5px;
    /* Removed text gradient to let logo image stand out */
}

.tm-symbol {
    font-size: 0.35em;
    vertical-align: super;
    margin-left: 2px;
}

.header-branding .titles {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 32px; /* Aligns with GatedZone text (25px img + 7px gap) */
}

.dot-separator {
    color: var(--text-main);
    opacity: 0.8;
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
}

.header-branding .page-title-main {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0;
    color: var(--text-main);
    background: none;
    -webkit-text-fill-color: initial;
    line-height: 1;
}

.header-branding .subtitle {
    font-size: 0.95rem;
    color: var(--text-dim);
    margin-top: 0;
    line-height: 1;
    font-weight: 400;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card label {
    display: block;
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

th {
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.85rem;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending {
    background: rgba(255, 171, 0, 0.1);
    color: #ffab00;
}

.badge-verified, .badge-paid {
    background: rgba(0, 230, 118, 0.1);
    color: #00e676;
    border: 1px solid rgba(0, 230, 118, 0.2);
}

.badge-approved {
    background: rgba(0, 229, 255, 0.1);
    color: #00e5ff;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.badge-expired, .badge-denied, .badge-unpaid {
    background: rgba(255, 82, 82, 0.1);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.badge-resolved {
    background: rgba(124, 77, 255, 0.1);
    color: #b388ff;
    border: 1px solid rgba(124, 77, 255, 0.2);
}

.badge-closed {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.version-tag {
    font-size: 0.65rem;
    background: rgba(124, 77, 255, 0.12);
    color: #b388ff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    border: 1px solid rgba(124, 77, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    pointer-events: none;
}

body.light-theme .version-tag {
    background: rgba(30, 58, 138, 0.08);
    color: #1e3a8a;
    border-color: rgba(30, 58, 138, 0.15);
}

.logout-btn {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--text-main);
}

/* Google-style Dropdown Menu Styles */
.menu-container {
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 15px;
}

.community-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    gap: 2px;
}

.community-name-display {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--secondary);
    letter-spacing: -0.5px;
    opacity: 1;
    line-height: 1.1;
}

.user-info-display {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 400;
    line-height: 1.2;
}

.hamburger {
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1001;
    position: relative;
    border-radius: 50%;
    transition: background 0.2s;
}

.hamburger:hover {
    background: rgba(255, 255, 255, 0.05);
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.side-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    background: var(--menu-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transform-origin: top right;
}

/* Triangle arrow */
.side-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: var(--menu-bg);
    border-top: 1px solid var(--glass-border);
    border-left: 1px solid var(--glass-border);
    transform: rotate(45deg);
}

.side-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.menu-header {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 8px;
}

.menu-item {
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 10px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--primary);
}

.menu-item.logout-link {
    color: #ff5252;
}

.menu-item.logout-link:hover {
    background: rgba(255, 82, 82, 0.05);
}

.theme-selector {
    margin-top: 10px;
    padding-top: 10px;
}

.theme-selector label {
    display: block;
    color: var(--text-dim);
    font-size: 0.7rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 12px;
}

.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
}

/* Language switcher — wraps to multiple rows when needed */
.lang-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
}

.theme-btn {
    padding: 7px 8px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
    white-space: nowrap;
}

/* Theme buttons (Dark/Light) stretch full row */
.theme-options .theme-btn {
    flex: 1;
}

.theme-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.theme-btn.active {
    border-color: var(--primary);
    background: rgba(124, 77, 255, 0.1);
    color: var(--text-main);
}

.copyright-info {
    margin-top: 15px;
    padding: 10px 12px;
    font-size: 0.85rem;
    color: var(--text-dim);
    border-top: 1px solid var(--glass-border);
    opacity: 0.8;
    line-height: 1.4;
}

/* --- Navigation Tabs (Global Dashboard Standard) --- */
.tabs-header, .dashboard-tabs, .tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    overflow: visible; /* Changed from hidden to show shadows on hover */
    padding-top: 10px; /* Added room for hover translateY and shadows */
    padding-bottom: 15px; /* Increased slightly to accommodate shadow */
    position: relative;
    z-index: 10;
    flex-wrap: nowrap;
    background: transparent !important;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
    flex-shrink: 0;
    width: auto;
    min-width: max-content;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--surface);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.tab-btn.active {
    color: var(--cyan);
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.2);
}

body.light-theme .tab-btn.active {
    background: rgba(0, 139, 163, 0.08);
    border-color: rgba(0, 139, 163, 0.15);
}

.tab-btn.in-dropdown {
    width: 100% !important;
    text-align: left;
    display: flex !important;
    margin-bottom: 8px;
    border: 1px dashed rgba(255,255,255,0.1) !important;
    justify-content: flex-start;
}

/* Inactive App State */
.tab-btn.inactive {
    opacity: 0.6;
    filter: grayscale(0.8);
    cursor: pointer;
    border: 1px dashed rgba(255,255,255,0.2);
    position: relative;
    pointer-events: auto !important;
}

.tab-btn.inactive::after {
    content: '🔒';
    font-size: 0.7rem;
    margin-left: 5px;
}

.overview-card.inactive {
    opacity: 0.7;
    filter: grayscale(0.5);
    position: relative;
    cursor: default;
}

.overview-card.inactive * {
    pointer-events: none;
}

.inactive-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,171,0,0.2);
    color: #ffab00;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
}

.app-lock-overlay {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    z-index: 5;
    border-radius: inherit;
}

.lock-badge {
    background: #000;
    color: var(--amber, #ffab00);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--amber, #ffab00);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 600px) {
    /* Layout Adjustments */
    .dashboard-container {
        width: 95%;
        margin: 20px auto;
        gap: 20px;
    }

    .glass-card {
        padding: 24px 20px;
        border-radius: 16px;
    }

    /* Headings & Typography */
    h1, .page-title-main {
        font-size: 1.6rem;
    }

    .logo {
        font-size: 1.4rem;
    }

    .header-branding .page-title-main {
        font-size: 0.9rem;
    }

    .header-branding .subtitle {
        font-size: 0.8rem;
    }

    /* Form Elements */
    .input-group label {
        margin-bottom: 8px;
    }

    .input-group input, .input-group select {
        padding: 12px 16px;
    }

    /* Refined Mobile Header Alignment */
    .dashboard-header {
        display: grid !important;
        grid-template-areas: 
            "logo hamburger"
            "info info" !important;
        grid-template-columns: 1fr auto;
        gap: 10px;
        align-items: center;
        margin-bottom: 25px;
        padding: 0 5px;
    }

    .header-branding { 
        grid-area: logo; 
        display: flex;
        justify-content: flex-start; /* Force left align */
        text-align: left;
    }
    .logo { 
        margin: 0 !important; 
        text-align: left !important;
    }
    
    .menu-container { display: contents; }
    
    .hamburger { 
        grid-area: hamburger; 
        margin-left: auto;
    }

    .community-info {
        grid-area: info;
        text-align: right !important; /* Move text to the right under the menu */
        align-items: flex-end !important;
        padding-top: 8px;
        border-top: 1px solid rgba(255,255,255,0.08);
    }

    .community-name-display {
        font-size: 1rem;
        color: var(--secondary);
    }

    .user-info-display {
        font-size: 0.72rem;
    }

    /* Tabs: Refined Horizontal Scroll */
    .dashboard-tabs, .tab-bar, .tabs {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        padding: 10px 0 15px !important;
        gap: 10px !important;
        margin-top: 10px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .dashboard-tabs::-webkit-scrollbar, .tab-bar::-webkit-scrollbar { display: none; }

    .tab-btn {
        flex: 0 0 auto !important; /* Ensure buttons only take needed space */
        width: auto !important;
        min-width: 100px;
        padding: 10px 16px !important;
        border-radius: 30px !important;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card {
        padding: 18px;
    }

    .stat-card .value {
        font-size: 1.6rem;
    }

    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    th, td {
        padding: 12px 10px;
        font-size: 0.85rem;
    }

    /* Side Menu Adjustment */
    .side-menu {
        width: 80%;
        max-width: 300px;
    }
}

@media (max-width: 400px) {
    .glass-card {
        padding: 20px 16px;
    }

    h1, .page-title-main {
        font-size: 1.4rem;
    }
    
    .logo {
        font-size: 1.2rem;
    }
}

/* Modal Overlay & General Card Components */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.f-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.f-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border-color: var(--primary) !important;
}

.badge {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Background Verification Chips */
.check-chip {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    margin-bottom: 4px;
}

.check-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.check-chip input {
    display: none;
}

.check-chip span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.check-chip:has(input:checked) {
    background: rgba(124, 77, 255, 0.15);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 15px rgba(124, 77, 255, 0.15);
}

.check-chip:has(input:checked) span::before {
    content: '✓';
    font-weight: 800;
    color: var(--secondary);
}

body.light-theme .check-chip {
    background: rgba(0, 0, 0, 0.04);
}

body.light-theme .check-chip:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.light-theme .check-chip:has(input:checked) {
    background: rgba(98, 0, 234, 0.1);
    color: var(--primary);
}
