/* ============================================================
   VoterApp — Official Pakistan Election Theme & Component UI
   ============================================================ */

:root {
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 68px;
    --header-height: 56px;

    /* Official Pakistan Election Green & Gold Accents */
    --brand: #006633;
    --brand-dark: #004d25;
    --brand-light: #059669;
    --brand-soft: #ecfdf5;
    --brand-border: #a7f3d0;
    --gold: #d97706;
    --gold-soft: #fef3c7;

    --bg: #f3f5f8;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --text: #0f172a;
    --muted: #64748b;

    /* Deep Slate / Navy Sidebar with Election Green glow */
    --sidebar-bg: #0b1320;
    --sidebar-bg-2: #0f1c2e;
    --sidebar-link: #94a3b8;
    --sidebar-active: #006633;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: clip !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Urdu Typography Support */
.font-urdu {
    font-family: "Noto Nastaliq Urdu", "Noto Naskh Arabic", serif;
    line-height: 1.8;
}

a { text-decoration: none; }

/* ---------- Header ---------- */
.app-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    z-index: 1040;
    width: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
}
.app-header .navbar-brand {
    color: var(--text);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}
.brand-logo {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: linear-gradient(135deg, #059669, #004d25);
    color: #fff; font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0, 102, 51, 0.25);
}
.sidebar-toggle { color: var(--muted); border: none; padding: 0.25rem 0.5rem; }
.sidebar-toggle:hover { color: var(--brand); }

.avatar-initials {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff; font-weight: 600; font-size: 0.82rem;
}

/* ---------- Layout ---------- */
.app-body {
    display: block;
    padding-top: var(--header-height);
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow-x: clip !important;
    position: relative;
}

/* Smooth scrollable finance tabs bar */
.finance-nav-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.finance-nav-scroll::-webkit-scrollbar {
    display: none;
}
.finance-nav-scroll .nav-tabs {
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: max-content;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-link);
    position: fixed;
    top: var(--header-height);
    bottom: 0; left: 0;
    overflow-y: auto;
    transition: all 0.2s ease;
    z-index: 1030;
    padding: 0.65rem 0.55rem 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.app-sidebar::-webkit-scrollbar { width: 5px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 6px; }

.sidebar-brand {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.4rem 0.5rem 0.75rem;
    color: #fff; font-weight: 700; font-size: 0.95rem;
}
.sidebar-brand small { display: block; font-weight: 500; font-size: 0.68rem; color: #94a3b8; }

.sidebar-heading {
    text-transform: uppercase;
    font-size: 0.65rem; letter-spacing: 0.08em;
    color: #64748b;
    margin: 0.85rem 0.5rem 0.3rem;
    font-weight: 700;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-link {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.48rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-link);
    font-weight: 500;
    font-size: 0.82rem;
    position: relative;
    transition: all 0.15s;
}
.sidebar-link i { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-link.active {
    background: linear-gradient(90deg, rgba(5, 150, 105, 0.25), rgba(0, 102, 51, 0.15));
    color: #34d399;
    font-weight: 600;
    border-left: 3px solid #10b981;
}

/* Collapsed Sidebar */
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); padding-left: 0.35rem; padding-right: 0.35rem; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar-brand span:not(.brand-logo) { display: none; }
body.sidebar-collapsed .sidebar-heading { display: none; }
body.sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
body.sidebar-collapsed .sidebar-link span { display: none; }
body.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
    max-width: calc(100% - var(--sidebar-collapsed-width));
}

/* ---------- Main Container ---------- */
.app-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    display: flex; flex-direction: column;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left 0.2s ease, width 0.2s ease, max-width 0.2s ease;
    overflow-x: clip !important;
}
.app-main .container-fluid { flex: 1; width: 100%; max-width: 100%; }

/* ---------- Footer ---------- */
.app-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 0.75rem 1.25rem;
    font-size: 0.78rem; color: var(--muted);
    display: flex; justify-content: space-between; align-items: center;
}

