/* ============================================================
   Maktab Al-Hayat — App Styles (Light Mode)
   ============================================================ */

:root {
    --bg:           #F5F7F5;
    --surface:      #FFFFFF;
    --surface-2:    #FAFBFA;
    --border:       #E4E8E4;
    --border-light: #EEF1EE;
    --text:         #0B2A20;
    --text-muted:   #5A6B62;
    --text-faint:   #94A29B;
    --primary:      #0F3D2E;
    --primary-soft: #1A5A45;
    --primary-bg:   #EAF2EE;
    --accent:       #C9A24B;
    --accent-dark:  #A8853A;
    --accent-bg:    #FBF6E9;
    --danger:       #D32F2F;
    --danger-bg:    #FDECEC;
    --success:      #2E7D32;
    --success-bg:   #E8F5E9;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(11, 42, 32, 0.05);
    --shadow-md: 0 4px 12px rgba(11, 42, 32, 0.06);
}

/* Reset */

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

html, body { width: 100%; min-height: 100%; }

body {
    font-family: "Vazirmatn", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.85;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

img { max-width: 100%; display: block; }

/* Layout */

#app-root {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 18px 40px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.page {
    display: none;
    flex: 1;
    flex-direction: column;
    animation: fadeUp 0.3s ease both;
}

.page.active { display: flex; }

/* Top Bar */

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    min-height: 38px;
}

.topbar-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, background 0.15s ease;
}

.topbar-btn:active {
    transform: scale(0.95);
    background: var(--surface-2);
}

.topbar-btn.hidden { visibility: hidden; }

.topbar-btn svg {
    width: 100%;
    height: 100%;
}

.topbar-title {
    flex: 1;
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hero */

.hero {
    padding: 20px 0 32px;
    text-align: center;
}

.hero-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 18px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface);
    box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px var(--border), var(--shadow-md);
}

.hero-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.4;
    margin-bottom: 6px;
}

.hero-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.hero-divider {
    width: 40px;
    height: 2px;
    background: var(--accent);
    margin: 20px auto 0;
    border-radius: 2px;
    opacity: 0.7;
}

/* Menu */

.menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    width: 100%;
}

.menu-item:active {
    transform: scale(0.985);
    border-color: var(--accent);
}

.menu-body {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.menu-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 3px;
}

.menu-desc {
    font-size: 11.5px;
    color: var(--text-muted);
}

.menu-arrow {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-faint);
    margin-left: 12px;
}

.menu-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-sm);
    background: var(--primary-bg);
    color: var(--primary);
    padding: 10px;
    margin-right: 14px;
}

.menu-icon svg {
    width: 100%;
    height: 100%;
}

/* Buttons */

.btn {
    flex: 1;
    border-radius: var(--r-sm);
    padding: 12px 14px;
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.97); }

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Empty & Loading */

.empty {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 44px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13.5px;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.8;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    display: inline-block;
    width: 26px;
    height: 26px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 12px;
}

/* Page Header */

.page-header {
    text-align: center;
    margin-bottom: 26px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.page-header p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 340px;
    margin: 0 auto;
    line-height: 1.9;
}

/* Text */

.text-body {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 2.05;
    text-align: right;
}

.text-body p { margin-bottom: 16px; }

.text-center { text-align: center; }

/* Modals */

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(11, 42, 32, 0.4);
    z-index: 1000;
    animation: fadeIn 0.18s ease;
}

.modal.active { display: flex; }

.modal-box {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 22px 18px 26px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.28s ease;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.modal-desc {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-bottom: 16px;
    line-height: 1.85;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.modal-actions button {
    flex: 1;
    border-radius: var(--r-sm);
    padding: 12px;
    font-size: 13.5px;
    font-weight: 600;
}

.modal-actions button:active { transform: scale(0.97); }

/* Inputs */

.input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-sm);
    padding: 13px 14px;
    font-size: 16px;
    outline: none;
    direction: ltr;
    text-align: left;
    transition: border-color 0.15s ease;
    font-family: inherit;
}

.input:focus {
    border-color: var(--primary);
}

.input-hint {
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 11.5px;
}

/* File Upload */

.file-drop {
    position: relative;
    width: 100%;
    border: 1.5px dashed var(--border);
    border-radius: var(--r-sm);
    padding: 22px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.file-drop:active {
    border-color: var(--primary);
    background: var(--surface-2);
}

.file-drop input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-drop-icon {
    font-size: 26px;
    margin-bottom: 6px;
}

.file-drop-text {
    font-size: 12.5px;
    color: var(--text-muted);
    word-break: break-all;
}

.file-preview {
    margin-top: 10px;
    border-radius: var(--r-sm);
    overflow: hidden;
    display: none;
}

.file-preview img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    background: var(--surface-2);
}

