/* ═══════════════════════════════════════════════════
   ResumeTailor AI — Design System & Styles
   ═══════════════════════════════════════════════════ */

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

/* ─── Design Tokens ─────────────────────────────── */
:root {
    /* Dark mode (default) */
    --bg-primary: #06080f;
    --bg-secondary: #0d1117;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.04);
    --border-glass: rgba(255, 255, 255, 0.07);
    --border-input: rgba(255, 255, 255, 0.1);
    --border-focus: #7c3aed;
    --text-primary: #e6e8eb;
    --text-secondary: #8b949e;
    --text-muted: #555d66;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --accent-soft: rgba(124, 58, 237, 0.12);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --error: #f87171;
    --error-soft: rgba(248, 113, 113, 0.12);
    --info: #60a5fa;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --blur: 24px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-primary: #f4f5f8;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.6);
    --bg-glass-hover: rgba(255, 255, 255, 0.85);
    --bg-input: rgba(0, 0, 0, 0.03);
    --border-glass: rgba(0, 0, 0, 0.07);
    --border-input: rgba(0, 0, 0, 0.12);
    --text-primary: #1a1a2e;
    --text-secondary: #5a6070;
    --text-muted: #9ca3af;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 600; }

.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-sm { font-size: 0.8rem; color: var(--text-secondary); }

/* ─── Loading Overlay ───────────────────────────── */
.loader-overlay {
    position: fixed; inset: 0;
    background: var(--bg-primary);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}
.loader-overlay.fade-out { opacity: 0; pointer-events: none; }

.loader-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loader-text { margin-top: 1rem; color: var(--text-secondary); font-size: 0.9rem; }

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

/* ─── Auth Page ─────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-soft) 0%, transparent 60%),
        var(--bg-primary);
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.brand-icon {
    display: inline-flex;
    margin-bottom: 0.75rem;
}
.auth-brand h1 { margin-bottom: 0.25rem; }
.auth-subtitle { color: var(--text-secondary); font-size: 0.9rem; }

.auth-form {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-form h2 { margin-bottom: 1.5rem; }

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }

/* ─── Form Elements ─────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}
textarea {
    resize: vertical;
    min-height: 100px;
}

.form-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
    min-height: 1.2rem;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ─── Buttons ───────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    outline: none;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-glass-hover); }

.btn-full { width: 100%; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1rem; border-radius: var(--radius-sm); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-icon {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; padding: 0.4rem; border-radius: var(--radius-xs);
    transition: all var(--transition); display: inline-flex;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-glass); }

.btn-loader {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ─── Navbar ────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.05rem;
}
.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.nav-user-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ─── Tab Bar ───────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-glass);
    overflow-x: auto;
}
.tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.tab:hover { color: var(--text-primary); background: var(--bg-glass); }
.tab.active {
    color: var(--accent);
    background: var(--accent-soft);
}

/* ─── Tab Content ───────────────────────────────── */
.tab-content {
    display: none;
    padding: 1.5rem;
    max-width: 960px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Cards ─────────────────────────────────────── */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}
.card:hover { border-color: rgba(124, 58, 237, 0.15); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
}
.badge-optional { background: var(--bg-glass-hover); color: var(--text-secondary); }

/* ─── Dashboard Grid ────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.card-email {
    grid-column: 1 / -1;
}

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

/* ─── Dropzone ──────────────────────────────────── */
.dropzone {
    border: 2px dashed var(--border-input);
    border-radius: var(--radius-sm);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}
.dropzone:hover, .dropzone.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.dropzone-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.dropzone-title {
    font-weight: 500;
    margin-bottom: 0.2rem;
}
.dropzone-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* File Preview */
.file-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--success-soft);
    border-radius: var(--radius-sm);
    margin-top: 0.75rem;
    border: 1px solid rgba(52, 211, 153, 0.2);
}
.file-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--success);
}
.file-name { font-weight: 500; font-size: 0.9rem; color: var(--text-primary); }
.file-size { font-size: 0.75rem; color: var(--text-secondary); }
.btn-remove { color: var(--text-secondary); font-size: 1.1rem; }

/* ─── JD Input ──────────────────────────────────── */
.jd-toggle {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    padding: 0.2rem;
}
.jd-tab {
    flex: 1;
    padding: 0.4rem;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    background: none;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.jd-tab.active {
    background: var(--accent);
    color: #fff;
}
.input-url {
    width: 100%;
}

/* ─── Action Bar ────────────────────────────────── */
.action-bar {
    text-align: center;
    padding: 1rem 0;
}
.action-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ─── Processing Steps ──────────────────────────── */
.processing-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}
.processing-title {
    font-size: 1.4rem;
    margin-bottom: 0.3rem;
}
.processing-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.steps-timeline {
    text-align: left;
    position: relative;
    padding-left: 2.5rem;
}
.steps-timeline::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 12px;
    bottom: 12px;
    width: 2px;
    background: var(--border-glass);
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    position: relative;
}
.step-indicator {
    position: absolute;
    left: -2.5rem;
    top: 0.85rem;
    z-index: 1;
}
.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-glass);
    border: 2px solid var(--bg-primary);
    transition: all 0.4s ease;
}

.step.active .step-dot {
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    animation: pulse 1.5s ease infinite;
}
.step.completed .step-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success-soft);
}
.step.failed .step-dot {
    background: var(--error);
}

.step-content h3 {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
}
.step-content p {
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.step.active .step-content h3 { color: var(--accent); }
.step.completed .step-content h3 { color: var(--success); }
.step.failed .step-content h3 { color: var(--error); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

/* ─── Results ───────────────────────────────────── */
.results-container {
    display: grid;
    gap: 1rem;
}

/* ATS Score Gauge */
.card-score { text-align: center; }
.score-gauge { position: relative; width: 180px; height: 180px; margin: 1rem auto; }
.gauge-svg { width: 100%; height: 100%; }
.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.score-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 60%);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.score-breakdown { margin-top: 1.25rem; }
.score-item {
    display: grid;
    grid-template-columns: 120px 1fr 45px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
}
.score-item-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
}
.score-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}
.score-item-value {
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
}

/* Keywords */
.keywords-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.keywords-title {
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
}
.keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.keyword-tag {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
}
.keyword-tag.matched {
    background: var(--success-soft);
    color: var(--success);
}
.keyword-tag.missing {
    background: var(--warning-soft);
    color: var(--warning);
}

/* Preview */
.preview-actions {
    display: flex;
    gap: 0.5rem;
}
.resume-preview-frame {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 2rem;
    min-height: 400px;
    color: #1a1a1a;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow: auto;
    max-height: 800px;
}
.preview-placeholder {
    text-align: center;
    color: #999;
    padding: 4rem 1rem;
}

/* ─── History ───────────────────────────────────── */
.history-list { display: grid; gap: 0.75rem; }
.history-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}
.history-empty p { margin-top: 0.5rem; }

.history-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.history-card:hover { border-color: var(--accent); background: var(--bg-glass-hover); }

.history-info h3 {
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
}
.history-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
}
.history-score {
    font-weight: 700;
    font-size: 1.1rem;
    margin-right: 1rem;
}
.score-high { color: var(--success); }
.score-mid { color: var(--warning); }
.score-low { color: var(--error); }

.history-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ─── Toast ─────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--info); }

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

/* ─── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
    .tab-content { padding: 1rem; }
    .navbar { padding: 0.6rem 1rem; }
    .tab-bar { padding: 0.4rem 1rem; }
    .keywords-grid { grid-template-columns: 1fr; }
    .score-item { grid-template-columns: 90px 1fr 40px; }
}
