/* ==========================================================================
   ExamFikra - Modern Google Material 3 Light Theme & Mobile Responsive
   منصة الفروض والاختبارات - تصميم جوجل الفاتح العصري والمتجاوب تماماً
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=Tajawal:wght@400;500;700;800;900&family=Amiri:wght@400;700&display=swap');

:root {
    /* Google Material 3 Light Theme Colors (Clean, Bright, Professional) */
    --google-bg: #f8f9fa;
    --google-surface: #ffffff;
    --google-surface-variant: #f1f3f4;
    --google-surface-container: #e8eaed;
    --google-surface-hover: #f1f3f4;
    --google-border: #dadce0;
    --google-border-subtle: #e2e8f0;

    /* Google Brand Palette */
    --google-blue: #1a73e8;
    --google-blue-hover: #1557b0;
    --google-red: #ea4335;
    --google-red-hover: #d93025;
    --google-green: #34a853;
    --google-green-hover: #2d9249;
    --google-yellow: #fbbc04;
    --google-purple: #9334e6;
    --google-gray: #5f6368;
    --google-gray-hover: #494c50;

    /* High-contrast Typography Colors */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-muted: #80868b;

    --font-heading: 'Tajawal', sans-serif;
    --font-body: 'Cairo', sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 9999px;
    --shadow-subtle: 0 1px 3px rgba(60, 64, 67, 0.12), 0 1px 2px rgba(60, 64, 67, 0.08);
    --shadow-elevated: 0 4px 12px rgba(60, 64, 67, 0.15), 0 1px 3px rgba(60, 64, 67, 0.1);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--google-bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    direction: rtl;
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ==========================================================================
   Header & App Navigation
   ========================================================================== */
.app-header {
    background: var(--google-surface);
    border-bottom: 1px solid var(--google-border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo-badge {
    width: 38px;
    height: 38px;
    background: #e8f0fe;
    color: var(--google-blue);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: var(--google-blue);
    display: flex;
    align-items: center;
    gap: 6px;
}

.google-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.dot-blue { width: 6px; height: 6px; border-radius: 50%; background: var(--google-blue); }
.dot-red { width: 6px; height: 6px; border-radius: 50%; background: var(--google-red); }
.dot-yellow { width: 6px; height: 6px; border-radius: 50%; background: var(--google-yellow); }
.dot-green { width: 6px; height: 6px; border-radius: 50%; background: var(--google-green); }

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

.btn-google-pill {
    background: var(--google-surface);
    border: 1px solid var(--google-border);
    color: var(--text-primary);
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-google-pill:hover {
    background: var(--google-surface-variant);
    border-color: #bdc1c6;
}

/* ==========================================================================
   Main Container & Hero
   ========================================================================== */
.main-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
    min-height: calc(100vh - 65px);
}

.platform-hero {
    text-align: center;
    margin: 20px 0 26px 0;
}

.platform-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 900;
    color: #1a73e8;
    margin-bottom: 6px;
    text-shadow: 0 1px 2px rgba(26, 115, 232, 0.12);
}

.platform-subtitle {
    font-size: 14.5px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* View Sections */
.view-section {
    display: none;
    animation: fadeIn 0.2s ease-in-out;
}
.view-section.active {
    display: block;
}

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

/* ==========================================================================
   STEP 1: TOOLS SELECTION (مطابق للقطة الشاشة 1)
   ========================================================================== */
.tools-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 580px;
    margin: 24px auto;
}

.tool-card {
    background: #ffffff;
    border: 3px solid #ff9800;
    border-radius: var(--radius-sm);
    padding: 18px 24px;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    color: #111827;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(255, 152, 0, 0.12);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 152, 0, 0.22);
    background: #fffdfa;
}

.tool-card.active {
    border-color: #1a73e8;
    background: #f0f7ff;
    color: #1a73e8;
    box-shadow: 0 4px 14px rgba(26, 115, 232, 0.25);
}

.tool-card.disabled {
    border-color: #cbd5e1;
    color: #94a3b8;
    background: #f8fafc;
    box-shadow: none;
    cursor: not-allowed;
}
.tool-card.disabled:hover {
    transform: none;
    background: #f8fafc;
}

.tool-badge-disabled {
    position: absolute;
    left: 14px;
    font-size: 11.5px;
    color: #64748b;
    background: #e2e8f0;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
}

/* ==========================================================================
   STEP 2: LEVELS SELECTION (مطابق للقطة الشاشة 2)
   ========================================================================== */
.levels-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 580px;
    margin: 24px auto;
}

.level-card {
    border-radius: var(--radius-sm);
    padding: 16px 24px;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    border: 2px solid transparent;
}

/* 1AM */
.level-card.level-1am {
    background: #fee2e2;
    border-color: #ef4444;
    color: #111827;
    box-shadow: 0 3px 10px rgba(239, 68, 68, 0.15);
}
.level-card.level-1am:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.25);
}