.file-preview.active { display: block; }

/* Alert */

.alert {
    display: none;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    font-size: 12px;
    line-height: 1.8;
}

.alert.show { display: block; }

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(211, 47, 47, 0.2);
}

/* Campaigns */

.campaigns {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.campaign {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.3s ease both;
}

.campaign h2 {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.6;
}

.campaign-desc {
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.9;
    white-space: pre-line;
    margin-bottom: 12px;
}

.progress { margin-top: 12px; }

.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
    margin-bottom: 8px;
}

.progress-row strong {
    font-size: 13.5px;
    color: var(--primary);
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-dark));
    border-radius: 10px;
    transition: width 0.6s ease;
}

.progress-small {
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 11px;
    color: var(--text-faint);
}

.badge-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--accent-bg);
    color: var(--accent-dark);
    border-radius: var(--r-sm);
    font-size: 12px;
    text-align: center;
    font-weight: 500;
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

/* Courses */

.course-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.course-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: right;
    width: 100%;
    transition: transform 0.15s ease, border-color 0.15s ease;
    animation: fadeUp 0.3s ease both;
}

.course-item:active {
    transform: scale(0.985);
    border-color: var(--primary);
}

.course-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.course-body { flex: 1; min-width: 0; }

.course-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
    line-height: 1.5;
}

.course-meta {
    font-size: 11.5px;
    color: var(--text-muted);
}

.course-arrow {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--text-faint);
}

/* Sessions */

.session-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: right;
    width: 100%;
    transition: transform 0.15s ease, border-color 0.15s ease;
    animation: fadeUp 0.3s ease both;
}

.session-item:active {
    transform: scale(0.985);
    border-color: var(--primary);
}

.session-num {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.session-body { flex: 1; min-width: 0; }

.session-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-faint);
}

.tag svg { width: 11px; height: 11px; }

.tag-pdf { color: #C62828; }
.tag-audio { color: var(--success); }

.session-arrow {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-faint);
}

/* Session Detail */

.session-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    animation: fadeUp 0.3s ease both;
}

.session-badge {
    display: inline-block;
    background: var(--primary-bg);
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 11px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.session-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 8px;
}

.session-header p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.9;
    white-space: pre-line;
}

.block { margin-bottom: 22px; }

.block-title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    padding-right: 2px;
}

.pdf-list,
.audio-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: right;
    width: 100%;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.pdf-item:active {
    transform: scale(0.985);
    border-color: var(--primary);
}

.pdf-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: #FDECEC;
    color: #C62828;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.pdf-body { flex: 1; min-width: 0; }

.pdf-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-size {
    font-size: 10.5px;
    color: var(--text-muted);
}

.pdf-dl {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--primary);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px;
}

.audio-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 13px 15px;
    box-shadow: var(--shadow-sm);
}

.audio-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.audio-icon {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--r-sm);
    background: var(--success-bg);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.audio-body { flex: 1; min-width: 0; }

.audio-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audio-meta {
    font-size: 10.5px;
    color: var(--text-muted);
    display: flex;
    gap: 10px;
}

.audio-player {
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 10px;
}

.audio-player audio {
    width: 100%;
    height: 38px;
    display: block;
}

.nav-row {
    display: flex;
    gap: 8px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* Utility */

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }

/* Animations */

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

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

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

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   Cards
   ============================================================ */

.cards-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.loading-cards {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 16px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
}

.card-info {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 12px 14px;
}

.card-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12.5px;
}

.card-row:last-child {
    margin-bottom: 0;
}

.card-label {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 70px;
}

.card-value {
    color: var(--text);
    font-weight: 600;
    flex: 1;
}

.card-number {
    font-family: monospace;
    letter-spacing: 0.5px;
    direction: ltr;
    text-align: left;
}

.copy-btn {
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

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

.card-description {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.8;
}

.receipt-hint {
    background: #FFF8E1;
    border: 1px solid #FFE082;
    color: #7A5F00;
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 11.5px;
    line-height: 1.85;
    margin-top: 12px;
}

body.dark .receipt-hint {
    background: rgba(255, 224, 130, 0.1);
    border-color: rgba(255, 224, 130, 0.3);
    color: #FFE082;
}