/* ═══════════════════════════════════════════════════════════════════
   JobBlitz Dashboard — Stylesheet
   Professional dark theme with clean typography and subtle depth
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg-base: #0c0e14;
    --bg-surface: #13151e;
    --bg-elevated: #1a1d2b;
    --bg-hover: #212537;
    --border: #262a3a;
    --border-light: #2f3447;

    --text-primary: #e8eaf0;
    --text-secondary: #9ca3b4;
    --text-muted: #5d6478;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);

    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.12);
    --blue: #3b82f6;
    --blue-soft: rgba(59, 130, 246, 0.12);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.12);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, 0.12);
    --cyan: #06b6d4;
    --cyan-soft: rgba(6, 182, 212, 0.12);

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.15);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Top Navigation ─────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logo-icon {
    font-size: 1.4rem;
    filter: saturate(1.5);
}

.topbar-stats {
    display: flex;
    gap: 8px;
}

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    min-width: 80px;
}

.stat-pill .stat-num {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-pill .stat-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-applied .stat-num { color: var(--green); }
.stat-interview .stat-num { color: var(--blue); }
.stat-visa .stat-num { color: var(--cyan); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.runtime-banner {
    padding: 10px 24px;
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.14), rgba(59, 130, 246, 0.08));
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.btn-scan {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-scan:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-scan:active { transform: translateY(0); }

.btn-scan.scanning {
    opacity: 0.7;
    pointer-events: none;
}

.btn-scan.scanning .scan-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.scan-icon {
    font-size: 1.1rem;
    display: inline-block;
}

/* ── Layout ─────────────────────────────────────────────────────── */

.layout {
    display: grid;
    grid-template-columns: minmax(320px, 360px) 1fr;
    min-height: calc(100vh - 60px);
}

/* ── Sidebar ────────────────────────────────────────────────────── */

.sidebar {
    padding: 22px 18px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.sidebar-section {
    margin-bottom: 22px;
}

.sidebar-section h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.filter-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: border var(--transition);
}

.filter-textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 92px;
    transition: border var(--transition);
}

.filter-input:focus,
.filter-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.profile-input {
    margin-bottom: 8px;
}

.profile-helper {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 10px;
}

.profile-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin: 10px 0 6px;
    letter-spacing: 0.3px;
}

.profile-summary {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
    line-height: 1.45;
}

.profile-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr;
    margin: 12px 0 10px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.profile-advanced {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.profile-advanced summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.profile-advanced[open] summary {
    margin-bottom: 12px;
}

@media (min-width: 1100px) {
    .profile-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition);
}

.filter-check:hover { background: var(--bg-hover); }

.filter-check input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
}

.filter-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.filter-select:focus { border-color: var(--accent); }

.range-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-wrap input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
}

.range-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 32px;
}

.scan-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Badges ─────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-new { background: var(--blue-soft); color: var(--blue); }
.badge-applied { background: var(--green-soft); color: var(--green); }
.badge-interview { background: var(--amber-soft); color: var(--amber); }
.badge-rejected { background: var(--red-soft); color: var(--red); }
.badge-offer { background: linear-gradient(135deg, var(--green-soft), var(--cyan-soft)); color: var(--green); }
.badge-visa { background: var(--cyan-soft); color: var(--cyan); }
.badge-cv-ready { background: var(--blue-soft); color: var(--blue); }
.badge-remote { background: var(--accent-glow); color: var(--accent-hover); }

/* ── Main Content ───────────────────────────────────────────────── */

.main-content {
    padding: 20px 24px;
    overflow-y: auto;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.results-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 2px;
    border: 1px solid var(--border);
}

.view-btn {
    padding: 4px 10px;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
}

.view-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ── Job Cards ──────────────────────────────────────────────────── */

.jobs-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.jobs-container.list-view {
    grid-template-columns: 1fr;
}

.job-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.job-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
    opacity: 0;
    transition: opacity var(--transition);
}

.job-card:hover {
    border-color: var(--border-light);
    background: var(--bg-elevated);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.job-card:hover::before { opacity: 1; }

.job-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 12px;
}

.job-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    flex: 1;
}

.job-card-score {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 2px solid;
}

.score-high { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.score-mid { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.score-low { border-color: var(--text-muted); color: var(--text-muted); background: var(--bg-elevated); }

.job-card-company {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.job-card-location {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.job-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
}

.job-card-actions {
    display: flex;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.72rem;
}

.btn-applied {
    background: var(--green-soft);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ── Empty State ────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; }

/* ── Modal ──────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px;
    position: relative;
    transform: translateY(20px) scale(0.97);
    transition: transform 0.25s ease;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.modal-score {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    flex-shrink: 0;
    border: 3px solid;
}

.modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
}

.modal-company {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.modal-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.modal-body h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin: 16px 0 8px;
}

.modal-body h3:first-child { margin-top: 0; }

#modal-description {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 8px;
}

#modal-reasons {
    list-style: none;
    padding: 0;
}

#modal-reasons li {
    padding: 4px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#modal-reasons li::before {
    content: '✓ ';
    color: var(--green);
    font-weight: 700;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.status-select {
    padding: 6px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    margin-left: auto;
}

.modal-feedback {
    margin-top: 12px;
    font-size: 0.82rem;
    color: var(--green);
    min-height: 20px;
}

/* ── Loading Overlay ────────────────────────────────────────────── */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(12, 14, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 300;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ── Scrollbar ──────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Toast Notifications ───────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    pointer-events: auto;
    animation: toast-in 0.3s ease forwards;
    max-width: 360px;
}

.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error { border-left: 3px solid var(--red); }
.toast.toast-info { border-left: 3px solid var(--blue); }

.toast.toast-out { animation: toast-out 0.3s ease forwards; }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Bookmark Button ───────────────────────────────────────────── */

.btn-bookmark {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 10px;
    transition: all var(--transition);
    line-height: 1;
}

.btn-bookmark:hover { color: var(--amber); border-color: var(--amber); }
.btn-bookmark.active { color: var(--amber); border-color: var(--amber); }

.job-card-bookmark {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
    z-index: 2;
}

.job-card:hover .job-card-bookmark { opacity: 1; }
.job-card-bookmark.active { opacity: 1; color: var(--amber); }

/* ── Notes Area ────────────────────────────────────────────────── */

.modal-notes {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.modal-notes h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.modal-notes textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border var(--transition);
    min-height: 60px;
}

.modal-notes textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal-notes .btn { margin-top: 6px; }

/* ── Stat Today Pill ───────────────────────────────────────────── */

.stat-today .stat-num { color: var(--amber); }

/* ── Block Button ──────────────────────────────────────────────── */

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 8px 14px;
}

/* ── Keyboard Hint ─────────────────────────────────────────────── */

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 0.65rem;
    font-family: 'Consolas', monospace;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-secondary);
}

/* ── Posted Age Badge ──────────────────────────────────────────── */

.job-card-age {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 8px;
        padding: 16px;
    }
    .sidebar-section { margin-bottom: 8px; }
    .topbar-stats { display: none; }
    .jobs-container { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .topbar { padding: 0 12px; }
    .main-content { padding: 12px; }
    .modal { padding: 20px; width: 95%; }
    .sidebar { grid-template-columns: 1fr; }
}
