/* ==========================================================================
   1. DESIGN SYSTEM VARIABLES & CORE RESET
   ========================================================================== */
:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-muted: #475569;
    --color-brand: #021530;
    --color-accent: #b45309;
    --color-success: #15803d;
    --border-light: #e2e8f0;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
}

/* ==========================================================================
   2. FIXED RESPONSIVE NAVBAR ARCHITECTURE
   ========================================================================== */
.main-nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    padding: 0.75rem 0;
    position: -webkit-sticky; /* Legacy Safari */
    position: sticky;
    top: 0;
    z-index: 1000; /* Stays reliably pinned over all content cards */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.nav-container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    gap: 1rem;
}

.logo-text { 
    font-weight: 700; 
    font-size: 0.95rem; 
    letter-spacing: -0.025em; 
    color: var(--color-brand);
    white-space: nowrap;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Profile Badge - Converts into a minimal user icon on mobile viewports */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-main);
    padding: 0.5rem 0.65rem;
    border-radius: 30px;
    border: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Hide email characters on tight mobile views to prevent navigation breaks */
#user-email-display {
    display: none; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* Dynamically inject generic user profile symbol asset on small viewports */
.user-profile-badge::before {
    content: "\f007"; /* FontAwesome Glyph string mapping */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-profile-badge button {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    padding: 0;
    font-size: 0.85rem;
}

.nav-lang-btn {
    padding: 0.5rem 0.65rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap;
    height: 34px; /* Fixes layout vertical jump alignment issues */
}

/* Responsive Navbar Breaks for Tablets/Desktops */
@media (min-width: 540px) {
    .logo-text { font-size: 1.1rem; }
    .nav-actions { gap: 0.75rem; }
    
    /* Safely render text email address once physical space opens up */
    #user-email-display {
        display: inline-block;
        max-width: 140px;
    }
    /* Terminate mobile icon fallback rule layout */
    .user-profile-badge::before {
        display: none;
    }
    .user-profile-badge {
        padding: 0.4rem 0.75rem;
    }
    .nav-lang-btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
    }
}

@media (min-width: 768px) {
    #user-email-display {
        max-width: 260px; /* Allocates full layout footprint to verify strings */
    }
}

/* ==========================================================================
   3. LANGUAGE INITIALIZATION OVERLAY
   ========================================================================== */
.lang-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.lang-box {
    background: var(--bg-card);
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.lang-box h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--color-brand); }
.lang-box p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.9rem; }
.lang-btn-group { display: flex; gap: 1rem; justify-content: center; }

/* ==========================================================================
   4. HERO PROFILE & DIGITAL MANIFESTO STREAM
   ========================================================================== */
.hero-section {
    padding: 2.5rem 0;
    background: radial-gradient(100% 100% at 50% 0%, rgba(2, 21, 48, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}
.hero-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}
@media (min-width: 768px) {
    .hero-section { padding: 4rem 0; }
    .hero-container { grid-template-columns: 320px 1fr; gap: 3rem; }
}

.candidate-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    height: max-content;
}
.candidate-img-placeholder {
    width: 120px;
    height: 120px;
    background: #f1f5f9;
    border-radius: 50%;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}
.candidate-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.25rem; }
.subtitle { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 1.25rem; }
.candidate-card h3 { font-size: 1.4rem; font-weight: 700; color: var(--color-brand); }
.tagline { font-size: 0.9rem; font-style: italic; color: var(--color-accent); margin: 0.75rem 0 1.25rem; line-height: 1.4; }
.election-date { font-size: 0.8rem; font-weight: 600; padding: 0.5rem 0.75rem; background: #fffbeb; color: #b45309; border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: 0.5rem; }

.promises-container h2 { font-size: 1.35rem; font-weight: 700; margin-bottom: 1.5rem; letter-spacing: -0.02em; }
@media (min-width: 768px) { .promises-container h2 { font-size: 1.5rem; } }

.promise-list { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 1024px) { .promise-list { grid-template-columns: 1fr 1fr; } }

.promise-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    transition: var(--transition-smooth);
}
.promise-item:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.04); }
.promise-item i { font-size: 1.15rem; color: var(--color-brand); margin-top: 0.2rem; }
.promise-item h4 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.promise-item p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }

/* ==========================================================================
   5. ADAPTIVE LIVE COMMUNITY POLL CARDS (PERCENTAGE DISPLAY FIX)
   ========================================================================== */
.polls-section { padding: 3rem 0; border-top: 1px solid var(--border-light); }
.section-title { text-align: center; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; padding: 0 0.5rem; }
.section-subtitle { text-align: center; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 2rem; padding: 0 1rem; }
@media (min-width: 768px) {
    .polls-section { padding: 4rem 0; }
    .section-title { font-size: 1.75rem; }
    .section-subtitle { font-size: 0.9rem; margin-bottom: 3rem; }
}