/* 2AM */
.level-card.level-2am {
    background: #f3e8ff;
    border-color: #a855f7;
    color: #111827;
    box-shadow: 0 3px 10px rgba(168, 85, 247, 0.15);
}
.level-card.level-2am:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(168, 85, 247, 0.25);
}

/* 3AM */
.level-card.level-3am {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #111827;
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.15);
}
.level-card.level-3am:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.25);
}

/* 4AM */
.level-card.level-4am {
    background: #dcfce7;
    border-color: #22c55e;
    color: #111827;
    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.15);
}
.level-card.level-4am:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.25);
}

.level-card.disabled {
    cursor: not-allowed;
    opacity: 0.85;
}
.level-card.disabled:hover {
    transform: none;
}

.level-card.active {
    box-shadow: 0 0 0 3px #1a73e8, 0 6px 18px rgba(26, 115, 232, 0.28) !important;
    transform: translateY(-2px);
}

.back-btn-row {
    text-align: center;
    margin-top: 18px;
}

.btn-back-step {
    background: var(--google-surface);
    border: 1px solid var(--google-border);
    color: var(--text-secondary);
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-back-step:hover {
    background: var(--google-surface-variant);
    color: var(--text-primary);
}

/* ==========================================================================
   STEP 3: EXERCISES & COMPETENCIES CONFIGURATION (مطابق للقطة الشاشة 3)
   ========================================================================== */
.config-wrapper {
    background: var(--google-surface);
    border: 1px solid var(--google-border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-card);
    max-width: 680px;
    margin: 0 auto;
}

.config-header {
    text-align: center;
    margin-bottom: 22px;
}

.config-header h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.config-header p {
    font-size: 13.5px;
    color: var(--text-secondary);
}

.exercises-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.exercise-config-row {
    background: #ffffff;
    border: 2px solid #ff9800;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.2s ease;
}

.exercise-config-row:hover {
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.12);
}

.exo-name-label, .exo-name {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 900;
    color: #111827;
}

.selected-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.comp-tag {
    font-size: 11px;
    background: #f5f3ff;
    color: #7c3aed;
    border: 1px solid #ddd6fe;
    border-radius: var(--radius-pill);
    padding: 2px 8px;
    font-weight: 700;
}

.exo-controls-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-select-comps, .btn-select-lessons {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-select-comps:hover, .btn-select-lessons:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.4);
}

.btn-delete-slot, .btn-delete-exo {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 17px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}
.btn-delete-slot:hover, .btn-delete-exo:hover {
    background: #fee2e2;
}

.btn-reorder {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    color: #4b5563;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}
.btn-reorder:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.add-exo-wrapper {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0 18px 0;
}

.btn-add-exo {
    background: #22c55e;
    color: #ffffff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.35);
    transition: all 0.2s ease;
}
.btn-add-exo:hover {
    transform: scale(1.06);
    background: #16a34a;
}

/* Worksheet Mode Option Card (Step 3) */
.worksheet-option-card {
    background: #f0f7ff;
    border: 1.5px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}
.worksheet-option-card:hover {
    border-color: var(--google-blue);
    background: #e8f0fe;
}
.worksheet-option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    width: 100%;
}
.worksheet-checkbox-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}
.worksheet-checkbox {
    width: 22px;
    height: 22px;
    accent-color: var(--google-blue);
    cursor: pointer;
}
.worksheet-checkbox-sm {
    width: 17px;
    height: 17px;
    accent-color: var(--google-blue);
    cursor: pointer;
}
.worksheet-option-info {
    flex: 1;
}
.worksheet-option-title {
    font-size: 15.5px;
    font-weight: 800;
    color: #1e3a8a;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.badge-worksheet-hint {
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-weight: 700;
}
.worksheet-option-desc {
    font-size: 12.5px;
    color: #475569;
    line-height: 1.4;
}

.customizer-worksheet-toggle {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 3px 8px;
    border-radius: 6px;
}
.quick-worksheet-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: #1e40af;
    cursor: pointer;
}

.btn-generate-now {
    width: 100%;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-generate-now:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

/* ==========================================================================
   STEP 4: RESULT, PREVIEW, TYPOGRAPHY & CONTROLS (مطابق للقطة الشاشة 5)
   ========================================================================== */
.result-header {
    text-align: center;
    margin-bottom: 18px;
}

.result-header h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 900;
    color: var(--text-primary);
}

.result-header p {
    font-size: 13.5px;
    color: var(--text-secondary);
}

.preview-and-actions-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 900px;
    margin: 0 auto;
}

