:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #f59e0b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-width: 280px;
    --header-height: 70px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass: blur(12px);
    --font-main: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text);
    overflow-x: hidden;
}

body.login-active {
    background-image: url('Voter-Awareness-2_14..._imresizer.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    height: var(--header-height);
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass);
    border-bottom: 1px solid var(--bg-card-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.lang-selector {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--bg-card-border);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-right: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.lang-selector:focus {
    border-color: var(--primary);
}

.title {
    font-family: var(--font-main);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

.ghost {
    background: transparent;
    border: 1px solid var(--bg-card-border);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 99px;
}

.ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-color: var(--text-muted);
}

.signout-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 99px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.signout-btn:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(239, 68, 68, 0.5);
}

.export-btn {
    background: #10b981;
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 99px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.export-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.5);
}

.download-btn {
    background: #f59e0b;
    color: white !important;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 99px;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.4);
}

.download-btn:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(245, 158, 11, 0.5);
}

/* Status Badge */
.status-badge {
    padding: 0.4rem 1rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Login/Auth */
#landingSection {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    padding: 2rem;
}

#authSection {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 2rem;
    animation: floatUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.auth-card {
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(10px);
    padding: 1.75rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 100%;
    max-width: 340px;
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.auth-card-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.auth-card-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}

.auth-card h2 {
    font-family: var(--font-main);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: white;
    text-align: center;
}

.role-toggle {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    border-radius: 99px;
    display: flex;
    margin: 1.5rem 0;
}

.role-button {
    flex: 1;
    padding: 0.6rem;
    border-radius: 99px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
}

.role-button.active {
    background: var(--bg-card-border);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Form Elements */
input,
select,
textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--bg-card-border);
    padding: 0.8rem 1rem;
    border-radius: 0.75rem;
    color: white;
    margin-top: 0.4rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

/* Dashboard Layout */
body.login-active #dashboard {
    display: none;
}

#dashboard {
    display: block;
    min-height: calc(100vh - var(--header-height));
    position: relative;
    padding-left: 0;
}

.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 1000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--bg-card-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.open {
    transform: translateX(0);
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.sidebar-overlay.visible {
    display: block;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-button {
    text-align: left;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.9rem 1.25rem;
    border-radius: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-button.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    font-weight: 600;
}

/* Main Content Panels */
.panel {
    display: none;
    padding: 2.5rem;
    animation: fadeIn 0.4s ease;
    max-width: 1400px;
    margin: 0 auto;
}

.panel.active {
    display: block;
}


.panel h2 {
    font-family: var(--font-main);
    font-size: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--bg-card-border);
    padding-bottom: 1rem;
}

/* Stat Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.7));
    border: 1px solid var(--bg-card-border);
    padding: 1.5rem;
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card p {
    font-size: 2.5rem;
    font-family: var(--font-main);
    font-weight: 700;
    margin: 0;
    color: white;
    background: linear-gradient(135deg, white 0%, #94a3b8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1.5rem;
}

th {
    background: rgba(15, 23, 42, 0.95);
    /* Opaque for sticky */
    padding: 0.75rem;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--bg-card-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(4px);
}

td {
    padding: 0.75rem;
    background: rgba(30, 41, 59, 0.3);
    border-bottom: 1px solid var(--bg-card-border);
    color: var(--text);
    font-size: 0.9rem;
    white-space: nowrap;
    /* Prevent text wrapping to force scroll */
}

tr:hover td {
    background: rgba(59, 130, 246, 0.05);
}

tr:first-child td:first-child {
    border-top-left-radius: 1rem;
}

tr:first-child td:last-child {
    border-top-right-radius: 1rem;
}

tr:last-child td:first-child {
    border-bottom-left-radius: 1rem;
    border-bottom: none;
}

tr:last-child td:last-child {
    border-bottom-right-radius: 1rem;
    border-bottom: none;
}

/* Address Column specific adjustment */
td:nth-child(10) {
    white-space: normal;
    min-width: 180px;
    max-width: 250px;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--bg-card-border);
    border-radius: 1rem;
    margin-top: 1rem;
}

