/* ===== CSS Variables ===== */
:root {
    --primary-color: #4F46E5;
    --primary-hover: #4338CA;
    --secondary-color: #6B7280;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #F59E0B;

    --bg-primary: #FFFFFF;
    --bg-secondary: #F9FAFB;
    --bg-tertiary: #F3F4F6;

    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;

    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --border-radius: 8px;
    --transition: all 0.2s ease;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
    --primary-color: #6366F1;
    --primary-hover: #4F46E5;
    --secondary-color: #9CA3AF;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #F59E0B;

    --bg-primary: #1F2937;
    --bg-secondary: #111827;
    --bg-tertiary: #374151;

    --text-primary: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-light: #9CA3AF;

    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* ===== Vintage Theme (Pastel Colors) ===== */
[data-theme="vintage"] {
    --primary-color: #9D7BB8;
    --primary-hover: #8B6BA6;
    --secondary-color: #B8A4C9;
    --success-color: #90D4A8;
    --error-color: #F4A5A5;
    --warning-color: #F9D89C;

    --bg-primary: #FAF7F5;
    --bg-secondary: #F0EAE6;
    --bg-tertiary: #E8DFD8;

    --text-primary: #4A4A4A;
    --text-secondary: #7A7A7A;
    --text-light: #A0A0A0;

    --border-color: #D9CFC7;
    --shadow-sm: 0 1px 2px 0 rgba(157, 123, 184, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(157, 123, 184, 0.12);
    --shadow-lg: 0 10px 15px -3px rgba(157, 123, 184, 0.15);
}

/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== App Container ===== */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.app-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
}

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

.app-header h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    transform: scale(1.1);
}

.main-nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

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

.nav-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* ===== Main Content ===== */
.app-main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.view-header {
    margin-bottom: 2rem;
}

.view-header h2 {
    font-size: 1.875rem;
    color: var(--text-primary);
}

/* ===== Buttons ===== */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

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

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

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

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-back {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
}

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

.btn-correct {
    background-color: var(--success-color);
    color: white;
    flex: 1;
}

.btn-correct:hover {
    background-color: #059669;
}

.btn-wrong {
    background-color: var(--error-color);
    color: white;
    flex: 1;
}

.btn-wrong:hover {
    background-color: #DC2626;
}

/* ===== Modules Grid ===== */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
}

.module-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.module-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.module-delete-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
    padding: 0;
}

.module-delete-btn:hover {
    background-color: var(--error-color);
    color: white;
    transform: scale(1.1);
}

.module-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.module-card h3 {
    font-size: 1.25rem;
    margin: 0;
    color: var(--text-primary);
}

.document-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 12px;
    white-space: nowrap;
}

