:root {
    --primary: #1e293b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --gold: #d97706;
    --purple: #7c3aed;
    --bg-light: #f1f5f9;
    --card-bg: #ffffff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; padding: 0;
}

html, body {
    width: 100%; max-width: 100%; overflow-x: hidden;
    background-color: var(--bg-light); color: var(--text-dark);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* 1. MÀN HÌNH ĐĂNG NHẬP */
.auth-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex; justify-content: center; align-items: center; z-index: 9999; padding: 16px;
}
.auth-card {
    background: white; padding: 32px 24px; border-radius: var(--radius);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; text-align: center;
}
.auth-icon { font-size: 48px; color: var(--accent); margin-bottom: 12px; }
.auth-card h2 { font-size: 22px; color: var(--primary); margin-bottom: 6px; }
.input-group { margin: 20px 0; }
.input-group input {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border-color);
    border-radius: 8px; font-size: 16px; outline: none;
}
.input-group input:focus { border-color: var(--accent); }
.error-msg { color: #dc2626; margin-top: 12px; font-size: 14px; }

/* 2. CHÍNH */
.app-container { width: 100%; max-width: 850px; margin: 0 auto; padding: 16px 12px; }
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--primary); color: white; padding: 12px 16px;
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
}
.header-brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.header-brand i { color: var(--gold); }
.header-actions { display: flex; gap: 6px; }

/* BUTTONS */
.btn {
    padding: 10px 14px; border: none; border-radius: 8px; cursor: pointer;
    font-weight: 600; font-size: 14px; transition: all 0.2s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-gold { background: var(--gold); color: white; }
.btn-accent { background: #059669; color: white; }
.btn-purple { background: var(--purple); color: white; }
.btn-secondary { background: #64748b; color: white; }
.btn-header-logout { background: rgba(255,255,255,0.15); color: white; padding: 10px; }

/* NÚT AMEN / ĐỔI CÂU DỄ NHÌN NỀN TRẮNG CHỮ ĐEN */
.btn-dark-outline {
    background: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-dark) !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-dark-outline:hover { background: #f8fafc !important; border-color: var(--text-muted) !important; }

.btn-block { width: 100%; }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* CARDS */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.search-hero-section { border: 2px solid #e2e8f0; padding: 18px 16px; }
.search-hero-box { position: relative; width: 100%; margin-bottom: 10px; }
.search-hero-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 18px; color: var(--accent); }
.search-hero-box input {
    width: 100%; padding: 12px 16px 12px 46px; font-size: 15px;
    border: 2px solid var(--border-color); border-radius: 10px; outline: none; background: #f8fafc;
}
.search-hero-box input:focus { border-color: var(--accent); background: white; }
.filter-topic-box { display: flex; align-items: center; gap: 8px; }
.filter-topic-box label { font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.filter-topic-box select, .form-control { width: 100%; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 14px; outline: none; }

/* FORM */
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--bg-light); padding-bottom: 8px; }
.form-grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
.form-group input, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 14px; outline: none; }

/* DANH SÁCH & THẺ NHIỀU CHỦ ĐỀ */
.verse-grid { display: flex; flex-direction: column; gap: 12px; }
.verse-item { border: 1px solid var(--border-color); border-left: 4px solid var(--accent); padding: 14px; border-radius: 8px; background: white; word-wrap: break-word; }
.verse-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.verse-ref { font-weight: 700; font-size: 16px; color: var(--primary); }

/* HIỂN THỊ CÁC THẺ CHỦ ĐỀ CÁCH NHAU */
.topic-tag-group { display: flex; flex-wrap: wrap; gap: 4px; }
.verse-topic-tag { background: #eff6ff; color: var(--accent); padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }

.verse-text { font-size: 15px; font-style: italic; color: #334155; margin-bottom: 8px; }
.verse-notes { font-size: 13px; color: var(--text-muted); background: #fffbeb; padding: 8px; border-radius: 6px; border-left: 3px solid var(--gold); margin-bottom: 8px; }
.verse-actions { display: flex; gap: 8px; justify-content: flex-end; }

.pagination-container { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border-color); background: white; cursor: pointer; border-radius: 6px; font-weight: 600; }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* MODALS */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.7); display: flex; justify-content: center; align-items: center; z-index: 1000; padding: 12px; }
.modal-card { background: white; border-radius: var(--radius); width: 100%; max-width: 480px; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-lg { max-width: 620px; }
.modal-header { background: var(--primary); color: white; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.close-modal { background: none; border: none; color: white; font-size: 24px; cursor: pointer; }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; background: #f8fafc; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
.flex-between { justify-content: space-between; align-items: center; }

/* FLASHCARD */
.flashcard-hint { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.flashcard-container { width: 100%; height: 250px; perspective: 1000px; cursor: pointer; }
.flashcard-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform 0.5s; transform-style: preserve-3d; }
.flashcard-container.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
    position: absolute; width: 100%; height: 100%; -webkit-backface-visibility: hidden; backface-visibility: hidden;
    border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center;
    box-shadow: var(--shadow); border: 2px solid var(--gold); background: white;
}
.flashcard-front h2 { font-size: 24px; color: var(--primary); margin: 10px 0; }
.flashcard-back { transform: rotateY(180deg); background: #fffdf9; overflow-y: auto; }

/* TRẮC NGHIỆM */
.quiz-question-box { background: #f8fafc; border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; margin-bottom: 16px; text-align: center; }
.quiz-type-badge { display: inline-block; background: var(--purple); color: white; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; margin-bottom: 8px; text-transform: uppercase; }
.quiz-question-text { font-size: 17px; color: var(--primary); font-weight: 600; }
.quiz-options-grid { display: flex; flex-direction: column; gap: 10px; }
.quiz-option-btn {
    width: 100%; padding: 12px 16px; text-align: left; background: white; border: 2px solid var(--border-color);
    border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s; color: var(--text-dark);
}
.quiz-option-btn:hover:not(:disabled) { border-color: var(--accent); background: #f0f7ff; }
.quiz-option-btn.correct { background: #d1fae5 !important; border-color: #10b981 !important; color: #065f46 !important; font-weight: 700; }
.quiz-option-btn.wrong { background: #fee2e2 !important; border-color: #ef4444 !important; color: #991b1b !important; }
.quiz-feedback { margin-top: 14px; padding: 10px; border-radius: 6px; text-align: center; font-weight: 600; font-size: 14px; }
.quiz-feedback.correct { background: #d1fae5; color: #065f46; }
.quiz-feedback.wrong { background: #fee2e2; color: #991b1b; }
.quiz-score-live { font-size: 14px; color: var(--text-muted); }

/* MOBILE */
@media (max-width: 600px) {
    .app-container { padding: 8px; }
    .btn-text { display: none; }
    .form-grid-3, .form-grid-2 { grid-template-columns: 1fr; gap: 0; }
    .filter-topic-box { flex-direction: column; align-items: flex-start; }
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1; }
}