/* ============================================================
   devoirati-3etapes.css
   Feuille de la famille « 3 etapes ».
   Extraite de 7eme/Puissances/3etapes/anap/FactorPuiss2.html (page modele
   choisie par le chef). Palette indigo #3f51b5 / #667eea conservee.
   A charger APRES basic.css. Remplace le <style> en ligne des pages.
   ============================================================ */

/* ---------- bloc 1 du modele ---------- */
:root {
            --primary-color: #3498db;
            --gradient-primary: linear-gradient(135deg, #3498db, #2980b9);
            --border-radius: 12px;
            --shadow-soft: 0 4px 6px rgba(0, 0, 0, 0.1);
            --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
            --transition: all 0.3s ease;
        }
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 20px;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 200vh;
        }
        .main-content {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 40px;
            border-radius: var(--border-radius);
            box-shadow: var(--shadow-soft);
        }
        h1 {
            color: var(--primary-color);
            text-align: center;
            margin-bottom: 30px;
        }
        .help-button {
            position: fixed;
            top: 20px;
            left: 20px;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background: var(--gradient-primary);
            color: white;
            border: none;
            font-size: 1.8em;
            font-weight: bold;
            cursor: pointer;
            box-shadow: var(--shadow-soft);
            transition: var(--transition);
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .help-button:hover {
            transform: scale(1.1);
            box-shadow: var(--shadow-hover);
        }
        .help-panel {
            position: fixed;
            top: 80px;
            left: 20px;
            width: 320px;
            max-height: 400px;
            background: white;
            border-radius: var(--border-radius);
            padding: 0;
            box-shadow: var(--shadow-hover);
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: var(--transition);
            overflow: hidden;
        }
        .help-panel.show {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        .help-panel-content {
            padding: 20px;
            max-height: 360px;
            overflow-y: auto;
            overflow-x: hidden;
            direction: rtl;
        }
        .help-panel-content::-webkit-scrollbar {
            width: 8px;
        }
        .help-panel-content::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 4px;
        }
        .help-panel-content::-webkit-scrollbar-thumb {
            background: var(--primary-color);
            border-radius: 4px;
        }
        .help-panel-content::-webkit-scrollbar-thumb:hover {
            background: #2980b9;
        }
        .help-panel h3 {
            color: var(--primary-color);
            margin-bottom: 15px;
            text-align: center;
            margin-top: 0;
        }
        .help-panel h4 {
            color: #2c3e50;
            margin: 20px 0 10px 0;
            font-size: 1.1em;
        }
        .help-panel h5 {
            color: #e74c3c;
            margin: 15px 0 8px 0;
            font-size: 1em;
        }
        .help-panel p {
            line-height: 1.6;
            margin-bottom: 10px;
        }
        .help-panel ol {
            padding-right: 20px;
            margin: 10px 0;
        }
        .help-panel li {
            margin-bottom: 8px;
        }
        .help-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 998;
            background: transparent;
            display: none;
        }
        .help-overlay.show {
            display: block;
        }
        
        /* Styles pour les sections du panneau d'aide */
        .math-rule {
            background: #e8f4f8;
            border: 2px solid var(--primary-color);
            border-radius: 8px;
            padding: 15px;
            margin: 15px 0;
            text-align: center;
        }
        
        .example-section {
            background: rgba(52, 152, 219, 0.1);
            border-right: 3px solid var(--primary-color);
            padding: 12px;
            margin: 12px 0;
            border-radius: 5px;
        }
        
        .warning-section {
            background: rgba(231, 76, 60, 0.1);
            border-right: 3px solid #e74c3c;
            padding: 12px;
            margin: 12px 0;
            border-radius: 5px;
        }
        
        .exercise-list {
            background: rgba(155, 89, 182, 0.1);
            border-right: 3px solid #9b59b6;
            padding: 12px;
            margin: 12px 0;
            border-radius: 5px;
        }
        
        .application-section {
            background: rgba(39, 174, 96, 0.1);
            border-right: 3px solid #27ae60;
            padding: 12px;
            margin: 12px 0;
            border-radius: 5px;
        }
        
        .complementary-rules {
            background: rgba(243, 156, 18, 0.1);
            border-right: 3px solid #f39c12;
            padding: 12px;
            margin: 12px 0;
            border-radius: 5px;
        }
        
        .final-tip {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px;
            margin: 15px 0;
            border-radius: 8px;
            text-align: center;
        }
        
        /* Styles pour MathJax */
        .help-panel-content .MathJax,
        .help-panel-content .MathJax_Display,
        .help-panel-content mjx-container {
            direction: ltr !important;
            text-align: left !important;
        }
        
        /* Responsive */
        @media (max-width: 768px) {
            .help-panel {
                width: 280px;
                left: 10px;
                max-height: 350px;
            }
            .help-panel-content {
                max-height: 310px;
            }
            .help-button {
                width: 45px;
                height: 45px;
                font-size: 1.5em;
                left: 15px;
                top: 15px;
            }
        }
        @media (max-width: 480px) {
            .help-panel {
                width: calc(100vw - 30px);
                left: 15px;
                right: 15px;
            }
        }