.badge-script {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.badge-exam {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.module-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ===== Exam Date Indicator ===== */
.exam-date-info {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-weight: 500;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 3px solid var(--primary-color);
}

.exam-date-soon {
    background-color: rgba(245, 158, 11, 0.1);
    border-left-color: var(--warning-color);
    color: var(--warning-color);
}

.exam-date-urgent {
    background-color: rgba(239, 68, 68, 0.1);
    border-left-color: var(--error-color);
    color: var(--error-color);
    animation: pulse 2s infinite;
}

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

[data-theme="dark"] .exam-date-info {
    background-color: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .exam-date-soon {
    background-color: rgba(245, 158, 11, 0.15);
}

[data-theme="dark"] .exam-date-urgent {
    background-color: rgba(239, 68, 68, 0.15);
}

.module-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.module-stat {
    display: flex;
    flex-direction: column;
}

.module-stat-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.module-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.module-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.module-actions .btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
}

.module-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 9999px;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.module-badge.status-uploaded {
    background-color: #FEF3C7;
    color: #92400E;
}

.module-badge.status-ready {
    background-color: #D1FAE5;
    color: #065F46;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 0.5rem;
}

/* ===== Upload Form ===== */
.upload-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input[type="text"] {
    width: 100%;
    padding: 0.625rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group input[type="text"]:invalid {
    border-color: var(--error-color);
}

.form-group input[type="text"]:valid {
    border-color: var(--success-color);
}

/* Select/Dropdown Styles */
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Toggle Switch Styles */
.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--secondary-color);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Radio Group Styles */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.radio-option:hover {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
}

.radio-option input[type="radio"] {
    margin-top: 0.25rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.radio-option input[type="radio"]:checked + .radio-label {
    color: var(--primary-color);
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.1);
}

.radio-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.radio-label strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.radio-label small {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.file-upload-area {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    background-color: var(--bg-secondary);
    transition: var(--transition);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
}

.file-upload-area input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    pointer-events: none;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
}

.file-upload-label * {
    pointer-events: none;
}

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

#file-name {
    color: var(--text-secondary);
}

/* ===== Progress ===== */
.progress-container {
    margin-top: 2rem;
    padding: 2rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.progress-container h3 {
    margin-bottom: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.progress-fill-animated {
    animation: indeterminate 1.5s infinite;
}

@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

#upload-status,
#generation-status {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===== Quiz ===== */
.quiz-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.quiz-header .btn-back {
    justify-self: start;
}

.quiz-header h2 {
    justify-self: center;
    text-align: center;
    margin: 0;
}

.quiz-stats {
    justify-self: end;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    min-height: 450px;
    position: relative;
}

.card-front,
.card-back {
    display: flex;
    flex-direction: column;
    min-height: 350px;
    align-items: center;
    width: 100%;
}

.card-question {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: auto;
    color: var(--text-primary);
    text-align: center !important;
    width: 100%;
    padding: 1rem 0;
    white-space: normal;
    word-wrap: break-word;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.card-question-small {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
    text-align: center !important;
    width: 100%;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.card-answer {
    font-size: 1.125rem;
    line-height: 1.8;
    margin-bottom: 1rem;
    color: var(--text-primary);
    flex: 1;
    text-align: center !important;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
}

.card-page-reference {
    margin-top: 0.5rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
    border: 1px solid var(--border-color);
}

.card-explanation-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.btn-explain {
    background-color: var(--bg-secondary);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-explain:hover {
    background-color: var(--primary-color);
    color: white;
}

.card-explanation {
    margin-top: 1rem;
    padding: 1.25rem;
    background-color: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    width: 100%;
}

.explanation-header {
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1rem;
}

.explanation-content {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 0.95rem;
    text-align: left;
}

/* Original Exam Question Styling */
.original-exam-question h4 {
    color: var(--warning-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--warning-color);
}

.original-question-box,
.original-answer-box,
.original-content-box {
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: var(--border-radius);
    background-color: var(--bg-tertiary);
}

.original-question-box {
    border-left: 4px solid var(--warning-color);
}

.original-answer-box {
    border-left: 4px solid var(--success-color);
}

.original-content-box {
    border-left: 4px solid var(--primary-color);
}

.original-question-box strong,
.original-answer-box strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.original-question-box p,
.original-answer-box p,
.original-content-box p {
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
}

/* Markdown styling inside explanation */
.explanation-content h1,
.explanation-content h2,
.explanation-content h3,
.explanation-content h4 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.explanation-content h1 { font-size: 1.5rem; }
.explanation-content h2 { font-size: 1.25rem; }
.explanation-content h3 { font-size: 1.1rem; }
.explanation-content h4 { font-size: 1rem; }

.explanation-content p {
    margin-bottom: 1rem;
}

.explanation-content strong {
    font-weight: 700;
    color: var(--text-primary);
}

.explanation-content em {
    font-style: italic;
    color: var(--text-secondary);
}

.explanation-content ul,
.explanation-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.explanation-content li {
    margin-bottom: 0.5rem;
}

.explanation-content code {
    background-color: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.explanation-content pre {
    background-color: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1rem 0;
}

.explanation-content pre code {
    background-color: transparent;
    padding: 0;
}

.explanation-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.explanation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hint Section */
.card-hint-section {
    width: 100%;
    margin-bottom: 1.5rem;
}

.btn-hint {
    background-color: var(--bg-secondary);
    color: var(--warning-color);
    border: 2px solid var(--warning-color);
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-hint:hover {
    background-color: var(--warning-color);
    color: white;
}

.card-hint {
    margin-top: 1rem;
    padding: 1.25rem;
    background-color: var(--bg-secondary);
    border: 2px solid var(--warning-color);
    border-radius: var(--border-radius);
    width: 100%;
}

.hint-header {
    margin-bottom: 1rem;
    color: var(--warning-color);
    font-size: 1rem;
}

.hint-content {
    color: var(--text-primary);
    line-height: 1.8;
    font-size: 0.95rem;
    text-align: left;
}

.hint-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.card-skip-action {
    width: 100%;
    margin-bottom: 1rem;
    text-align: center;
}

.btn-skip {
    background-color: var(--bg-secondary);
    color: var(--warning-color);
    border: 2px solid var(--warning-color);
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-skip:hover {
    background-color: var(--warning-color);
    color: white;
}

.card-actions {
    display: flex;
    gap: 1rem;
    margin-top: auto;
    width: 100%;
}

#show-answer-btn {
    width: 100%;
    padding: 0.875rem;
    font-size: 1rem;
    margin-top: 2rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.card-source-info {
    margin-top: 1rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
    border: 1px solid var(--border-color);
}

.card-notes {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

#notes-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

#notes-char-count {
    display: block;
    margin-top: 0.5rem;
}

.card-delete-action {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    width: 100%;
}

.btn-delete-question {
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
}

.btn-delete-question:hover {
    background-color: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* ===== Quiz Complete ===== */
.quiz-complete {
    text-align: center;
    padding: 3rem;
}

.quiz-complete h3 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--success-color);
}

.session-summary {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.summary-value {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.quiz-complete .btn {
    margin: 0.5rem;
}

/* ===== Statistics ===== */
.statistics-container {
    max-width: 900px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stats-details {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.stats-details h3 {
    margin-bottom: 1rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.chart-container {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.chart-container h3 {
    margin-bottom: 1rem;
}

.progress-chart {
    width: 100%;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

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

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

/* ===== Settings ===== */
.settings-container {
    max-width: 900px;
}

.settings-section {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.settings-section h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.settings-modules-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-module-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
}

.settings-module-info {
    flex: 1;
}

.settings-module-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.settings-module-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.settings-module-actions {
    display: flex;
    gap: 0.5rem;
}

.settings-module-actions .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

.backup-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.account-settings-card,
.backup-action-card {
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
}

.account-settings-card {
    max-width: 500px;
}

.account-settings-card h4,
.backup-action-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.account-settings-card form {
    margin-top: 1rem;
}

.account-settings-card .form-group {
    margin-bottom: 1rem;
}

.account-settings-card .btn {
    margin-top: 0.5rem;
}

.backup-action-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.backup-action-card .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.form-select {
    width: 100%;
    padding: 0.625rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-primary);
    font-family: inherit;
    margin-bottom: 0.5rem;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.file-upload-area-small {
    margin-bottom: 0.5rem;
}

.file-upload-area-small input[type="file"] {
    display: none;
}

.file-upload-area-small label {
    display: inline-block;
    cursor: pointer;
}

.selected-filename {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.danger-zone {
    border-color: var(--error-color);
}

.danger-zone h3 {
    color: var(--error-color);
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.form-input {
    width: 100%;
    padding: 0.625rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-hint {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    line-height: 1.5;
}

/* ===== Confirmation Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeInOverlay 0.2s ease;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-box {
    background-color: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 90%;
    animation: slideInModal 0.3s ease;
}

@keyframes slideInModal {
    from {
        transform: scale(0.9) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
}

.modal-body p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 1rem 2rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.modal-footer .btn {
    min-width: 100px;
}

.modal-box-large {
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-box-large .modal-body {
    overflow-y: auto;
    flex: 1;
}

.modal-body-help h4 {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

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

.modal-body-help ul,
.modal-body-help ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.modal-body-help li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.help-example {
    background-color: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.help-example code {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
    display: block;
}

/* ===== Difficulty Preview & Tooltips ===== */
.info-icon {
    display: inline-block;
    font-size: 1rem;
    color: var(--primary-color);
    cursor: help;
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: var(--transition);
}

.info-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

.difficulty-preview {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.difficulty-preview h4 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
}

.preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.preview-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.preview-value {
    font-size: 0.95rem;
    color: var(--primary-color);
    font-weight: 600;
}

.preview-note {
    grid-column: 1 / -1;
    background-color: #FEF3C7;
    border-color: #F59E0B;
}

.preview-note .preview-label {
    color: #92400E;
}

.preview-note .preview-value {
    color: #B45309;
}

/* ===== Theme Selector Styles ===== */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.theme-option {
    position: relative;
    cursor: pointer;
}

.theme-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-preview {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--bg-secondary);
    transition: var(--transition);
    min-height: 100px;
}

.theme-option input[type="radio"]:checked + .theme-preview {
    border-color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.theme-preview:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.theme-preview-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.theme-icon {
    font-size: 2rem;
}

.theme-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.theme-preview-colors {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

.color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
}

/* Theme-specific preview styling */
.theme-preview-light {
    background: linear-gradient(135deg, #FFFFFF 0%, #F9FAFB 100%);
}

.theme-preview-dark {
    background: linear-gradient(135deg, #1F2937 0%, #111827 100%);
}

.theme-preview-dark .theme-name {
    color: #F9FAFB;
}

.theme-preview-vintage {
    background: linear-gradient(135deg, #FAF7F5 0%, #F0EAE6 100%);
}

[data-theme="vintage"] .theme-option input[type="radio"]:checked + .theme-preview {
    border-color: #9D7BB8;
    background-color: rgba(157, 123, 184, 0.05);
    box-shadow: 0 0 0 3px rgba(157, 123, 184, 0.1);
}

[data-theme="vintage"] .theme-preview:hover {
    border-color: #9D7BB8;
}

/* ===== Logout Button ===== */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
    }

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

    /* Compact header for mobile */
    .app-header {
        padding: 0.75rem 1rem;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

    .user-name {
        display: none;
    }

    .logout-btn {
        padding: 0.6rem;
        min-width: auto;
        border-radius: 50%;
        aspect-ratio: 1;
    }

    .logout-text {
        display: none;
    }

    .logout-icon {
        width: 20px;
        height: 20px;
    }

    .quiz-card {
        padding: 1.5rem;
        min-height: 300px;
    }

    .card-front,
    .card-back {
        min-height: 250px;
    }

    .card-question {
        font-size: 1.375rem;
    }

    .card-answer {
        font-size: 1rem;
    }

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

    .quiz-header {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        text-align: center;
    }

    .quiz-header .btn-back,
    .quiz-header h2,
    .quiz-stats {
        justify-self: center;
    }

    /* Card action buttons spacing for mobile */
    .card-delete-action {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .card-delete-action .btn {
        width: 100%;
        margin: 0 !important;
    }
}

/* ===== Login Page Styles ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366F1 100%);
    padding: 2rem;
    position: relative;
}

.login-box {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.login-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

.login-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
}

.login-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.login-tab.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.login-tab:hover:not(.active) {
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-group-checkbox {
    display: flex;
    align-items: center;
}

.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group-checkbox input[type="checkbox"] {
    cursor: pointer;
}

.error-message {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--error-color);
    border-radius: 6px;
    color: var(--error-color);
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
}

.login-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

.login-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.login-link:hover {
    text-decoration: underline;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: 16px;
    z-index: 1000;
}

[data-theme="dark"] .loading-overlay {
    background: rgba(31, 41, 55, 0.95);
}

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

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

.loading-overlay p {
    color: var(--text-primary);
    font-weight: 500;
}

.theme-toggle-login {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.75rem;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.theme-toggle-login:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Mobile responsiveness for login */
@media (max-width: 640px) {
    .login-container {
        padding: 1rem;
    }

    .login-box {
        padding: 1.5rem;
    }

    .login-logo {
        font-size: 3rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }
}

/* Loading Overlay for Quiz Start */
#quiz-loading.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#quiz-loading .loading-container {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    min-width: 250px;
}

#quiz-loading .loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1.5rem;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color, #4CAF50);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#quiz-loading p {
    margin: 0;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}