@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* === PREMIUM LIGHT THEME (DEFAULT) === */
    --bg-primary: #f1f5f9;     /* Slate 100 - shaded so cards pop beautifully */
    --bg-sidebar: #0f172a;     /* Deep Slate 900 for premium contrast */
    --bg-card: #ffffff;        /* Pure White */
    --bg-topbar: rgba(255, 255, 255, 0.85);
    --border-color: #cbd5e1;   /* Slate 300 - enhanced visual visibility and structure */
    
    --text-primary: #0f172a;   /* Slate 900 */
    --text-secondary: #475569; /* Slate 600 */
    --text-muted: #94a3b8;     /* Slate 400 */
    
    --accent-indigo: #4f46e5;
    --accent-blue: #2563eb;
    --accent-emerald: #10b981;
    --accent-rose: #ef4444;
    --accent-amber: #f59e0b;
    
    --gradient-brand: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    --gradient-emerald: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --gradient-rose: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    --gradient-dark: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-glow: 0 0 15px rgba(79, 70, 229, 0.05);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

/* === OPTIONAL PREMIUM DARK THEME (TRIGGERS INSTANTLY) === */
.dark-mode {
    --bg-primary: #0a0d14;
    --bg-sidebar: #10141f;
    --bg-card: #151a26;
    --bg-topbar: rgba(21, 26, 38, 0.8);
    --border-color: rgba(255, 255, 255, 0.06);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.15);
    
    --gradient-dark: linear-gradient(180deg, #10141f 0%, #0a0d14 100%);
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    background-image: var(--gradient-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Layout Framework */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Left Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 101;
    transition: var(--transition-normal);
}

/* Specific contrast styles when sidebar is dark (Default Light Theme contrast) */
body:not(.dark-mode) .sidebar {
    border-right: none;
}

body:not(.dark-mode) .sidebar .sidebar-logo {
    color: #ffffff;
}

body:not(.dark-mode) .sidebar .sidebar-link {
    color: #94a3b8; /* Light slate text on dark bg */
}

body:not(.dark-mode) .sidebar .sidebar-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

body:not(.dark-mode) .sidebar .sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body:not(.dark-mode) .sidebar .btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
}

body:not(.dark-mode) .sidebar .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

body:not(.dark-mode) .sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: 1.3rem;
    text-decoration: none;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-logo span {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    list-style: none;
}

.sidebar-item {
    margin-bottom: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    transition: var(--transition-fast);
}

.sidebar-link:hover {
    color: var(--text-primary);
    background-color: rgba(0, 0, 0, 0.03);
}

.dark-mode .sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-link.active {
    color: white;
    background: var(--gradient-brand);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.sidebar-link.active svg {
    stroke: white;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content Container */
.main-content {
    flex: 1;
    min-width: 0; /* Critical for flex child responsiveness */
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition-normal);
}

/* Horizontal Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.03);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.dark-mode .user-badge {
    background: rgba(255, 255, 255, 0.03);
}

/* Sleek Theme Switcher Button */
.theme-toggle-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.dark-mode .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.03);
}

.theme-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.06);
}

.dark-mode .theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Impersonation Banner */
.impersonation-banner {
    background: var(--gradient-rose);
    color: white;
    text-align: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 102;
}

.impersonation-banner a {
    color: white;
    text-decoration: underline;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

/* Content Area */
.content-body {
    flex: 1;
    padding: 2rem;
}

/* Premium Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Dashboard Metrics & Layout Grid */
.grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* Responsive Grid for Columns */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
}

/* Sleek Premium Cards */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/* Elevate form card borders slightly in default light theme for legibility */
body:not(.dark-mode) .card {
    border-color: #cbd5e1; /* Shaded slate 300 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.card:hover {
    transform: translateY(-2.5px);
    box-shadow: var(--shadow-md);
    border-color: rgba(79, 70, 229, 0.15);
}

.dark-mode .card:hover {
    box-shadow: var(--shadow-glow);
    border-color: rgba(99, 102, 241, 0.25);
}

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

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

/* Enhance form-control contrast in light mode */
body:not(.dark-mode) .form-control {
    background-color: #f1f5f9; /* Slate 100 - shaded so they are attractive and pop! */
    border: 1px solid #cbd5e1; /* Slate 300 */
}

body:not(.dark-mode) .form-control::placeholder {
    color: #94a3b8;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.dark-mode .form-control:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select {
    appearance: none;
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
}