.preview-pane-wrapper {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Page & Typography & PDF Settings Toolbar */
.page-customizer-toolbar {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 14px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.customizer-toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.customizer-section-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.customizer-items-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.customizer-toolbar-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 2px 0;
}

.customizer-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customizer-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

.customizer-select {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.customizer-select:focus {
    border-color: var(--google-blue);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.customizer-input {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    min-width: 150px;
    transition: all 0.2s ease;
}
.customizer-input:focus {
    border-color: var(--google-blue);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.customizer-toggle-badge {
    background: #f8fafc;
    border: 1px solid var(--google-border);
    padding: 3px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}
.customizer-toggle-badge:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.btn-autofit-pill {
    background: #e8f0fe !important;
    border-color: #bfdbfe !important;
    color: var(--google-blue) !important;
    font-weight: 800 !important;
}
.btn-autofit-pill:hover {
    background: #d2e3fc !important;
}

/* Mobile Scroll Hint & Zoom Toolbar */
.preview-view-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 12.5px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 8px;
}

.mobile-scroll-hint {
    color: var(--google-blue);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-zoom {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: var(--radius-pill);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}
.btn-zoom.active, .btn-zoom:hover {
    background: #e8f0fe;
    border-color: var(--google-blue);
    color: var(--google-blue);
}

/* Paper Sheet Container (Mobile-Safe Horizontal Scroll) */
.paper-sheet-container {
    background: #e9ecef;
    padding: 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Paper Sheet strictly matching A4 dimensions and PDF output */
.paper-sheet {
    background: #ffffff;
    color: #111827;
    width: 210mm;
    min-width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
    box-sizing: border-box;
    padding: 10mm;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    position: relative;
    direction: rtl;
    transform-origin: top center;
    transition: transform 0.2s ease;
}

/* ==========================================================================
   Paper Sheet Algerian Official Headers & Layout Styles
   ========================================================================== */
.paper-sheet .page {
    position: relative;
    min-height: auto;
    padding-bottom: 4mm;
}
.paper-sheet .font-bold { font-weight: bold; }
.paper-sheet .text-center { text-align: center; }
.paper-sheet .text-right { text-align: right; }
.paper-sheet .text-left { text-align: left; }
.paper-sheet .mb-1 { margin-bottom: 3px; }

/* Official Algerian Standard Header (Screenshot 5 Match) */
.paper-sheet .official-header { margin-bottom: 10px; }
.paper-sheet .template-algerian-standard .header-national {
    font-size: 13px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
}
.paper-sheet .algerian-header-box {
    border-top: 1.5px solid #111827;
    border-bottom: 1.5px solid #111827;
    padding: 4px 6px;
    margin: 5px 0 8px 0;
    font-size: 13px;
    line-height: 1.45;
}
.paper-sheet .header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2px 0;
}
.paper-sheet .header-col-right {
    text-align: right;
    width: 58%;
}
.paper-sheet .header-col-left {
    text-align: left;
    width: 42%;
}
.paper-sheet .header-row-bottom {
    border-top: 1px dotted #9ca3af;
    padding-top: 4px;
    margin-top: 4px;
}
.paper-sheet .score-box {
    display: inline-block;
    border: 1px solid #111827;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: bold;
    background: #ffffff;
}
.paper-sheet .exam-title-centered {
    font-size: 16px;
    font-weight: 900;
    color: #111827;
    margin: 6px 0 10px 0;
    text-align: center;
}
.paper-sheet .exam-title-centered .exam-title-text {
    display: inline-block;
    border-bottom: 2px solid #111827;
    padding-bottom: 2px;
}

/* Template 2: Table Header */
.paper-sheet .template-clean-table .algerian-table-header {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 8px;
}
.paper-sheet .template-clean-table .algerian-table-header td {
    border: 1.5px solid #111827;
    padding: 4px 6px;
    vertical-align: middle;
}
.paper-sheet .template-clean-table .table-republic-text { font-size: 10px; color: #4b5563; font-weight: bold; }
.paper-sheet .template-clean-table .table-exam-title { font-size: 14px; color: #111827; margin: 2px 0; font-weight: 900; }
.paper-sheet .template-clean-table .table-grade-text { font-size: 11.5px; font-weight: bold; }
.paper-sheet .template-clean-table .table-score-box {
    border: 1px solid #111827;
    padding: 2px;
    margin-top: 3px;
    font-weight: bold;
    text-align: center;
}
.paper-sheet .template-clean-table .table-student-row { background: #f9fafb; font-size: 11.5px; }

/* Template 3: Compact Header */
.paper-sheet .template-compact {
    border-bottom: 1.5px solid #111827;
    padding-bottom: 4px;
    margin-bottom: 10px;
    font-size: 12px;
}
.paper-sheet .template-compact .compact-top-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.paper-sheet .template-compact .compact-title {
    font-size: 14px;
    background: #f3f4f6;
    padding: 2px 8px;
    border: 1px solid #374151;
    border-radius: 3px;
}
.paper-sheet .template-compact .compact-bottom-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3px;
}
.paper-sheet .template-compact .compact-score { font-weight: bold; }

/* Template 4: Framed Header */
.paper-sheet .template-framed .frame-outer {
    border: 1.5px solid #111827;
    padding: 5px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}
.paper-sheet .template-framed .framed-title {
    font-size: 14.5px;
    margin: 3px 0;
}
.paper-sheet .template-framed .framed-title span {
    border-bottom: 1.5px solid #111827;
    padding-bottom: 1px;
}
.paper-sheet .border-top-dotted { border-top: 1px dotted #9ca3af; }
.paper-sheet .pt-1 { padding-top: 3px; }

/* Template 5: Minimal Divider Header */
.paper-sheet .template-minimal-divider .minimal-divider-line {
    height: 1.5px;
    background: #111827;
    margin: 4px 0;
}
.paper-sheet .header-split-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 2px 0;
    font-size: 12.5px;
}

/* Dedicated Series Header (سلاسل التمارين والدعم) */
.paper-sheet .template-series-header, .template-series-header {
    margin-bottom: 12px;
}
.paper-sheet .series-header-box, .series-header-box {
    border: 1.5px solid #2563eb;
    border-radius: 6px;
    background: #f8faff;
    padding: 8px 12px;
    text-align: center;
}
.paper-sheet .series-title-row, .series-title-row {
    font-size: 16px;
    color: #1d4ed8;
    margin-bottom: 6px;
    font-weight: 800;
}
.paper-sheet .series-meta-row, .series-meta-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-size: 12px;
    color: #1e3a8a;
    border-top: 1px dashed #bfdbfe;
    padding-top: 5px;
    flex-wrap: wrap;
    gap: 8px;
}

/* Series 2-Column Continuous Flow Layout (العمود الثاني يكمل العمود 1) */
.paper-sheet .series-columns-container, .series-columns-container {
    column-count: 2;
    column-gap: 6mm;
    column-rule: 1px dashed #cbd5e1;
    width: 100%;
    text-align: right;
    box-sizing: border-box;
}
.paper-sheet .series-columns-container .exercise, .series-columns-container .exercise {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 6px 8px;
    box-sizing: border-box;
}
.paper-sheet .series-columns-container .exo-title, .series-columns-container .exo-title {
    font-size: 13.5px;
    color: #1e40af;
    margin-bottom: 3px;
    text-decoration: none;
    border-bottom: 1.5px solid #3b82f6;
    display: inline-block;
    padding-bottom: 1px;
}
.paper-sheet .series-columns-container .question, .series-columns-container .question {
    margin-bottom: 3px;
    line-height: inherit;
}
.paper-sheet .series-columns-container .img-container img, .series-columns-container .img-container img {
    max-height: 32mm;
    max-width: 95%;
}

/* Series Inline Solution (الحل تحت كل تمرين مباشرة) */
.paper-sheet .series-inline-solution, .series-inline-solution {
    margin-top: 6px;
    padding: 6px 8px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 4px;
    font-size: 12px;
}
.paper-sheet .inline-sol-badge, .inline-sol-badge {
    color: #15803d;
    font-weight: 800;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}
.paper-sheet .inline-sol-content, .inline-sol-content {
    color: #166534;
    line-height: 1.4;
}

/* A4 Multi-page Divider with dashed line */
.a4-page-break-divider {
    margin: 24px -10mm;
    border-top: 2px dashed #94a3b8;
    text-align: center;
    position: relative;
    height: 1px;
    display: block;
}
.a4-divider-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #f1f5f9;
    border: 1px dashed #64748b;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 14px;
    border-radius: 12px;
    white-space: nowrap;
}
@media print {
    .a4-page-break-divider {
        break-before: page !important;
        page-break-before: always !important;
        border: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .a4-divider-badge {
        display: none !important;
    }
}

/* Exercises in Sheet */
.paper-sheet .exercise {
    margin-bottom: 12px;
    page-break-inside: auto;
    break-inside: auto;
}
.paper-sheet .exo-title {
    font-weight: 900;
    color: #b91c1c;
    font-size: 15px;
    margin-bottom: 4px;
    text-decoration: underline;
    text-underline-offset: 3px;
    page-break-after: avoid;
    break-after: avoid;
}
.paper-sheet .question {
    margin-bottom: 4px;
    page-break-inside: auto;
    break-inside: auto;
}
.paper-sheet .img-container {
    margin: 4px auto;
    text-align: center;
}
.paper-sheet .img-container img {
    max-width: 80%;
    max-height: 48mm;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

/* Worksheet Student Dotted Lines in Sheet */
.paper-sheet .worksheet-student-lines, .worksheet-student-lines {
    margin: 6px 0 10px 0;
    padding-right: 14px;
    padding-left: 6px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}
.paper-sheet .worksheet-dot-line, .worksheet-dot-line {
    width: 100%;
    height: 22px;
    border-bottom: 1.5px dotted #6b7280;
    margin-bottom: 4px;
    display: block;
}

/* Solutions in Sheet */
.paper-sheet .sol-exercise {
    margin-bottom: 12px;
    border-bottom: 1px dashed #9ca3af;
    padding-bottom: 5px;
}
.paper-sheet .sol-title { color: #047857; text-decoration: none; font-size: 14.5px; }
.paper-sheet .sol-header-box {
    border: 1.5px solid #047857;
    background: #ecfdf5;
    color: #065f46;
    font-size: 15px;
    font-weight: bold;
    padding: 5px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
}
.paper-sheet .step-text { margin-bottom: 4px; }

/* Official Algerian Grading Rubric Table (شبكة التصحيح وسلم التنقيط) */
.grading-rubric-container {
    width: 100%;
    margin: 8px 0;
    direction: rtl;
    text-align: right;
    page-break-inside: auto;
}
.grading-doc-title {
    font-size: 16px;
    font-weight: 900;
    color: #1e3a8a;
    text-align: center;
    margin-bottom: 10px;
    text-decoration: underline;
}
.grading-rubric-table {
    width: 100%;
    border-collapse: collapse;
    border: 2px solid #000;
    background: #fff;
    font-size: 13px;
}
.grading-rubric-table th, .grading-rubric-table td {
    border: 1px solid #000;
    padding: 6px 8px;
    vertical-align: middle;
}
.grading-rubric-table thead tr {
    background-color: #D8D0E3 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.grading-rubric-table th {
    font-weight: bold;
    color: #000;
    text-align: center;
    padding: 6px 4px;
}
.grading-rubric-table .th-exo-num { width: 9%; }
.grading-rubric-table .th-exo-sol { width: 73%; }
.grading-rubric-table .th-score-main { width: 18%; }
.grading-rubric-table .th-score-part { width: 9%; }
.grading-rubric-table .th-score-tot { width: 9%; }

.grading-rubric-table .cell-exo-num {
    font-size: 26px;
    font-weight: 900;
    color: #7C3AED;
    text-align: center;
    vertical-align: middle;
    background: #faf5ff;
}
.grading-rubric-table .cell-exo-tot {
    font-size: 16px;
    font-weight: 900;
    color: #991B1B;
    text-align: center;
    vertical-align: middle;
    background: #fff;
}
.grading-rubric-table .cell-score-part {
    font-size: 14px;
    font-weight: bold;
    color: #DC2626;
    text-align: center;
    vertical-align: middle;
    background: #fff;
}
.grading-rubric-table .cell-exo-sol {
    vertical-align: top;
    text-align: right;
    padding: 6px 10px;
    line-height: 1.5;
}
.grading-rubric-table .sol-q-title {
    color: #991B1B;
    font-weight: bold;
    font-size: 13.5px;
    margin-bottom: 3px;
}
.grading-rubric-table .sol-q-step {
    margin: 2px 0;
    color: #0f172a;
}
.grading-rubric-table .sol-q-step.centered {
    text-align: center;
    margin: 3px 0;
}
.grading-rubric-table .sol-q-result {
    color: #16A34A;
    font-weight: bold;
    margin-top: 3px;
}
.grading-rubric-table tr.exo-boundary-row > td {
    border-top: 2px solid #000 !important;
}
.paper-sheet .page-footer {
    margin-top: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    border-top: 1px solid #d1d5db;
    padding-top: 3px;
    color: #4b5563;
}

/* Two Columns in Sheet */
.paper-sheet .two-columns-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    width: 100%;
}
.paper-sheet .half-page-exam {
    width: 48%;
    position: relative;
    padding-bottom: 10px;
    font-size: 12px;
}
.paper-sheet .cut-divider {
    width: 4%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.paper-sheet .cut-divider::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    border-left: 1.5px dashed #6b7280;
}
.paper-sheet .cut-icon {
    background: #ffffff;
    padding: 3px 0;
    font-size: 13px;
    color: #4b5563;
    z-index: 2;
    transform: rotate(90deg);
}

/* ==========================================================================
   Action Buttons Panel (مطابق تماماً للقطة الشاشة 5)
   ========================================================================== */
.action-buttons-panel {
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.download-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.btn-action-primary {
    width: 100%;
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 18px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    text-align: center;
}

.btn-download-pdf { background: #d93025; color: #ffffff; }
.btn-download-pdf:hover { background: #b3261e; transform: translateY(-1px); }

.btn-download-word { background: #1a73e8; color: #ffffff; }
.btn-download-word:hover { background: #1557b0; transform: translateY(-1px); }

.btn-regenerate-exam { background: #7c3aed; color: #ffffff; }
.btn-regenerate-exam:hover { background: #6d28d9; transform: translateY(-1px); }

.btn-edit-exam { background: #2e7d32; color: #ffffff; }
.btn-edit-exam:hover { background: #1b5e20; transform: translateY(-1px); }

.btn-random-exam { 
    background: #e2e8f0; 
    color: #1e293b; 
    border: 1px solid #cbd5e1;
}
.btn-random-exam:hover { background: #cbd5e1; transform: translateY(-1px); }

.btn-pdf-settings {
    background: #ffffff;
    border: 1px solid var(--google-border);
    color: var(--text-primary);
}
.btn-pdf-settings:hover {
    background: #f8f9fa;
    border-color: #f59e0b;
    color: #b45309;
}

/* Dedicated Editor Bottom Bar Buttons */
.btn-editor-regen {
    background: #1a73e8;
    color: #ffffff;
    width: auto;
    padding: 9px 18px;
    font-size: 13.5px;
}
.btn-editor-regen:hover {
    background: #1557b0;
    transform: translateY(-1px);
}

.btn-editor-comps {
    background: #7c3aed;
    color: #ffffff;
    width: auto;
    padding: 9px 18px;
    font-size: 13.5px;
}
.btn-editor-comps:hover {
    background: #6d28d9;
    transform: translateY(-1px);
}

.btn-editor-done {
    background: #2e7d32;
    color: #ffffff;
    width: auto;
    padding: 9px 20px;
    font-size: 14px;
}
.btn-editor-done:hover {
    background: #1b5e20;
    transform: translateY(-1px);
}

/* ==========================================================================
   FULLSCREEN MOBILE/DESKTOP EDITOR (مثل تطبيقات الهاتف)
   ========================================================================== */
.fullscreen-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #ffffff;
    display: none;
    flex-direction: column;
    overflow-y: auto;
}

.fullscreen-editor-overlay.active {
    display: flex;
    animation: fullScreenSlideUp 0.2s ease forwards;
}

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

.fullscreen-appbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f8f9fa;
    border-bottom: 1px solid var(--google-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.appbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-back-appbar {
    background: #ffffff;
    border: 1px solid var(--google-border);
    color: var(--text-primary);
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.btn-back-appbar:hover {
    background: #e8f0fe;
    border-color: var(--google-blue);
    color: var(--google-blue);
}

.appbar-title {
    font-size: 17px;
    font-weight: 800;
    color: #111827;
}

.auto-save-badge {
    font-size: 12px;
    color: #16a34a;
    background: #dcfce7;
    border: 1px solid #86efac;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 700;
}

/* Item Selector Bar (Dropdown: التمرين 1، حل التمرين 1، ...) */
.fullscreen-chips-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--google-border);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.editor-select-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 260px;
}

.editor-select-label {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.editor-slot-select {
    background: #ffffff;
    border: 1.5px solid var(--google-border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    outline: none;
    cursor: pointer;
    flex: 1;
    max-width: 320px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: all 0.2s ease;
}

.editor-slot-select:focus {
    border-color: var(--google-blue);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.exo-mgmt-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-add-slot-pill {
    padding: 6px 12px !important;
    font-size: 12.5px !important;
    background: #e8f0fe !important;
    color: var(--google-blue) !important;
    border-color: #bfdbfe !important;
}
.btn-add-slot-pill:hover {
    background: #d2e3fc !important;
}

.btn-del-slot-pill {
    padding: 6px 12px !important;
    font-size: 12.5px !important;
    color: var(--google-red) !important;
}
.btn-del-slot-pill:hover {
    background: #fce8e6 !important;
    border-color: var(--google-red) !important;
}

.editor-bottom-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Suppress any red/pink MathLive command error markers */
math-field .ML__error,
math-field [error] {
    color: inherit !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
}

/* Ensure MathLive Virtual Keyboard displays above fullscreen overlay and modals */
math-virtual-keyboard,
.ML__keyboard,
div[data-ml-keyboard],
.MLK__backdrop,
.MLK__container,
.MLK__plate {
    z-index: 999999 !important;
}

/* Dedicated Slot Title Bar (Bold & Free Editing) */
.editor-slot-title-bar {
    background: #ffffff;
    border-bottom: 1px solid var(--google-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.slot-title-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 800;
    color: #b91c1c;
    white-space: nowrap;
}

.slot-title-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--google-border);
    border-radius: var(--radius-sm);
    color: #111827;
    font-family: var(--font-heading);
    font-size: 15.5px;
    font-weight: 800;
    padding: 7px 12px;
    outline: none;
    transition: all 0.2s ease;
}
.slot-title-input:focus {
    border-color: var(--google-blue);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.slot-points-chips {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.points-chips-label {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    white-space: nowrap;
}
.btn-point-chip {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn-point-chip:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
}

/* Editor Workspace Container */
.fullscreen-editor-body {
    flex: 1;
    padding: 16px;
    max-width: 950px;
    width: 100%;
    margin: 0 auto;
}

/* Sticky Bottom Bar */
.fullscreen-bottom-bar {
    position: sticky;
    bottom: 0;
    z-index: 90;
    background: #f8f9fa;
    border-top: 1px solid var(--google-border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

/* ==========================================================================
   Modals (Competencies & Settings)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: #ffffff;
    border: 2px solid #ff9800;
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

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

.modal-title { font-size: 17px; font-weight: 800; color: #111827; }

.modal-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
}
.modal-close-btn:hover { color: #ef4444; }

.modal-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--google-border);
    display: flex;
    justify-content: center;
    background: #fafafa;
}

.competency-item {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.15s ease;
}
.competency-item:hover { border-color: var(--google-blue); background: #f8fafc; }

.competency-item.selected {
    border-color: #7c3aed;
    background: #f5f3ff;
}

.competency-name { font-size: 14.5px; font-weight: 700; color: #1e293b; }

.comp-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.comp-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-toggle-masala {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    user-select: none;
}
.btn-toggle-masala:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
}
.btn-toggle-masala.active {
    background: linear-gradient(135deg, #f59e0b, #d97706) !important;
    color: #ffffff !important;
    border-color: #d97706 !important;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35) !important;
}

.btn-toggle-mored {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    user-select: none;
}
.btn-toggle-mored:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}
.btn-toggle-mored.active {
    background: linear-gradient(135deg, #0284c7, #0369a1) !important;
    color: #ffffff !important;
    border-color: #0369a1 !important;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35) !important;
}

.comp-tag-masala {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
    color: #92400e !important;
    font-weight: 800 !important;
}

.comp-tag-mored {
    background: #e0f2fe !important;
    border-color: #0284c7 !important;
    color: #0369a1 !important;
    font-weight: 800 !important;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
}

.competency-item.selected .custom-checkbox {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #ffffff;
}
.custom-checkbox::after {
    content: "✓";
    font-weight: 900;
    font-size: 13px;
    display: none;
}
.competency-item.selected .custom-checkbox::after { display: block; }

.btn-save-modal {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 30px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

/* Toast Notifications */
.loading-toast {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #ffffff;
    border: 1px solid var(--google-blue);
    color: #1e293b;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 4000;
    font-weight: 700;
    font-size: 13.5px;
}
.loading-toast.active { display: flex; }

.btn-back-modal-mobile {
    display: none;
    background: #ffffff;
    border: 1px solid var(--google-border);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   Responsive Adjustments for Mobile & Tablets
   ========================================================================== */
@media (max-width: 768px) {
    .app-header { padding: 8px 12px; gap: 8px; }
    .brand-title { font-size: 15px; }
    .nav-text { display: none; }
    .platform-title { font-size: 24px; }
    .platform-subtitle { font-size: 12.5px; }
    
    .tools-grid { max-width: 100%; padding: 0 6px; }
    .tool-card { font-size: 17px; padding: 14px 16px; }
    
    .levels-container { max-width: 100%; padding: 0 6px; }
    .level-card { font-size: 17px; padding: 13px 16px; }
    
    .config-wrapper { padding: 16px 12px; }
    .exercise-config-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .exo-controls-group { justify-content: space-between; }
    
    .page-customizer-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .customizer-group { justify-content: space-between; }
    
    /* Paper Sheet Mobile Horizontal Scroll & Safe Containment */
    .paper-sheet-container { 
        padding: 10px 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
    }
    .paper-sheet { 
        width: 210mm !important; 
        min-width: 210mm !important;
        margin: 0;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }

    /* Action Buttons strictly fitting within screen */
    .action-buttons-panel {
        width: 100%;
        max-width: 100%;
        padding: 14px 8px;
    }
    .btn-action-primary {
        font-size: 14.5px;
        padding: 12px;
    }

    /* Fullscreen Modals on Mobile: Looks like a new page filling the entire screen! */
    .btn-back-modal-mobile {
        display: inline-flex;
    }
    .modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }
    .modal-content {
        max-width: 100vw;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border: none;
        display: flex;
        flex-direction: column;
    }
    .modal-header {
        position: sticky;
        top: 0;
        background: #f8f9fa;
        z-index: 20;
        padding: 10px 14px;
        border-bottom: 1px solid var(--google-border);
    }
    .modal-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 14px;
    }
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: #f8f9fa;
        z-index: 20;
        padding: 10px 14px;
        border-top: 1px solid var(--google-border);
    }

    /* Fullscreen Editor on Mobile */
    .fullscreen-appbar { padding: 8px 10px; }
    .btn-back-appbar { padding: 6px 12px; font-size: 13px; }
    .editor-select-box { width: 100%; min-width: 100%; margin-bottom: 6px; }
    .editor-slot-select { max-width: 100%; width: 100%; }
    .exo-mgmt-tools { width: 100%; justify-content: space-between; }
    .editor-slot-title-bar { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 12px; }
    .fullscreen-editor-body { padding: 10px 8px; }
    
    .fullscreen-bottom-bar { 
        padding: 10px 12px; 
        flex-direction: column; 
        align-items: stretch; 
        gap: 8px; 
    }
    .editor-bottom-tools {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 8px;
    }
    .editor-bottom-tools .btn-action-primary {
        width: 100%;
        font-size: 13px;
        padding: 10px 6px;
        justify-content: center;
    }
    .btn-editor-done {
        width: 100%;
        justify-content: center;
        padding: 11px;
    }
}

/* ==========================================================================
   Header Elements Eye Toggle Buttons
   ========================================================================== */
.input-with-eye {
    display: inline-flex;
    align-items: center;
    position: relative;
}
.btn-toggle-eye {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 4px 6px;
    margin-right: -26px;
    z-index: 2;
    font-size: 13px;
    transition: color 0.15s ease, transform 0.15s ease;
}
.btn-toggle-eye:hover {
    color: #1a73e8;
    transform: scale(1.15);
}
.btn-toggle-eye.is-hidden {
    color: #cbd5e1;
}
.input-with-eye.is-hidden input {
    opacity: 0.45;
    text-decoration: line-through;
    background: #f1f5f9;
}

/* ==========================================================================
   Two-Columns Landscape Sheet (فرضين في صفحة واحدة A4)
   ========================================================================== */
.paper-sheet.two-columns-landscape {
    width: 297mm !important;
    min-width: 297mm !important;
    max-width: 297mm !important;
    min-height: 210mm !important;
}

/* ==========================================================================
   Official Algerian Grading Rubric Page (Pristine White Background)
   ========================================================================== */
.official-grading-page {
    background: #ffffff !important;
    min-height: 297mm;
    box-sizing: border-box;
    padding: 10mm;
    margin: 24px -10mm -10mm -10mm;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    border-radius: 2px;
    position: relative;
}
.paper-sheet.two-columns-landscape .official-grading-page {
    width: 210mm !important;
    max-width: 210mm !important;
    min-height: 297mm !important;
    margin: 40px auto 20px auto !important;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.15) !important;
    border-radius: 4px;
    background: #ffffff !important;
}
@media print {
    .official-grading-page {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: #ffffff !important;
        break-before: page !important;
        page-break-before: always !important;
    }
}

/* ==========================================================================
   Elegant Modern Feedback & Success Modal
   ========================================================================== */
.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.feedback-modal-overlay.active {
    display: flex;
    opacity: 1;
}
.feedback-modal-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 28px 32px;
    width: 90%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    direction: rtl;
    border: 1px solid rgba(226, 232, 240, 0.8);
}
.feedback-modal-overlay.active .feedback-modal-card {
    transform: scale(1);
}
.feedback-modal-icon-wrapper {
    width: 68px;
    height: 68px;
    margin: 0 auto 16px auto;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    transition: all 0.3s ease;
}
.feedback-modal-icon-wrapper.success {
    background: #dcfce7;
    color: #16a34a;
    box-shadow: 0 0 0 8px #f0fdf4;
}
.feedback-modal-icon-wrapper.info {
    background: #e0f2fe;
    color: #0284c7;
    box-shadow: 0 0 0 8px #f0f9ff;
}
.feedback-modal-icon-wrapper.error {
    background: #fee2e2;
    color: #dc2626;
    box-shadow: 0 0 0 8px #fef2f2;
}
.feedback-modal-icon-wrapper.warning {
    background: #fef3c7;
    color: #d97706;
    box-shadow: 0 0 0 8px #fffbeb;
}
.feedback-modal-title {
    font-size: 19px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 8px;
}
.feedback-modal-message {
    font-size: 14.5px;
    color: #475569;
    line-height: 1.55;
    margin-bottom: 22px;
}
.feedback-modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.btn-feedback-ok {
    background: #1a73e8;
    color: #ffffff;
    border: none;
    padding: 10px 32px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.btn-feedback-ok:hover {
    background: #1557b0;
    transform: translateY(-1px);
}


/* ==========================================================================
   Tool: مذكرات الاستدراك / معالجة
   ========================================================================== */
.istidrak-topic-card {
    background: #ffffff;
    border: 2px solid #0284c7;
    border-radius: var(--radius-sm, 10px);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.12);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.istidrak-topic-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.istidrak-topic-title {
    font-size: 15.5px;
    font-weight: 800;
    color: #0369a1;
}
.istidrak-topic-select {
    width: 100%;
    padding: 11px 14px;
    border-radius: 8px;
    border: 1.5px solid #38bdf8;
    background-color: #f0f9ff;
    color: #0c4a6e;
    font-family: var(--font-body, 'Cairo', sans-serif);
    font-size: 14.5px;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
    direction: rtl;
}
.istidrak-topic-select:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
    background-color: #ffffff;
}
.istidrak-topic-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #0284c7;
    font-weight: 500;
}
