/* ══════════════════════════════════════════════════════
   Email Scanner — Dark Navy + White Minimal Theme
   ══════════════════════════════════════════════════════ */

:root {
    --bg-primary: #050a15;
    --bg-secondary: #0a1128;
    --bg-tertiary: #111d35;
    --bg-hover: #162040;
    --border: #1a2a4a;
    --border-light: #243456;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.12);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.12);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.12);
    --danger: #ef4444;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ── Layout ─────────────────────────────────────── */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

/* ── Header ─────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scan-status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.scan-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 16px;
}
.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn:disabled, .btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

/* ── Stats Grid ─────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    transition: all var(--transition);
}
.stat-card:hover {
    border-color: var(--border-light);
    background: var(--bg-tertiary);
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-change {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ── Main Content Area ──────────────────────────── */
.content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

/* ── Toolbar ────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.tab {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    background: none;
    border: none;
    font-family: inherit;
}
.tab:hover { color: var(--text-secondary); }
.tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.search-box {
    position: relative;
    flex-shrink: 0;
}

.search-box input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px 7px 34px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    width: 220px;
    transition: all var(--transition);
    font-family: inherit;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 14px;
    pointer-events: none;
}

/* ── Email List ─────────────────────────────────── */
.email-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.email-card:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.email-card.unread {
    border-left: 3px solid var(--accent);
}

.email-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.email-from {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.email-sender {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.email-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.email-subject {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.email-jobs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.job-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--accent-glow);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
}

.confidence-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.confidence-high {
    background: var(--success-glow);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.confidence-medium {
    background: var(--warning-glow);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.confidence-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.email-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(26, 42, 74, 0.5);
}

.email-actions {
    display: flex;
    gap: 6px;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Subscriber List ────────────────────────────── */
.subscriber-form {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.subscriber-form input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}
.subscriber-form input::placeholder { color: var(--text-dim); }
.subscriber-form input:focus {
    border-color: var(--accent);
}

.subscriber-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.subscriber-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.subscriber-email {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.subscriber-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.subscriber-actions button {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 14px;
    transition: color var(--transition);
}
.subscriber-actions button:hover { color: var(--danger); }
.subscriber-actions button.toggle-btn:hover { color: var(--warning); }

.subscriber-inactive {
    opacity: 0.5;
    text-decoration: line-through;
}

/* ── Top Companies ──────────────────────────────── */
.company-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.company-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.company-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.company-count {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ── Scan Logs ──────────────────────────────────── */
.scan-log-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
}

.scan-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 11px;
    color: var(--text-muted);
    border-radius: 4px;
}
.scan-log-item:nth-child(odd) {
    background: rgba(17, 29, 53, 0.5);
}

.scan-log-result {
    color: var(--text-secondary);
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 21, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.modal-value {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-job {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 8px;
}

.modal-job-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.modal-job-company {
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 8px;
}

.modal-job-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.modal-job-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-job-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

.apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 7px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--transition);
}
.apply-btn:hover {
    background: var(--accent-hover);
    color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
}

/* ── Notes Textarea ─────────────────────────────── */
.notes-textarea {
    width: 100%;
    min-height: 80px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition);
}
.notes-textarea::placeholder { color: var(--text-dim); }
.notes-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Modal Preview ──────────────────────────────── */
.modal-preview {
    font-size: 13px;
    color: var(--text-secondary);
    max-height: 120px;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Refresh Timer ──────────────────────────────── */
.refresh-timer {
    font-size: 11px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

/* ── Toast ──────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    animation: slideIn 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.error { border-color: rgba(239, 68, 68, 0.3); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Empty State ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-state-sub {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Loading ────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 120px;
    border-radius: var(--radius);
    margin-bottom: 8px;
}

/* ── Pagination ─────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination button {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.pagination button:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 8px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
    .content {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .app { padding: 16px 12px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px 14px; }
    .stat-value { font-size: 22px; }
    .header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .header-actions { width: 100%; justify-content: space-between; }
    .tabs { overflow-x: auto; }
}