.polls-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 1.5rem; 
}
@media (min-width: 640px) { .polls-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .polls-grid { grid-template-columns: repeat(3, 1fr); } }

.poll-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    transition: var(--transition-smooth);
    height: auto; 
}
.poll-card h3 { 
    font-size: 1.05rem; 
    font-weight: 600; 
    margin-bottom: 1.25rem; 
    color: var(--color-brand); 
    line-height: 1.4;
    word-break: break-word; 
}
.poll-options { 
    display: flex; 
    flex-direction: column; 
    gap: 0.85rem; 
    margin-top: auto; 
}

/* Stack label and percentage line vertically to prevent overlap text clips */
.poll-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column; 
    align-items: stretch;
    gap: 0.35rem;
}
.poll-btn-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 0.88rem;
    font-weight: 500;
    color: inherit;
}
.poll-btn:hover:not(:disabled) {
    background: var(--color-brand);
    color: white;
    border-color: var(--color-brand);
}

.percentage-track-container {
    width: 100%;
    background: #e2e8f0;
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
    margin-top: 0.15rem;
}
.percentage-track-fill {
    height: 100%;
    background: var(--color-brand);
    border-radius: 4px;
    transition: width 0.5s ease-out;
}
.poll-btn:hover .percentage-track-fill { background: white; }
.poll-card.voted-card .percentage-track-fill { background: var(--color-success); }

/* ==========================================================================
   6. UI BUTTONS, GENERAL ACTION MATRICES & ADMIN MODALS
   ========================================================================== */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-excel, .btn-lang {
    padding: 0.625rem 1rem; font-size: 0.85rem; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: var(--transition-smooth); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary { background: var(--color-brand); color: white; }
.btn-secondary { background: transparent; border-color: var(--border-light); color: var(--text-muted); }
.btn-secondary:hover { background: var(--bg-main); color: var(--text-primary); }
.btn-success { background: var(--color-success); color: white; width: 100%; margin-top: 1rem; }
.btn-danger { background: #ef4444; color: white; }
.btn-excel { background: #166534; color: white; }

.modal { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); z-index: 2000; overflow-y: auto; padding: 1rem; }
.modal-content { background: var(--bg-card); margin: 1.5rem auto; width: 100%; max-width: 750px; border-radius: var(--radius-lg); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1); overflow: hidden; border: 1px solid var(--border-light); }
@media (min-width: 768px) { .modal-content { margin: 4rem auto; } }

.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; }
.close-modal { font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

.crud-box { background: var(--bg-main); padding: 1.25rem; border-radius: var(--radius-lg); border: 1px solid var(--border-light); margin-bottom: 1.5rem; }
.crud-box h4 { margin-bottom: 1rem; font-size: 0.95rem; font-weight: 600; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-group label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 580px) { .form-row { grid-template-columns: 1fr 1fr; gap: 1rem; } }
input[type="text"] { padding: 0.625rem 0.875rem; border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-size: 0.9rem; background: var(--bg-card); width: 100%; }
input[type="text"]:focus { outline: none; border-color: var(--color-brand); }

/* Tabular Records Matrix Layout */
.table-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td { padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--border-light); text-align: left; vertical-align: middle; }
.admin-table th { background: #f1f5f9; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* ==========================================================================
   7. SECURE ACCOUNT ROUTING SECURITY GATE
   ========================================================================== */
.login-gate-container {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    padding: 1rem;
}
.login-gate-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
@media (min-width: 480px) { .login-gate-card { padding: 3rem 2.5rem; } }

.login-gate-card .logo-mark {
    width: 60px;
    height: 60px;
    background: #021530;
    color: white;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem auto;
    font-size: 1.35rem;
    font-weight: 800;
}
.login-gate-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--color-brand); margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.login-gate-card p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.75rem; line-height: 1.4; }

.btn-login-wide {
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: #021530;
    color: white;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}
.btn-login-wide:hover { background: #0f172a; transform: translateY(-1px); }

/* ==========================================================================
   8. MINIMALIST FOOTER & MISC UTILITIES
   ========================================================================== */
.social-section { background: var(--bg-card); border-top: 1px solid var(--border-light); padding: 2.5rem 0; text-align: center; }
.footer-grid { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1.25rem; margin-bottom: 1.5rem; }
.social-links a { color: var(--text-muted); font-size: 1.25rem; margin: 0 0.5rem; transition: var(--transition-smooth); }
.social-links a:hover { color: var(--color-brand); }
.admin-login-bar { border-top: 1px solid var(--border-light); padding-top: 1.25rem; }
.hidden { display: none !important; }