/* =====================================================
   VOTER FINDER — style.css  (Library Edition)
   ===================================================== */

/* ---------- Tokens ---------- */
:root {
    --accent: #4f6ef7;
    --accent-light: #7b96ff;
    --accent-dark: #3450d4;
    --green: #22c55e;
    --red: #ef4444;
    --orange: #f97316;
    --yellow: #eab308;
    --bg: #0d0f1a;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.10);
    --text: #f0f2ff;
    --muted: #8891b4;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    --transition: 0.22s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Ambient Orbs ---------- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--accent);
    top: -120px;
    left: -120px;
    animation: drift 12s ease-in-out infinite alternate;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: #7c3aed;
    bottom: -100px;
    right: -100px;
    animation: drift 16s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
    from {
        transform: translate(0, 0)
    }

    to {
        transform: translate(40px, 30px)
    }
}

/* ---------- App Shell ---------- */
.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 0 40px;
}

/* ---------- Header ---------- */
.app-header {
    text-align: center;
    padding: 32px 20px 20px;
}

.header-logo {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-logo span {
    vertical-align: middle;
}

.header-sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ---------- App Body ---------- */
.app-body {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    padding: 0 18px;
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 14px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

/* ---------- Library Panel ---------- */
.lib-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.07);
    padding: 3px 9px;
    border-radius: 99px;
    border: 1px solid var(--border);
}

/* Add PDF Button */
.add-pdf-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent-light);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    position: relative;
}

.add-pdf-btn:hover {
    background: rgba(79, 110, 247, 0.1);
}

.add-pdf-btn input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Library search */
.lib-search-wrap {
    position: relative;
}

.lib-search {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.lib-search::placeholder {
    color: var(--muted);
}

.lib-search:focus {
    border-color: var(--accent);
}

/* Queue Status */
.queue-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--orange);
    font-weight: 600;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.25);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
}

.queue-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--orange);
    animation: blink 1s infinite;
    flex-shrink: 0;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.3
    }
}

/* PDF List */
.pdf-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
    max-height: 420px;
    padding-right: 2px;
}

.pdf-list::-webkit-scrollbar {
    width: 4px;
}

.pdf-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 99px;
}

.empty-lib {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    opacity: 0.6;
    padding: 30px 0;
}

/* PDF Item */
.pdf-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    animation: fadeIn 0.3s ease;
}

.pdf-item:hover {
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.10);
}

.pdf-item.selected {
    border-color: var(--accent);
    background: rgba(79, 110, 247, 0.12);
}

.pdf-item.disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.pdf-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.pdf-item-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
    flex: 1;
    line-height: 1.4;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    flex-shrink: 0;
    transition: color var(--transition);
}

.delete-btn:hover {
    color: var(--red);
}

.pdf-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* Status badges */
.badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    letter-spacing: 0.3px;
}

.badge-done {
    background: rgba(34, 197, 94, 0.15);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-pending {
    background: rgba(234, 179, 8, 0.15);
    color: var(--yellow);
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-ocring {
    background: rgba(249, 115, 22, 0.15);
    color: var(--orange);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.pdf-pages {
    font-size: 10px;
    color: var(--muted);
}

/* Mini progress */
.mini-progress-track {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    margin-top: 6px;
    overflow: hidden;
}

.mini-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--orange), #fbbf24);
    border-radius: 99px;
    transition: width 0.4s ease;
}

.page-counter {
    font-size: 11px;
    font-weight: 700;
    color: var(--orange);
    margin-top: 4px;
    display: block;
    letter-spacing: 0.3px;
}

/* Clear All */
.clear-all-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--red);
    border-radius: var(--radius-sm);
    padding: 9px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: auto;
}

.clear-all-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* ---------- Search Panel ---------- */
.selected-pdf-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    flex-wrap: wrap;
}

.selected-label {
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.selected-name {
    color: var(--accent-light);
    font-weight: 700;
    flex: 1;
    word-break: break-all;
}

.change-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    transition: color var(--transition);
}

.change-btn:hover {
    color: var(--red);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.text-input {
    width: 100%;
    padding: 13px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.text-input::placeholder {
    color: var(--muted);
}

.text-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.18);
}

.search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: 0 4px 20px rgba(79, 110, 247, 0.4);
}

.search-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(79, 110, 247, 0.5);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scope row */
.scope-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.scope-option {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    font-weight: 500;
}

.scope-option input[type="radio"] {
    accent-color: var(--accent);
    width: 15px;
    height: 15px;
}

/* Result box */
.result-box {
    display: none;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

.result-box.visible {
    display: block;
}

.result-box.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--green);
}