/* Load distinct SVG dropdown arrow depending on theme mode */
body:not(.dark-mode) .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

.dark-mode .form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

/* Styled Premium Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-normal);
    text-decoration: none;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--gradient-brand);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.dark-mode .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.06);
}

.dark-mode .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
    background: var(--gradient-rose);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Visual Progress Bars (Usage indicators) */
.progress-container {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.dark-mode .progress-bar-bg {
    background: rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.progress-blue { background: var(--accent-blue); }
.progress-emerald { background: var(--accent-emerald); }
.progress-amber { background: var(--accent-amber); }
.progress-rose { background: var(--accent-rose); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-active {
    background: rgba(16, 185, 129, 0.08);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.dark-mode .badge-active {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-suspended {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.dark-mode .badge-suspended {
    background: rgba(244, 63, 94, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(244, 63, 94, 0.2);
}

.badge-terminated {
    background: rgba(107, 114, 128, 0.08);
    color: #374151;
    border: 1px solid rgba(107, 114, 128, 0.15);
}

.dark-mode .badge-terminated {
    background: rgba(107, 114, 128, 0.1);
    color: #d1d5db;
    border: 1px solid rgba(107, 114, 128, 0.2);
}

/* Styled Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    color: #065f46;
    border-color: rgba(16, 185, 129, 0.15);
}

.dark-mode .alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.15);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border-color: rgba(239, 68, 68, 0.15);
}

.dark-mode .alert-danger {
    background: rgba(244, 63, 94, 0.1);
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.15);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

body:not(.dark-mode) .table-responsive {
    border-color: #cbd5e1;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

body:not(.dark-mode) th {
    background-color: #f1f5f9; /* Slate 100 shaded header for structured tables */
    border-bottom: 1px solid #cbd5e1;
    color: #334155; /* Darker bold text */
}

.dark-mode th {
    background-color: rgba(255, 255, 255, 0.01);
}

td {
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

body:not(.dark-mode) td {
    border-bottom: 1px solid #e2e8f0;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: rgba(0, 0, 0, 0.005);
}

.dark-mode tr:hover td {
    background-color: rgba(255, 255, 255, 0.005);
}

/* Pagination container */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

body:not(.dark-mode) .pagination {
    border-top: 1px solid #cbd5e1;
}

.pagination-links {
    display: flex;
    gap: 0.35rem;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

body:not(.dark-mode) .pagination-link {
    border-color: #cbd5e1;
}

.dark-mode .pagination-link {
    background: rgba(255, 255, 255, 0.03);
}

.pagination-link:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
}

.dark-mode .pagination-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.pagination-link.active {
    background: var(--gradient-brand);
    color: white;
    border-color: transparent;
}

/* Hamburger toggle for mobile sidebar responsiveness */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .topbar {
        padding: 0 1rem;
    }
    .content-body {
        padding: 1rem;
    }
}

/* Dropzone styles are scoped within the voter import view component */

/* ==========================================================================
   MODERN RESPONSIVE GRID & SPACING UTILITIES (Bootstrap-Compatible)
   ========================================================================== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.row > [class*="col-"] {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    box-sizing: border-box;
}

/* Base columns (Mobile defaults) */
.col-6 {
    flex: 0 0 auto;
    width: 50%;
}
.col-12 {
    flex: 0 0 auto;
    width: 100%;
}

/* Medium viewports (Tablets, 768px and up) */
@media (min-width: 768px) {
    .col-md-3 {
        flex: 0 0 auto;
        width: 25%;
    }
    .col-md-4 {
        flex: 0 0 auto;
        width: 33.33333333%;
    }
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }
    .col-md-12 {
        flex: 0 0 auto;
        width: 100%;
    }
    .mb-md-0 {
        margin-bottom: 0 !important;
    }
}

/* Large viewports (Desktops, 992px and up) */
@media (min-width: 992px) {
    .col-lg-5 {
        flex: 0 0 auto;
        width: 41.66666667%;
    }
    .col-lg-7 {
        flex: 0 0 auto;
        width: 58.33333333%;
    }
    .col-lg-6 {
        flex: 0 0 auto;
        width: 50%;
    }
    .col-lg-12 {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* Flexbox alignments */
.align-items-center {
    align-items: center !important;
}
.justify-content-between {
    justify-content: space-between !important;
}

/* Spacing utilities (Margins) */
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
