@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

:root {
    --primary-color: #005a9c;
    --secondary-color: #4a90e2;
    --background-color: #f0f4f8;
    --container-bg: #ffffff;
    --correct-bg: #d4edda;
    --incorrect-bg: #f8d7da;
    --warning-color: #ffc107;
    --success-color: #28a745;
    --text-color: #333;
    --border-color: #ccc;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Lato', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 1em;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.6;
}

header {
    width: 100%;
    max-width: 1100px;
    text-align: center;
    margin-bottom: 2em;
}

header h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 2.2em;
    text-shadow: 1px 1px 2px var(--shadow-color);
}

main {
    width: 100%;
    max-width: 1100px;
}

.exercise-zone {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2em;
}

@media (min-width: 800px) {
    .exercise-zone {
        grid-template-columns: 350px 1fr;
    }
}

.panel {
    background-color: var(--container-bg);
    border-radius: 12px;
    padding: 1.8em;
    box-shadow: 0 6px 20px var(--shadow-color);
    border: 1px solid var(--medium-gray);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

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

.panel-data header h2 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5em;
}

.figure-container {
    position: relative;
    margin: 1.5em 0;
    background: var(--light-gray);
    border-radius: 8px;
    padding: 1em;
    border: 1px solid var(--border-color);
}

#figureSVG {
    display: block;
    margin: 0 auto;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.length-label {
    font-size: 0.85em;
    fill: #c9302c;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    paint-order: stroke;
    stroke: white;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.length-label.unknown {
    fill: #ff6b00;
    font-style: italic;
}

.point-label {
    font-size: 1em;
    fill: var(--primary-color);
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: middle;
    paint-order: stroke;
    stroke: white;
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#given-lengths,
#parallel-lines {
    font-weight: bold;
    font-size: 1.1em;
    line-height: 1.6;
    text-align: left;
    background: var(--light-gray);
    padding: 1em;
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
    margin: 1em 0;
}

#given-lengths {
    border-left-color: var(--success-color);
}

#parallel-lines {
    border-left-color: var(--secondary-color);
}

.worksheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5em;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 0.8em;
    flex-wrap: wrap;
    gap: 1em;
}

#question-text {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.4em;
    flex: 1;
}

#step-indicator {
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.5em 1.2em;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 90, 156, 0.3);
    font-size: 0.9em;
}

input,
select {
    padding: 0.6em 0.8em;
    margin: 0 0.3em;
    font-size: 1em;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    text-align: center;
    transition: all 0.2s ease;
    background: white;
    font-family: 'Lato', sans-serif;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 90, 156, 0.1);
    transform: translateY(-1px);
}

input.correct {
    background-color: var(--correct-bg);
    border-color: var(--success-color);
    color: #155724;
}

input.incorrect {
    background-color: var(--incorrect-bg);
    border-color: #dc3545;
    color: #721c24;
}

input[readonly] {
    background-color: var(--light-gray);
    border-color: var(--medium-gray);
    color: var(--text-color);
    cursor: not-allowed;
}

button {
    padding: 0.8em 1.5em;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-family: 'Lato', sans-serif;
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#new-exercise-btn {
    background: linear-gradient(135deg, var(--success-color), #20c997);
    color: white;
    font-size: 1.1em;
    margin-bottom: 1.5em;
    width: 100%;
}

.wizard-navigation {
    margin-top: 2em;
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    justify-content: center;
    padding-top: 1.5em;
    border-top: 1px solid var(--medium-gray);
}

.wizard-navigation button {
    min-width: 120px;
}

#prev-btn {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: white;
}

#next-btn,
#check-step-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

#check-all-btn {
    background: linear-gradient(135deg, var(--success-color), #20c997);
    color: white;
}

.feedback-zone {
    margin-top: 2em;
    border-top: 2px solid var(--medium-gray);
    padding-top: 1.5em;
}

#feedback-message {
    padding: 1em;
    border-radius: 8px;
    margin-bottom: 1em;
    font-weight: bold;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#feedback-message.correct {
    background-color: var(--correct-bg);
    color: #155724;
    border: 1px solid var(--success-color);
}

#feedback-message.incorrect {
    background-color: var(--incorrect-bg);
    color: #721c24;
    border: 1px solid #dc3545;
}

#feedback-message.info {
    background-color: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

#solution-btn {
    background: linear-gradient(135deg, #ff6b00, #ff8e42);
    color: white;
    width: 100%;
    margin-bottom: 1em;
}

.solution {
    margin-top: 1.5em;
    background: linear-gradient(135deg, #e8f5e8, #f0f8f0);
    padding: 1.5em;
    border-radius: 10px;
    border: 2px solid var(--success-color);
    display: none;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.2);
}

.solution h4 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5em;
    font-size: 1.2em;
}