/* ---------- Page Header ---------- */
.page-head { margin-bottom: 1rem; }
.page-title { font-weight: 700; font-size: 1.25rem; letter-spacing: -0.01em; margin: 0; color: var(--text); }
.page-subtitle { color: var(--muted); font-size: 0.8rem; margin: 2px 0 0; }

/* ---------- Cards & Matrix Widgets ---------- */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: var(--surface);
}

/* Card Left Accent Borders - Clean, elegant 3.5px line without coloring other borders */
.card-accent-primary, .card.border-start.border-primary, .stat-card.border-start.border-primary {
    border-left: 4px solid var(--brand) !important;
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}
.card-accent-info, .card.border-start.border-info, .stat-card.border-start.border-info {
    border-left: 4px solid #0284c7 !important;
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}
.card-accent-success, .card.border-start.border-success, .stat-card.border-start.border-success {
    border-left: 4px solid #059669 !important;
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}
.card-accent-warning, .card.border-start.border-warning, .stat-card.border-start.border-warning {
    border-left: 4px solid #d97706 !important;
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}
.card-accent-danger, .card.border-start.border-danger, .stat-card.border-start.border-danger {
    border-left: 4px solid #dc2626 !important;
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
}

.stat-card.border-start, .card.border-start {
    border-top: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
    border-left-width: 4px !important;
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* KPI Stat Cards */
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: var(--surface);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon-wrap {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-card .stat-value {
    font-size: clamp(1.2rem, 1.8vw, 1.45rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    word-break: break-word;
}
.stat-card .stat-label {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}
.stat-card .stat-badge { font-size: 0.68rem; font-weight: 600; padding: 0.2rem 0.5rem; border-radius: 999px; }
.stat-card small {
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Matrix Progress Bars */
.matrix-progress {
    height: 6px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

/* ---------- Tables ---------- */
.table-matrix {
    font-size: 0.8rem;
    margin-bottom: 0;
}
.table-matrix > :not(caption) > * > * {
    padding: 0.55rem 0.75rem;
}
.table-matrix thead th {
    background: #f8fafc;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table-matrix tbody tr {
    transition: background 0.1s;
    border-bottom: 1px solid var(--border-light);
}
.table-matrix tbody tr:hover {
    background: #f8fbf9;
}

/* ---------- Custom Badges ---------- */
.badge-election { background: #006633; color: #fff; }
.badge-na { background: #0284c7; color: #fff; }
.badge-pp { background: #059669; color: #fff; }
.badge-gold { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.82rem;
    padding: 0.42rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.btn-primary {
    background: var(--brand); border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { font-size: 0.75rem; padding: 0.28rem 0.55rem; border-radius: 6px; }

/* ---------- Forms ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: 0.42rem 0.65rem;
    font-size: 0.82rem;
    box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(0, 102, 51, 0.12);
}

/* ---------- Custom File Upload Preview Dropzone ---------- */
.file-upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    background: #f8fafc;
    transition: all 0.2s;
    cursor: pointer;
}
.file-upload-dropzone:hover, .file-upload-dropzone.dragover {
    border-color: var(--brand);
    background: var(--brand-soft);
}
.file-preview-card {
    display: none;
    background: #ffffff;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    box-shadow: var(--shadow-xs);
}

/* ---------- Full Screen Election Preloader ---------- */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(11, 19, 32, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
}
.loader-seal {
    width: 68px; height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #059669, #004d25);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
    animation: seal-pulse 1.8s infinite ease-in-out;
}
@keyframes seal-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(16, 185, 129, 0.3); }
    50% { transform: scale(1.08); box-shadow: 0 0 35px rgba(16, 185, 129, 0.6); }
}
.loader-progress-bar {
    width: 280px;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 1rem;
}
.loader-progress-bar .bar {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, #34d399, #10b981);
    border-radius: 999px;
    animation: loader-slide 1.5s infinite linear;
}
@keyframes loader-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* Custom Pagination Component */
.pagination {
    margin-bottom: 0;
    gap: 3px;
}
.page-link {
    border-radius: 6px !important;
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
    color: var(--text);
    border-color: var(--border);
}
.page-item.active .page-link {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

/* ---------- Responsive Off-Canvas Sidebar & Backdrop (< 992px) ---------- */
.sidebar-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 19, 32, 0.65);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1032;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}
body.sidebar-open-mobile {
    overflow: hidden;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        width: 260px;
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 1035;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
    }
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
    .app-main {
        margin-left: 0 !important;
        width: 100%;
    }
    body.sidebar-collapsed .app-sidebar {
        width: 260px;
        transform: translateX(-100%);
    }
    body.sidebar-collapsed .app-sidebar.open {
        transform: translateX(0);
    }
    body.sidebar-collapsed .app-main {
        margin-left: 0 !important;
    }
}

/* Mobile Screens (< 576px) */
@media (max-width: 575.98px) {
    body { font-size: 12px; }
    .page-title { font-size: 1.12rem; }
    .app-main .container-fluid {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }
    .card-header {
        padding: 0.55rem 0.75rem;
    }
    .card-body {
        padding: 0.75rem;
    }
    
    .stat-card {
        padding: 0.6rem !important;
    }
    .stat-card .stat-icon-wrap {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    .stat-card .stat-value {
        font-size: 1.15rem;
    }
    .stat-card .stat-label {
        font-size: 0.65rem;
    }
    
    .table-matrix > :not(caption) > * > * {
        padding: 0.45rem 0.5rem;
        font-size: 0.76rem;
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
   Auth Pages (Login, Password Reset)
   ============================================================ */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(1200px 600px at 50% -10%, #d1fae5 0%, #f1f5f9 60%, #e2e8f0 100%);
    padding: 1.5rem;
    position: relative;
}
.auth-card {
    width: 100%;
    max-width: 430px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(0, 77, 37, 0.12);
    box-shadow: 0 20px 40px -15px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    margin: auto;
}
.auth-head {
    background: linear-gradient(145deg, #059669 0%, #004d25 100%);
    color: #ffffff;
    padding: 2.2rem 2rem 1.75rem;
    text-align: center;
    position: relative;
}
.auth-head .brand-logo {
    width: 54px;
    height: 54px;
    margin: 0 auto 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}
.auth-body {
    padding: 2rem 2.25rem 2.25rem;
    background: #ffffff;
}
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.76rem;
    color: #64748b;
}

/* ============================================================
   Voter Verification Parchi & Branding Styles
   ============================================================ */
.parchi-print {
    margin-top: 2rem;
}
.parchi-slip {
    background: #ffffff;
    border: 2px solid #0f172a;
    border-radius: 8px;
    padding: 1.25rem;
    max-width: 650px;
    margin: 0 auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.ps-header-branding {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    gap: 10px;
}
.ps-branding-left, .ps-branding-right {
    flex: 0 0 85px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ps-logo-img, .ps-candidate-photo {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    border-radius: 6px;
}
.ps-candidate-photo {
    border: 1px solid #cbd5e1;
}
.ps-branding-center {
    flex: 1;
    text-align: center;
}
.ps-party-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: 0.5px;
    line-height: 1.2;
}
.ps-symbol-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 3px 12px;
    border-radius: 12px;
    margin: 4px 0;
    font-size: 0.88rem;
    color: #1e293b;
}
.ps-symbol-inline-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}
.ps-sub-location {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}
.ps-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
}
.ps-cell {
    border-bottom: 1px dashed #cbd5e1;
    padding-bottom: 4px;
}
.ps-cell.ps-full {
    grid-column: span 2;
}
.ps-cell span {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
}
.ps-cell b {
    font-size: 0.95rem;
    color: #0f172a;
}
.ps-cnic {
    font-family: ui-monospace, monospace;
    letter-spacing: 0.5px;
}

@media print {
    body * {
        visibility: hidden;
    }
    .no-print {
        display: none !important;
    }
    .parchi-print, .parchi-print * {
        visibility: visible;
    }
    .parchi-print {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin-top: 0;
    }
    .parchi-slip {
        box-shadow: none;
        border: 2px solid #000;
        width: 100%;
        max-width: 100%;
    }
}