.result-box.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
}

.result-box.warning {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: var(--orange);
}

/* Matches */
.matches-wrap {
    display: none;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 340px;
}

.matches-wrap.visible {
    display: flex;
}

.matches-wrap::-webkit-scrollbar {
    width: 4px;
}

.matches-wrap::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 99px;
}

.matches-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.match-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 13px;
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

.match-pdf-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(124, 58, 237, 0.2);
    color: #c4b5fd;
    border: 1px solid rgba(124, 58, 237, 0.3);
    white-space: nowrap;
    flex-shrink: 0;
}

.match-page {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    white-space: nowrap;
    flex-shrink: 0;
}

.occ-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    border: 1px solid var(--border);
    white-space: nowrap;
    flex-shrink: 0;
}

.match-snippet {
    color: var(--muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    line-height: 1.5;
}

.match-snippet mark {
    background: rgba(249, 115, 22, 0.3);
    color: #fbbf24;
    border-radius: 3px;
    padding: 0 2px;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

/* ─────────────────────────────────────────
   RESPONSIVE — Tablet (≤ 900px)
───────────────────────────────────────── */
@media (max-width: 900px) {
    .app-body {
        grid-template-columns: 280px 1fr;
        gap: 14px;
        padding: 0 14px;
    }

    .pdf-list {
        max-height: 320px;
    }
}

/* ─────────────────────────────────────────
   RESPONSIVE — Mobile (≤ 640px)
───────────────────────────────────────── */
@media (max-width: 640px) {

    /* Reduce orbs on mobile for perf */
    .orb-1 {
        width: 260px;
        height: 260px;
    }

    .orb-2 {
        width: 200px;
        height: 200px;
    }

    /* Header */
    .app-header {
        padding: 22px 16px 14px;
    }

    .header-logo {
        font-size: 20px;
    }

    .header-sub {
        font-size: 12px;
    }

    /* Stack panels vertically */
    .app-body {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 12px;
    }

    /* Library panel: compact on mobile */
    .library-panel {
        padding: 14px;
        gap: 10px;
    }

    /* PDF list: shorter height, horizontal scroll hint */
    .pdf-list {
        min-height: 140px;
        max-height: 220px;
    }

    /* Add PDF button: bigger tap target */
    .add-pdf-btn {
        padding: 14px 12px;
        font-size: 14px;
    }

    /* Queue status: smaller */
    .queue-status {
        font-size: 11px;
        padding: 7px 10px;
    }

    /* PDF item: comfortable tap size */
    .pdf-item {
        padding: 12px 12px;
    }

    .pdf-item-name {
        font-size: 13px;
    }

    .delete-btn {
        font-size: 16px;
        padding: 2px 4px;
    }

    /* Clear all: full width */
    .clear-all-btn {
        padding: 11px;
        font-size: 13px;
    }

    /* Search panel */
    .search-panel {
        padding: 14px;
        gap: 12px;
    }

    /* Selected PDF info: wrap nicely */
    .selected-pdf-info {
        padding: 10px 12px;
        font-size: 12px;
    }

    .selected-name {
        font-size: 13px;
    }

    /* Text input: bigger for mobile keyboard */
    .text-input {
        padding: 14px 14px;
        font-size: 16px;
        /* prevents iOS zoom on focus */
    }

    /* Search button: bigger tap target */
    .search-btn {
        padding: 16px;
        font-size: 16px;
    }

    /* Scope row: stack vertically */
    .scope-row {
        gap: 12px;
    }

    .scope-option {
        font-size: 14px;
    }

    .scope-option input[type="radio"] {
        width: 17px;
        height: 17px;
    }

    /* Results: less height, still scrollable */
    .result-box {
        font-size: 14px;
        padding: 12px 14px;
    }

    .matches-wrap {
        max-height: 260px;
    }

    /* Match items: wrapping layout for small screens */
    .match-item {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 12px;
    }

    .match-snippet {
        width: 100%;
        flex: none;
        font-size: 12px;
        white-space: normal;
        /* allow wrapping on mobile */
        overflow: visible;
        text-overflow: unset;
    }

    /* Panel title */
    .panel-title {
        font-size: 14px;
    }
}

/* ─────────────────────────────────────────
   RESPONSIVE — Small phones (≤ 400px)
───────────────────────────────────────── */
@media (max-width: 400px) {
    .app-body {
        padding: 0 8px;
    }

    .header-logo {
        font-size: 18px;
    }

    .search-btn {
        font-size: 15px;
        padding: 14px;
    }

    .pdf-list {
        max-height: 180px;
    }

    .matches-wrap {
        max-height: 220px;
    }
}