.solution-step {
    margin: 1.5em 0;
    font-size: 1.1em;
    text-align: center;
    padding: 1.2em;
    background-color: white;
    border-radius: 8px;
    border-left: 5px solid var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.solution-step:hover {
    transform: translateX(5px);
}

.solution-step h4 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 0.8em;
    font-size: 1.1em;
}

fieldset {
    border: 2px solid var(--medium-gray);
    border-radius: 10px;
    padding: 1.5em;
    margin-bottom: 1.5em;
    background: var(--light-gray);
    transition: border-color 0.3s ease;
}

fieldset:hover {
    border-color: var(--primary-color);
}

legend {
    font-weight: bold;
    color: var(--primary-color);
    padding: 0 1em;
    font-size: 1.2em;
    background: white;
    border-radius: 20px;
    border: 2px solid var(--primary-color);
}

.equation {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.8em;
    margin: 1em 0;
    padding: 1em;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.previous-step-result {
    background-color: white;
    padding: 1.2em;
    border-radius: 8px;
    margin-bottom: 1.5em;
    text-align: center;
    font-size: 1.2em;
    min-height: 60px;
    border: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.equation-fraction-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5em;
    padding: 1em 0;
    flex-wrap: wrap;
    background: white;
    border-radius: 8px;
    margin: 1em 0;
}

.fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--light-gray);
    padding: 0.8em;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-width: 80px;
}

.fraction input {
    width: 60px;
    border: 1px solid var(--border-color);
    text-align: center;
    margin: 2px;
    background: white;
}

.fraction input:first-child {
    border-bottom: 2px solid black;
    border-radius: 6px 6px 0 0;
    margin-bottom: 4px;
}

.fraction input:last-child {
    border-radius: 0 0 6px 6px;
    margin-top: 4px;
}

.fraction-divider {
    width: 80%;
    height: 2px;
    background: black;
    margin: 4px 0;
}

.fraction-inline {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 0 0.5em;
    vertical-align: middle;
}

.fraction-inline-divider {
    display: inline-block;
    width: 60px;
    height: 2px;
    background: black;
    vertical-align: middle;
    margin: 0 -10px;
    position: relative;
    z-index: 1;
}

.parallel-symbol {
    color: var(--primary-color);
    font-weight: bold;
    margin: 0 0.5em;
    font-size: 1.2em;
}

.katex {
    font-size: 1.2em !important;
}

.katex-display {
    margin: 1em 0 !important;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wizard-step {
    animation: slideIn 0.3s ease-out;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0.5em;
    }
    
    .panel {
        padding: 1.2em;
    }
    
    .worksheet-header {
        flex-direction: column;
        text-align: center;
    }
    
    #question-text {
        font-size: 1.2em;
    }
    
    .equation-fraction-input {
        gap: 1em;
    }
    
    .fraction {
        min-width: 70px;
    }
    
    .fraction input {
        width: 50px;
    }
    
    .wizard-navigation {
        flex-direction: column;
    }
    
    .wizard-navigation button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8em;
    }
    
    .panel {
        padding: 1em;
    }
    
    input, select {
        padding: 0.5em 0.6em;
        font-size: 0.9em;
    }
    
    button {
        padding: 0.7em 1.2em;
        font-size: 0.9em;
    }
    
    .equation-fraction-input {
        flex-direction: column;
        gap: 0.8em;
    }
    
    .fraction {
        flex-direction: row;
        gap: 0.5em;
        align-items: center;
    }
    
    .fraction input:first-child {
        border-bottom: none;
        border-right: 2px solid black;
        border-radius: 6px 0 0 6px;
        margin-bottom: 2px;
        margin-right: 4px;
    }
    
    .fraction input:last-child {
        border-radius: 0 6px 6px 0;
        margin-top: 2px;
        margin-left: 4px;
    }
    
    .fraction-divider {
        display: none;
    }
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4a9fff;
        --background-color: #1a1a1a;
        --container-bg: #2d2d2d;
        --text-color: #e0e0e0;
        --border-color: #555;
        --shadow-color: rgba(0, 0, 0, 0.3);
        --light-gray: #3a3a3a;
        --medium-gray: #444;
    }
    
    .panel {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    }
    
    input, select {
        background: #3a3a3a;
        color: var(--text-color);
        border-color: #555;
    }
    
    .solution {
        background: linear-gradient(135deg, #2a3a2a, #1a2a1a);
    }
    
    .solution-step {
        background: #3a3a3a;
    }
}

/* Impression */
@media print {
    .wizard-navigation,
    #solution-btn,
    .feedback-zone {
        display: none;
    }
    
    .panel {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    body {
        background: white;
    }
}
.calculation-fraction {
    display: inline-flex;
    flex-direction: column;
    text-align: center;
    vertical-align: middle;
    margin: 0 0.5em;
}

.calculation-numerator {
    padding: 0.2em 0.5em;
    border-bottom: 2px solid black;
}

.calculation-denominator {
    padding: 0.2em 0.5em;
}