/* =============================================
   Interview Question Bank — style.css
   Professional blue theme, card-flip animations
   ============================================= */

:root {
    --primary: #1e40af;
    --primary-h: #1d3ba8;
    --secondary: #3b82f6;
    --accent-ok: #16a34a;
    --accent-warn: #d97706;
    --accent-err: #dc2626;
    --bg: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    --header-h: 56px;
    --sidebar-w: 240px;
    --transition: 0.2s ease;
}

/* Dark mode */
body.dark {
    --primary: #60a5fa;
    --primary-h: #3b82f6;
    --bg: #0f172a;
    --bg-surface: #1e293b;
    --bg-sidebar: #111827;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
}

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

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.25s, color 0.25s;
}

/* ── Header ── */
.site-header {
    height: var(--header-h);
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-inner {
    max-width: 100%;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1rem;
}

.logo-icon {
    font-size: 1.3rem;
}

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

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-h);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
}

.btn-outline {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.35);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.12);
}

body:not(.dark) .sidebar .btn-outline,
body:not(.dark) .main-content .btn-outline,
.modal-card .btn-outline {
    color: var(--text-muted);
    border-color: var(--border);
}

body:not(.dark) .sidebar .btn-outline:hover,
body:not(.dark) .main-content .btn-outline:hover,
.modal-card .btn-outline:hover {
    background: rgba(0, 0, 0, 0.04);
}

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

.btn-danger {
    background: transparent;
    color: var(--accent-err);
    border-color: rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.06);
}

.full-width {
    width: 100%;
    justify-content: center;
}

.mt-sm {
    margin-top: 8px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── App Layout ── */
.app-wrapper {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - var(--header-h));
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ── Progress Stats ── */
.progress-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prog-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.prog-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.prog-bar-bg {
    background: var(--border);
    border-radius: 4px;
    height: 7px;
    overflow: hidden;
}

.prog-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
    background: var(--accent-ok);
}

/* ── Spaced Repetition ── */
.spaced-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.spaced-item {
    font-size: 0.74rem;
    color: var(--text-muted);
    background: rgba(30, 64, 175, 0.07);
    border: 1px solid rgba(30, 64, 175, 0.15);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.spaced-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.spaced-empty {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Filters ── */
.filter-group {
    margin-bottom: 8px;
}

.filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    background: var(--bg-surface);
    color: var(--text);
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ── Questions Grid ── */
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

/* ── Question Card ── */
.question-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all var(--transition);
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border-color: rgba(30, 64, 175, 0.2);
}

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

.q-card-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-technical {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.badge-behavioral {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

.badge-system {
    background: rgba(139, 92, 246, 0.12);
    color: #7c3aed;
}

.badge-easy {
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
}

.badge-medium {
    background: rgba(234, 179, 8, 0.12);
    color: #b45309;
}

.badge-hard {
    background: rgba(220, 38, 38, 0.12);
    color: #dc2626;
}

.badge-company {
    background: rgba(30, 64, 175, 0.08);
    color: var(--primary);
    border: 1px solid rgba(30, 64, 175, 0.2);
}

.q-card-actions {
    display: flex;
    gap: 4px;
}

.q-card-btn {
    background: transparent;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    color: var(--text-muted);
    transition: color var(--transition);
}

.q-card-btn:hover {
    color: var(--text);
}

.q-question {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 8px;
}

.q-answer-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 10px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.q-stars {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
}

.q-star {
    font-size: 1rem;
    cursor: pointer;
    transition: transform var(--transition);
    color: var(--border);
}

.q-star.filled {
    color: #f59e0b;
}

.q-star:hover {
    transform: scale(1.2);
}

.q-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.q-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.q-tag {
    font-size: 0.62rem;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--text-muted);
}

/* ── Empty State ── */
.empty-state {
    grid-column: 1/-1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
}

/* ── Practice Mode Overlay ── */
.practice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.practice-overlay[hidden] {
    display: none;
}

.practice-container {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.practice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.practice-header h2 {
    color: #fff;
    font-size: 1.1rem;
}

.practice-progress {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ── Card Flip ── */
.card-flip-wrapper {
    perspective: 1200px;
    height: 340px;
}

.card-flip {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease;
}

.card-flip.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.card-back {
    transform: rotateY(180deg);
}

.card-type-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.card-question {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.6;
    color: var(--text);
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
}

.card-answer {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-muted);
    max-height: 180px;
    overflow-y: auto;
    width: 100%;
    text-align: left;
}

/* ── Rating ── */
.card-rating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rating-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stars-row {
    display: flex;
    gap: 6px;
}

.star-btn {
    background: transparent;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--border);
    transition: color var(--transition), transform var(--transition);
}

.star-btn:hover,
.star-btn.active {
    color: #f59e0b;
    transform: scale(1.2);
}

.practice-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-card {
    width: 100%;
    max-width: 540px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 0.95rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    line-height: 1.6;
}

.code-textarea {
    font-family: monospace;
    font-size: 0.78rem;
}

.import-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

code {
    font-family: monospace;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.84rem;
    z-index: 999;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.25s ease;
    pointer-events: none;
    max-width: 300px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 860px) {
    :root {
        --sidebar-w: 180px;
    }

    .questions-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .sidebar {
        display: none;
    }

    .header-actions .btn-sm:not(#practice-mode-btn):not(#add-question-btn) {
        display: none;
    }
}