.table-wrapper table {
    width: max-content;
    /* Force horizontal expansion */
    min-width: 100%;
    margin-top: 0;
}

/* Import/Filters */
.import-panel {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--bg-card-border);
    padding: 1.5rem;
    border-radius: 1rem;
    margin-bottom: 1.5rem;
}

.import-toolbar {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 99px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.file-label:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

.file-label input {
    display: none;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

#editVoterModal,
#editStaffModal {
    z-index: 200;
}

.modal.visible {
    display: flex;
    animation: fadeIn 0.2s;
}

.modal-card {
    background: #0f172a;
    border: 1px solid var(--bg-card-border);
    border-radius: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-card.fullscreen {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.modal-card.fullscreen .analytics-scroll {
    flex: 1;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
}

/* Utilities */
.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.action-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    margin-right: 0.5rem;
}

.action-btn.edit {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.action-btn.delete {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes floatUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
.mobile-menu-btn {
    display: block;
    /* Always show the 3-line button */
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 900px) {
    #dashboard {
        grid-template-columns: 1fr;
        position: relative;
        padding-left: 0;
        /* No static sidebar on mobile */
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1001;
        /* Must be higher than overlay */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: #0f172a;
        padding-top: 5rem;
    }

    .sidebar-overlay {
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-btn {
        display: block;
    }

    .panel {
        padding: 1.5rem 1rem;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Variant Switching */
.login-variant {
    display: none;
}

.login-variant.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    z-index: 10000;
    box-shadow: -10px 10px 30px rgba(0, 0, 0, 0.5);
    border-left: 4px solid var(--primary);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-weight: 600;
    pointer-events: none;
    max-width: 350px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.toast.success {
    border-left: 4px solid #059669;
    background: #ecfdf5;
    /* Very light green background */
    color: #065f46;
    /* Dark green text for readability */
    border: 1px solid #10b981;
    backdrop-filter: blur(12px);
}

.toast.error {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
}

.toast.info {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
}

@media (max-width: 600px) {
    .toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        bottom: auto;
        width: auto;
        max-width: none;
    }
}

/* Search Interface */
.search-container {
    max-width: 550px;
    margin: 0 auto;
}

.search-box {
    position: relative;
    background: rgba(30, 41, 59, 0.4);
    border: 2px solid var(--bg-card-border);
    border-radius: 1.25rem;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.search-box:focus-within {
    border-color: var(--primary);
    background: rgba(30, 41, 59, 0.6);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.search-box i {
    padding: 0 1.25rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none !important;
    padding: 0.8rem 0;
    font-size: 1rem;
    color: white;
    box-shadow: none !important;
}

#searchResults {
    text-align: left;
    margin-top: 2rem;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.result-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    border: 1px solid var(--bg-card-border);
    border-radius: 1.25rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem;
    align-items: center;
}

.result-card:hover {
    border-color: var(--primary);
    transform: translateX(5px);
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
}

.result-info h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: var(--text);
}

.result-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.meta-item {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.meta-item strong {
    color: var(--primary);
    font-weight: 500;
}

.no-results {
    text-align: center;
    padding: 3rem;
    background: rgba(30, 41, 59, 0.2);
    border-radius: 1.5rem;
    border: 2px dashed var(--bg-card-border);
    margin-top: 2rem;
}

.no-results i {
    font-size: 3rem;
    color: var(--danger);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.results-count {
    margin: 1.5rem 0 1rem 0;
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.results-count::before {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--bg-card-border);
}

@media (max-width: 600px) {
    .result-card {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1.25rem;
    }

    .result-card button {
        width: 100%;
    }

    .result-meta {
        grid-template-columns: 1fr;
    }
}

/* Progress Bar Styles */
.import-progress-container {
    margin-top: 1.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 99px;
    height: 12px;
    overflow: hidden;
    border: 1px solid var(--bg-card-border);
    display: none;
    position: relative;
}

.import-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    width: 0%;
    transition: width 0.3s ease;
}

.import-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: none;
}

.import-stats span strong {
    color: #34d399;
}
/* Modal Footer */
.modal-footer {
    padding: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: 1px solid var(--bg-card-border);
}

/* Link Button */
.link-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.link-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
