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

        :root {
            --primary-color: #2c3e50;
            --secondary-color: #3498db;
            --accent-color: #e74c3c;
            --success-color: #27ae60;
            --warning-color: #f39c12;
            --info-color: #9b59b6;
            --geometry-blue: #3498db;
            --construction-green: #27ae60;
            --advanced-purple: #8e44ad;
            
            --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --gradient-geometry: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
            --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
            --gradient-warning: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
            --gradient-info: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
            --gradient-construction: linear-gradient(135deg, #27ae60 0%, #229954 100%);
            --gradient-advanced: linear-gradient(135deg, #8e44ad 0%, #9b59b6 100%);
            
            --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.08);
            --shadow-medium: 0 25px 80px rgba(0, 0, 0, 0.12);
            --shadow-strong: 0 30px 100px rgba(0, 0, 0, 0.15);
            --shadow-glow: 0 0 40px rgba(52, 152, 219, 0.3);
            --border-radius: 25px;
            --border-radius-small: 15px;
            --transition: all 0.6s cubic-bezier(0.23, 1, 0.320, 1);
            --transition-fast: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

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

        body {
            font-family: 'Cairo', 'Tajawal', sans-serif;
            line-height: 1.8;
            background: linear-gradient(135deg, #8e44ad 0%, #3498db 50%, #667eea 100%);
            background-attachment: fixed;
            min-height: 100vh;
            padding: 20px;
            font-size: 16px;
            color: #2c3e50;
            overflow-x: hidden;
            direction: rtl;
        }

        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: 
                radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(142, 68, 173, 0.05) 0%, transparent 50%);
            pointer-events: none;
            z-index: -1;
        }
/* À AJOUTER À LA TOUTE FIN de design_elegant.css */

/* === RÉPARATION CSS === */

/* Navigation entre exercices - Version finale  pour les exercices */
.exercise-navigation {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  align-items: center;
  background: rgba(255, 255, 255, 0.98);
  padding: 12px 25px;
  border-radius: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 1000;
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  max-width: calc(100vw - 40px);
}

.nav-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 25px;
  cursor: pointer;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

        .help-button, .generate-button {
            position: fixed;
            top: 100px;
            background: var(--gradient-advanced);
            color: white;
            border: none;
            padding: 12px 18px;
            border-radius: 30px;
            font-family: 'Cairo', sans-serif;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            box-shadow: var(--shadow-soft);
            transition: var(--transition-fast);
            z-index: 1000;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .help-button {
            right: 20px;
        }

        .generate-button {
            left: 20px;
            background: var(--gradient-construction);
        }

        .help-button:hover, .generate-button:hover {
            transform: translateY(-2px);
            box-shadow: var(--shadow-glow);
        }

        .help-panel {
            position: fixed;
            top: 70px;
            right: 20px;
            width: 520px;
            max-height: 0;
            overflow: hidden;
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow-strong);
            z-index: 999;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border: 2px solid rgba(142, 68, 173, 0.1);
        }

        .help-panel.show {
            max-height: 80vh;
            overflow-y: auto;
        }

        .help-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 25px;
            background: var(--gradient-advanced);
            color: white;
            border-top-left-radius: var(--border-radius);
            border-top-right-radius: var(--border-radius);
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .help-header h3 {
            margin: 0;
            font-size: 1.3em;
            font-weight: 700;
        }

        .close-help {
            background: transparent;
            border: none;
            color: white;
            font-size: 1.5em;
            cursor: pointer;
            padding: 0;
            width: 35px;
            height: 35px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: var(--transition-fast);
        }

        .close-help:hover {
            background: rgba(255, 255, 255, 0.2);
            transform: scale(1.1);
        }

        .help-content {
            padding: 25px;
            line-height: 1.7;
        }

        .help-section {
            margin-bottom: 30px;
            padding: 20px;
            background: rgba(142, 68, 173, 0.05);
            border-radius: var(--border-radius-small);
            border-right: 4px solid var(--advanced-purple);
        }

        .help-section h4 {
            color: var(--primary-color);
            font-size: 1.2em;
            font-weight: 700;
            margin-bottom: 15px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .theorem-box, .property-box, .method-box, .warning-box {
            background: white;
            padding: 18px;
            border-radius: 12px;
            margin: 15px 0;
            box-shadow: var(--shadow-soft);
            border-right: 4px solid;
        }

        .theorem-box {
            border-right-color: var(--info-color);
            background: linear-gradient(135deg, #f4f3ff 0%, #e8e5ff 100%);
        }

        .property-box {
            border-right-color: var(--success-color);
            background: linear-gradient(135deg, #e8f8f5 0%, #d1f2eb 100%);
        }

        .method-box {
            border-right-color: var(--warning-color);
            background: linear-gradient(135deg, #fef9e7 0%, #fcf4dd 100%);
        }

        .warning-box {
            border-right-color: var(--accent-color);
            background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
            position: relative;
        }

        .warning-box::before {
            content: '⚠️';
            position: absolute;
            top: -12px;
            right: 15px;
            background: white;
            padding: 5px;
            border-radius: 50%;
            font-size: 1.2em;
        }

        .math-container {
            max-width: 1400px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(20px);
            border-radius: var(--border-radius);
            padding: 60px;
            box-shadow: var(--shadow-strong);
            border: 1px solid rgba(255, 255, 255, 0.2);
            position: relative;
            overflow: hidden;
            animation: containerSlideIn 1s ease-out;
        }

        .math-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 8px;
            background: var(--gradient-advanced);
            background-size: 300% 100%;
            animation: gradientFlow 6s ease-in-out infinite;
        }

        @keyframes containerSlideIn {
            from {
                transform: translateY(50px) scale(0.95);
                opacity: 0;
            }
            to {
                transform: translateY(0) scale(1);
                opacity: 1;
            }
        }

        @keyframes gradientFlow {
            0%, 100% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
        }

        .math-header {
            text-align: center;
            margin-bottom: 60px;
            padding: 40px;
            background: rgba(142, 68, 173, 0.08);
            border-radius: var(--border-radius);
            position: relative;
            overflow: hidden;
        }

        .math-header h1 {
            color: var(--primary-color);
            font-size: 3.2em;
            font-weight: 800;
            margin-bottom: 20px;
            text-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            font-family: 'Amiri', serif;
        }

        .math-header .sub-header {
            font-size: 1.3em;
            color: #555;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 30px;
            font-weight: 600;
            flex-wrap: wrap;
            gap: 15px;
        }

        .math-header .sub-header span {
            padding: 12px 24px;
            background: rgba(255, 255, 255, 0.8);
            border-radius: var(--border-radius-small);
            box-shadow: var(--shadow-soft);
            transition: var(--transition-fast);
        }

        .chapter-display {
            background: linear-gradient(135deg, rgba(142, 68, 173, 0.1) 0%, rgba(52, 152, 219, 0.1) 100%);
            border-radius: 15px;
            padding: 25px;
            margin: 20px 0;
            border: 2px solid rgba(142, 68, 173, 0.2);
            text-align: center;
        }

        .geometry-symbol {
            font-size: 2em;
            font-weight: bold;
            color: var(--advanced-purple);
            margin: 10px 15px;
            display: inline-block;
            padding: 10px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.8);
            transition: var(--transition-fast);
        }

        .geometry-symbol:hover {
            background: var(--advanced-purple);
            color: white;
            transform: scale(1.1);
        }

        .exercises-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 40px;
            margin-bottom: 40px;
        }

        .exercise-card {
            background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
            border-radius: var(--border-radius);
            padding: 40px;
            box-shadow: var(--shadow-soft);
            border: 1px solid rgba(255, 255, 255, 0.8);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            transform: translateY(0);
        }

        .exercise-card:hover {
            transform: translateY(-8px) scale(1.02);
            box-shadow: var(--shadow-strong);
        }

        .exercise-card::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 6px;
            height: 100%;
            background: var(--gradient-advanced);
            transition: var(--transition-fast);
        }

        .exercise-card:hover::before {
            width: 12px;
            box-shadow: var(--shadow-glow);
        }

        .exercise-header {
            display: flex;
            align-items: center;
            gap: 25px;
            margin-bottom: 30px;
            padding-bottom: 25px;
            border-bottom: 3px solid rgba(142, 68, 173, 0.1);
            position: relative;
        }

        .exercise-title {
            color: var(--primary-color);
            font-size: 1.8em;
            font-weight: 700;
            flex-grow: 1;
            font-family: 'Amiri', serif;
        }

        .exercise-number {
            background: var(--gradient-advanced);
            color: white;
            padding: 12px 20px;
            border-radius: 50px;
            font-weight: 700;
            font-size: 1em;
            box-shadow: var(--shadow-soft);
            position: relative;
            overflow: hidden;
        }

        .exercise-content {
            color: #34495e;
            line-height: 2.2;
            margin-bottom: 30px;
            font-size: 1.1em;
        }

        .exercise-content p {
            margin-bottom: 18px;
        }

        .construction-steps {
            background: rgba(142, 68, 173, 0.05);
            padding: 20px;
            border-radius: var(--border-radius-small);
            margin: 15px 0;
            border-right: 4px solid var(--advanced-purple);
        }

        .step-item {
            margin: 12px 0;
            padding: 12px;
            background: white;
            border-radius: 8px;
            border-right: 3px solid var(--construction-green);
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .step-arrow {
            color: var(--construction-green);
            font-weight: bold;
            font-size: 1.2em;
        }

        .figure-display {
            background: #f8f9fa;
            border: 2px dashed var(--geometry-blue);
            border-radius: var(--border-radius-small);
            padding: 30px;
            margin: 20px 0;
            text-align: center;
            position: relative;
            min-height: 150px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .figure-display::before {
            content: '📐';
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 1.5em;
            opacity: 0.3;
        }

        .figure-line {
            width: 200px;
            height: 3px;
            background: var(--primary-color);
            margin: 10px 0;
            position: relative;
        }

        .figure-point {
            position: absolute;
            width: 8px;
            height: 8px;
            background: var(--accent-color);
            border-radius: 50%;
            top: -2.5px;
        }

        .question-list {
            margin: 20px 0;
        }

        .question-item {
            background: rgba(142, 68, 173, 0.03);
            padding: 15px;
            margin: 10px 0;
            border-radius: var(--border-radius-small);
            border-right: 3px solid var(--advanced-purple);
        }

        .special-note {
            background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
            border: 2px solid var(--warning-color);
            border-radius: var(--border-radius-small);
            padding: 20px;
            margin: 20px 0;
            position: relative;
        }

        .special-note::before {
            content: '📏';
            position: absolute;
            top: -12px;
            right: 15px;
            background: white;
            padding: 5px;
            border-radius: 50%;
            font-size: 1.2em;
        }

        .progress-stats {
            background: linear-gradient(135deg, rgba(142, 68, 173, 0.1) 0%, rgba(39, 174, 96, 0.1) 100%);
            padding: 20px;
            border-radius: var(--border-radius-small);
            margin: 30px 0;
            text-align: center;
            border: 2px solid rgba(142, 68, 173, 0.2);
            position: relative;
            overflow: hidden;
        }

        .progress-indicator {
            display: flex;
            gap: 12px;
            justify-content: center;
            margin-bottom: 15px;
        }

        .progress-dot {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #e0e0e0;
            transition: var(--transition);
            position: relative;
            cursor: pointer;
        }

        .progress-dot.active {
            background: var(--gradient-advanced);
            transform: scale(1.3);
            box-shadow: 0 0 20px rgba(142, 68, 173, 0.4);
        }

        .progress-buttons {
            display: flex;
            gap: 20px;
            margin: 35px 0;
            flex-wrap: wrap;
            justify-content: center;
        }

        .progress-btn {
            font-family: 'Cairo', sans-serif;
            border: none;
            padding: 16px 32px;
            border-radius: 50px;
            cursor: pointer;
            font-size: 15px;
            font-weight: 700;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            min-width: 160px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 12px;
            text-transform: none;
            box-shadow: var(--shadow-soft);
        }

        .progress-btn:hover:not(:disabled) {
            transform: translateY(-4px) scale(1.05);
        }

        .progress-btn:disabled {
            opacity: 0.7;
            cursor: not-allowed;
            transform: none !important;
        }

        .btn-hint {
            background: var(--gradient-success);
            color: white;
            box-shadow: 0 8px 30px rgba(79, 172, 254, 0.4);
        }

        .btn-method {
            background: var(--gradient-warning);
            color: white;
            box-shadow: 0 8px 30px rgba(250, 112, 154, 0.4);
        }

        .btn-solution {
            background: var(--gradient-info);
            color: white;
            box-shadow: 0 8px 30px rgba(155, 89, 182, 0.4);
        }

        .btn-reset {
            background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
            color: white;
            box-shadow: 0 8px 30px rgba(149, 165, 166, 0.4);
        }

        .correction-section {
            display: none !important;
            margin: 30px 0;
            padding: 35px;
            border-radius: var(--border-radius);
            position: relative;
            overflow: hidden;
            animation: sectionSlideIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            box-shadow: var(--shadow-medium);
            border: 2px solid transparent;
        }

        .correction-section.visible {
            display: block !important;
        }

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

        .correction-section::before {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 8px;
            height: 100%;
            border-radius: 4px;
        }

        .correction-hint {
            background: linear-gradient(135deg, #e8f8f5 0%, #d1f2eb 100%);
            border-color: #27ae60;
            color: #0e6b3a;
        }

        .correction-hint::before {
            background: var(--gradient-success);
        }

        .correction-hint h4 {
            color: #27ae60;
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 20px;
            font-size: 1.4em;
            font-weight: 700;
        }

        .correction-method {
            background: linear-gradient(135deg, #fef9e7 0%, #fcf4dd 100%);
            border-color: #f39c12;
            color: #b7950b;
        }

        .correction-method::before {
            background: var(--gradient-warning);
        }

        .correction-method h4 {
            color: #f39c12;
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 20px;
            font-size: 1.4em;
            font-weight: 700;
        }

        .correction-solution {
            background: linear-gradient(135deg, #f4f3ff 0%, #e8e5ff 100%);
            border-color: #9b59b6;
            color: #6c3483;
        }

        .correction-solution::before {
            background: var(--gradient-info);
        }

        .correction-solution h4 {
            color: #9b59b6;
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 20px;
            font-size: 1.4em;
            font-weight: 700;
        }

        /* تحسينات للجوال */
        @media (max-width: 768px) {
            .math-container {
                padding: 30px 20px;
                margin: 10px;
            }
            
            .math-header h1 {
                font-size: 2.5em;
            }
            
            .math-header .sub-header {
                flex-direction: column;
                gap: 15px;
                padding: 0;
            }
            
            .progress-buttons {
                flex-direction: column;
                align-items: center;
            }
            
            .progress-btn {
                width: 100%;
                max-width: 280px;
            }
            
            .help-button, .generate-button {
                top: 15px;
                padding: 8px 12px;
                font-size: 12px;
            }

            .help-panel {
                top: 60px;
                right: 10px;
                left: 10px;
                width: auto;
                max-width: calc(100vw - 20px);
            }

            .geometry-symbol {
                font-size: 1.5em;
                margin: 5px 8px;
            }

            .figure-display {
                padding: 20px;
                min-height: 120px;
            }

            .figure-line {
                width: 150px;
            }
        }