/* Math Exercises Styles - Educaweb */

/* ============================================
   Exercise Container
   ============================================ */
.math-exercise-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    border-radius: 20px;
    padding: 30px;
    margin: 20px auto;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.math-exercise-header {
    text-align: center;
    margin-bottom: 30px;
}

.math-exercise-title {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 10px;
}

.math-exercise-level {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
}

.math-exercise-level.cp { background: #FFF3E0; color: #E65100; }
.math-exercise-level.ce1 { background: #E8F5E9; color: #2E7D32; }
.math-exercise-level.ce2 { background: #E3F2FD; color: #1565C0; }
.math-exercise-level.cm1 { background: #F3E5F5; color: #7B1FA2; }
.math-exercise-level.cm2 { background: #FCE4EC; color: #C2185B; }

/* ============================================
   Question Display
   ============================================ */
.math-question-box {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    text-align: center;
    position: relative;
    min-height: 200px;
}

.math-question-number {
    position: absolute;
    top: -15px;
    left: 20px;
    background: #0d6efd;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
}

.math-question-text {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 20px 0;
}

.math-question-visual {
    margin: 20px 0;
}

/* ============================================
   Objects Display (apples, balls, etc.)
   ============================================ */
.objects-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.objects-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 15px;
    border-radius: 10px;
    background: #f8f9fa;
    min-width: 80px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.objects-group:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.objects-group.selected {
    background: #e3f2fd;
    border: 2px solid #0d6efd;
}

.object-item {
    width: 40px;
    height: 40px;
    margin: 3px;
    transition: transform 0.2s;
}

.object-item:hover {
    transform: scale(1.1);
}

.object-item.counted {
    animation: bounce 0.3s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ============================================
   Number Line (Bande numérique)
   ============================================ */
.number-line-container {
    overflow-x: auto;
    padding: 20px 0;
    margin: 20px 0;
}

.number-line {
    display: flex;
    justify-content: flex-start;
    gap: 0;
    min-width: max-content;
    position: relative;
    padding: 10px 0;
}

.number-line::before {
    content: '';
    position: absolute;
    bottom: 35px;
    left: 0;
    right: 0;
    height: 4px;
    background: #3498db;
    z-index: 0;
}

.number-line-cell {
    width: 45px;
    height: 45px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

.number-line-number {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    border: 3px solid #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.number-line-number:hover {
    transform: scale(1.1);
    background: #e3f2fd;
}

.number-line-number.current {
    background: #3498db;
    color: white;
    transform: scale(1.2);
}

.number-line-number.visited {
    background: #81d4fa;
    border-color: #0288d1;
}

.number-line-number.start {
    background: #4caf50;
    border-color: #2e7d32;
    color: white;
}

.number-line-number.end {
    background: #f44336;
    border-color: #c62828;
    color: white;
}

.number-line-tick {
    width: 2px;
    height: 10px;
    background: #3498db;
    margin-top: 2px;
}

/* ============================================
   Column Operations (Addition/Soustraction)
   ============================================ */
.column-operation-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.column-operation {
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.column-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 50px;
    padding: 5px 10px;
}

.column-operator {
    width: 40px;
    text-align: left;
    font-weight: bold;
}

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

.column-digit {
    width: 40px;
    height: 50px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
}

.column-digit input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    background: transparent;
}

.column-digit:focus-within {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.column-carry {
    font-size: 1rem;
    color: #dc3545;
    font-weight: bold;
    margin-right: 5px;
}

.column-carry input {
    width: 30px;
    height: 30px;
    font-size: 1rem;
}

.column-divider {
    border-top: 3px solid #2c3e50;
    margin: 10px 0;
}

.column-result .column-digit {
    border: 2px solid #0d6efd;
    background: #f8f9fa;
}

/* ============================================
   Answer Input Area
   ============================================ */
.math-answer-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.math-answer-input {
    width: 120px;
    height: 60px;
    font-size: 2rem;
    text-align: center;
    border: 3px solid #dee2e6;
    border-radius: 15px;
    transition: all 0.3s;
}

.math-answer-input:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

.math-answer-input.correct {
    border-color: #198754;
    background: #d1e7dd;
}

.math-answer-input.incorrect {
    border-color: #dc3545;
    background: #f8d7da;
    animation: shake 0.5s ease-in-out;
}

.math-equals {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* ============================================
   Exercise Controls
   ============================================ */
.math-controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin: 30px 0;
}

.math-btn {
    min-width: 130px;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 25px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.math-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.math-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-eraser {
    background: #6c757d;
    color: white;
}

.btn-eraser:hover {
    background: #5a6268;
}

.btn-check {
    background: #0d6efd;
    color: white;
}

.btn-check:hover {
    background: #0b5ed7;
}

.btn-show {
    background: #ffc107;
    color: #212529;
}

.btn-show:hover {
    background: #e0a800;
}

.btn-continue {
    background: #198754;
    color: white;
}

.btn-continue:hover {
    background: #157347;
}

.btn-stop {
    background: #dc3545;
    color: white;
}

.btn-stop:hover {
    background: #bb2d3b;
}

.btn-options {
    background: #6f42c1;
    color: white;
}

.btn-options:hover {
    background: #5a32a3;
}

/* ============================================
   Counters Display
   ============================================ */
.math-counters {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.counter-box {
    background: white;
    border-radius: 15px;
    padding: 15px 25px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    min-width: 120px;
}

.counter-box.abandons {
    border-left: 4px solid #dc3545;
}

.counter-box.correct-first {
    border-left: 4px solid #198754;
}

.counter-box.correct-after {
    border-left: 4px solid #ffc107;
}

.counter-label {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 5px;
}

.counter-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2c3e50;
}

/* ============================================
   Feedback Messages
   ============================================ */
.math-feedback {
    padding: 15px 25px;
    border-radius: 10px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    display: none;
}

.math-feedback.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.math-feedback.correct {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.math-feedback.incorrect {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.math-feedback.info {
    background: #cfe2ff;
    color: #055160;
    border: 1px solid #b6effb;
}

.math-feedback.success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

/* ============================================
   Timer Display
   ============================================ */
.math-timer {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    font-size: 1.2rem;
    font-weight: bold;
}

.math-timer.warning {
    background: #fff3cd;
    color: #856404;
}

.math-timer.danger {
    background: #f8d7da;
    color: #842029;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ============================================
   Progress Bar
   ============================================ */
.math-progress {
    width: 100%;
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    margin: 20px 0;
    overflow: hidden;
}

.math-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #00a8ff);
    border-radius: 5px;
    transition: width 0.5s ease;
}

/* ============================================
   Fraction Display
   ============================================ */
.fraction-container {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
    font-size: 1.5rem;
}

.fraction-numerator,
.fraction-denominator {
    padding: 5px 15px;
}

.fraction-line {
    width: 100%;
    height: 3px;
    background: #2c3e50;
}

.fraction-input {
    width: 60px;
    height: 40px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid #dee2e6;
    border-radius: 8px;
}

/* ============================================
   Modal Styles
   ============================================ */
.math-modal .modal-content {
    border-radius: 20px;
    border: none;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.math-modal .modal-header {
    background: linear-gradient(135deg, #0d6efd, #00a8ff);
    color: white;
    border-radius: 20px 20px 0 0;
    padding: 20px 30px;
}

.math-modal .modal-title {
    font-weight: bold;
}

.math-modal .modal-body {
    padding: 30px;
}

.math-modal .modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e9ecef;
}

/* Options Modal Specific */
.options-form .form-label {
    font-weight: 600;
    margin-bottom: 10px;
}

.options-form .form-check {
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.options-form .form-check:last-child {
    border-bottom: none;
}

/* ============================================
   Stop Confirmation Modal
   ============================================ */
.stop-modal-icon {
    font-size: 4rem;
    color: #ffc107;
    margin-bottom: 20px;
}

/* ============================================
   Solution Modal
   ============================================ */
.solution-step {
    display: flex;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    margin: 10px 0;
}

.solution-step-number {
    width: 30px;
    height: 30px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-weight: bold;
}

/* ============================================
   Difficulty Stars
   ============================================ */
.difficulty-stars {
    color: #ffc107;
    font-size: 1rem;
}

.difficulty-stars .star {
    margin: 0 2px;
}

.difficulty-stars .star.empty {
    color: #dee2e6;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .math-exercise-container {
        padding: 15px;
        border-radius: 15px;
    }

    .math-question-text {
        font-size: 1.5rem;
    }

    .math-answer-input {
        width: 100px;
        height: 50px;
        font-size: 1.5rem;
    }

    .math-btn {
        min-width: 100px;
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    .counter-box {
        min-width: 100px;
        padding: 10px 15px;
    }

    .counter-value {
        font-size: 1.5rem;
    }

    .number-line-cell {
        width: 35px;
        height: 35px;
    }

    .number-line-number {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .column-digit {
        width: 35px;
        height: 45px;
        font-size: 1.2rem;
    }

    .math-timer {
        top: 70px;
        right: 10px;
        padding: 8px 15px;
        font-size: 1rem;
    }
}

@media (max-width: 576px) {
    .math-controls {
        flex-direction: column;
        align-items: center;
    }

    .math-btn {
        width: 100%;
        max-width: 250px;
    }

    .math-counters {
        flex-direction: column;
        align-items: center;
    }

    .counter-box {
        width: 100%;
        max-width: 250px;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .math-controls,
    .math-timer,
    .math-feedback {
        display: none !important;
    }

    .math-exercise-container {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ============================================
   Accessibility
   ============================================ */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .math-btn {
        border: 2px solid currentColor;
    }

    .math-answer-input {
        border-width: 4px;
    }

    .number-line-number {
        border-width: 4px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}