/* ---------- bloc 2 du modele ---------- */
/* ======================== SYSTÈME CSS INTÉGRÉ ======================== */
        @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

        :root {
            --primary-color: #3f51b5;
            --secondary-color: #2196f3;
            --success-color: #4caf50;
            --warning-color: #ff9800;
            --danger-color: #f44336;
            --info-color: #17a2b8;
            --light-color: #f8f9fa;
            --dark-color: #343a40;
            --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --gradient-success: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
            --gradient-info: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
            --gradient-warning: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
            --shadow-soft: 0 10px 35px rgba(0, 0, 0, 0.07);
            --shadow-hover: 0 18px 45px rgba(0, 0, 0, 0.1);
            --border-radius: 20px;
            --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

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

        body {
            font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.8;
            background: var(--gradient-primary);
            min-height: 100vh;
            padding: 20px;
            font-size: 16px;
            color: #333;
        }

        .math-container {
            max-width: 1200px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.98);
            backdrop-filter: blur(15px);
            border-radius: var(--border-radius);
            padding: 40px;
            box-shadow: var(--shadow-soft);
            border: 1px solid rgba(255, 255, 255, 0.3);
            position: relative;
            overflow: hidden;
            animation: slideInUp 0.8s ease-out;
        }

        .math-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 5px;
            background: var(--gradient-primary);
            background-size: 200% 100%;
            animation: gradientShift 4s ease infinite;
            border-radius: var(--border-radius) var(--border-radius) 0 0;
        }

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

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

        .math-header {
            text-align: center;
            margin-bottom: 40px;
            padding: 25px;
            background: rgba(102, 126, 234, 0.08);
            border-radius: var(--border-radius);
            position: relative;
        }

        .math-header h1 {
            color: var(--primary-color);
            font-size: 2.5em;
            font-weight: 700;
            margin-bottom: 10px;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        .math-header .sub-header {
            font-size: 1.1em;
            color: #666;
            display: flex;
            justify-content: space-between;
            padding: 0 20px;
        }

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

        .exercise-card {
            background: #ffffff;
            border-radius: var(--border-radius);
            padding: 30px;
            margin-bottom: 30px;
            box-shadow: var(--shadow-soft);
            border: 1px solid #e0e0e0;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }

        .exercise-card:hover {
            transform: translateY(-5px);
            box-shadow: var(--shadow-hover);
        }

        .exercise-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: var(--gradient-primary);
            transition: width 0.3s ease;
        }

        .exercise-card:hover::before {
            width: 8px;
        }

        .exercise-header {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 25px;
            padding-bottom: 20px;
            border-bottom: 2px solid #f0f0f0;
        }

        .exercise-title {
            color: var(--primary-color);
            font-size: 1.5em;
            font-weight: 700;
            flex-grow: 1;
        }

        .exercise-number {
            background: var(--gradient-primary);
            color: white;
            padding: 8px 16px;
            border-radius: 50px;
            font-weight: 600;
            font-size: 0.9em;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        }

        .exercise-content {
            color: #34495e;
            line-height: 2.2;
            margin-bottom: 25px;
        }

        .exercise-display {
            font-size: 20px;
            text-align: center;
            margin: 30px 0;
            padding: 20px;
            border: 2px solid var(--primary-color);
            border-radius: 15px;
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        }

        .input-section {
            text-align: center;
            margin: 20px 0;
            padding: 20px;
            background: rgba(102, 126, 234, 0.05);
            border-radius: 15px;
        }

        .input-section label {
            font-size: 16px;
            font-weight: bold;
            color: var(--primary-color);
            display: block;
            margin-bottom: 10px;
        }

        input[type="text"] {
            font-size: 16px;
            padding: 12px 20px;
            margin: 10px;
            border: 2px solid var(--primary-color);
            background: white;
            text-align: center;
            width: 120px;
            border-radius: 25px;
            transition: var(--transition);
        }

        input[type="text"]:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.3);
            transform: scale(1.05);
        }

        .interactive-buttons {
            text-align: center;
            margin: 20px 0;
            display: flex;
            gap: 15px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .interactive-btn {
            font-family: 'Cairo', sans-serif;
            font-size: 14px;
            padding: 12px 24px;
            border: none;
            border-radius: 50px;
            cursor: pointer;
            font-weight: 600;
            transition: var(--transition);
            min-width: 140px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .btn-check {
            background: var(--gradient-success);
            color: white;
            box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
        }

        .btn-check:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px rgba(76, 175, 80, 0.4);
        }

        .btn-generate {
            background: var(--gradient-warning);
            color: white;
            box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
        }

        .btn-generate:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px rgba(255, 152, 0, 0.4);
        }

        #result {
            text-align: center;
            margin: 20px 0;
            padding: 15px;
            border-radius: 15px;
            font-size: 18px;
            font-weight: bold;
            display: none;
            animation: fadeInSlide 0.6s ease-out;
        }

        .result-success {
            background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
            border: 2px solid #4caf50;
            color: #155724;
        }

        .result-error {
            background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
            border: 2px solid #f44336;
            color: #721c24;
        }

        .progress-stats {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            padding: 15px;
            border-radius: 10px;
            margin: 20px 0;
            text-align: center;
            border: 1px solid #dee2e6;
        }

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

        .progress-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #dee2e6;
            transition: all 0.3s ease;
        }

        .progress-dot.active {
            background: var(--success-color);
            transform: scale(1.2);
        }

        .progress-dot.current {
            background: var(--warning-color);
            transform: scale(1.3);
            box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
        }

        .progress-buttons {
            display: flex;
            gap: 15px;
            margin: 25px 0;
            flex-wrap: wrap;
            align-items: center;
        }

        .progress-btn {
            font-family: 'Cairo', sans-serif;
            border: none;
            padding: 12px 24px;
            border-radius: 50px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 600;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            text-transform: none;
            min-width: 140px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

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

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

        .btn-hint {
            background: var(--gradient-success);
            color: white;
            box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
        }

        .btn-hint:hover:not(:disabled) {
            box-shadow: 0 10px 25px rgba(76, 175, 80, 0.4);
        }

        .btn-method {
            background: var(--gradient-warning);
            color: white;
            box-shadow: 0 6px 20px rgba(255, 152, 0, 0.3);
        }

        .btn-method:hover:not(:disabled) {
            box-shadow: 0 10px 25px rgba(255, 152, 0, 0.4);
        }

        .btn-solution {
            background: var(--gradient-info);
            color: white;
            box-shadow: 0 6px 20px rgba(23, 162, 184, 0.3);
        }

        .btn-solution:hover:not(:disabled) {
            box-shadow: 0 10px 25px rgba(23, 162, 184, 0.4);
        }

        .btn-reset {
            background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
            color: white;
            box-shadow: 0 6px 20px rgba(108, 117, 125, 0.3);
            margin-right: auto;
        }

        .btn-reset:hover:not(:disabled) {
            box-shadow: 0 10px 25px rgba(108, 117, 125, 0.4);
        }

        .correction-section {
            display: none;
            margin: 20px 0;
            padding: 25px;
            border-radius: 15px;
            position: relative;
            overflow: hidden;
            animation: fadeInSlide 0.6s ease-out;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

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

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

        .correction-section::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 6px;
            height: 100%;
            border-radius: 3px;
        }

        .correction-hint {
            background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
            border: 1px solid #c3e6cb;
            color: #155724;
        }

        .correction-hint::before {
            background: #28a745;
        }

        .correction-hint h4 {
            color: #28a745;
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 15px;
            font-size: 1.2em;
        }

        .correction-method {
            background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
            border: 1px solid #faebcc;
            color: #856404;
        }

        .correction-method::before {
            background: #ffc107;
        }

        .correction-method h4 {
            color: #d39e00;
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 15px;
            font-size: 1.2em;
        }

        .correction-solution {
            background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
            border: 1px solid #b8daff;
            color: #0c5460;
        }

        .correction-solution::before {
            background: #17a2b8;
        }

        .correction-solution h4 {
            color: #138496;
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 15px;
            font-size: 1.2em;
        }

        .solution-step {
            margin: 15px 0;
            padding: 15px;
            border-left: 3px solid var(--info-color);
            background-color: rgba(255, 255, 255, 0.7);
            border-radius: 8px;
        }

        .step-title {
            font-weight: bold;
            margin-bottom: 8px;
            color: var(--info-color);
        }

        .math-expression {
            text-align: center;
            margin: 10px 0;
            padding: 15px;
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            direction: ltr;
        }

        .final-answer {
            text-align: center;
            margin-top: 20px;
            padding: 20px;
            border: 3px solid var(--success-color);
            background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
            border-radius: 15px;
            font-size: 18px;
            font-weight: bold;
            color: #155724;
        }

        .bounce-in {
            animation: bounceIn 0.8s ease-out;
        }

        @keyframes bounceIn {
            0% {
                transform: scale(0.3);
                opacity: 0;
            }
            50% {
                transform: scale(1.05);
            }
            70% {
                transform: scale(0.9);
            }
            100% {
                transform: scale(1);
                opacity: 1;
            }
        }

        .pulse {
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0% {
                box-shadow: 0 0 0 0 rgba(63, 81, 181, 0.4);
            }
            70% {
                box-shadow: 0 0 0 10px rgba(63, 81, 181, 0);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(63, 81, 181, 0);
            }
        }

        @media (max-width: 768px) {
            .math-container {
                padding: 20px;
                margin: 10px;
            }
            
            .math-header h1 {
                font-size: 2em;
            }
            
            .progress-buttons, .interactive-buttons {
                flex-direction: column;
            }
            
            .progress-btn, .interactive-btn {
                width: 100%;
                justify-content: center;
            }
            
            .exercise-header {
                flex-direction: column;
                text-align: center;
                gap: 10px;
            }

            input[type="text"] {
                width: 200px;
            }
        }
