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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #2c3e50;
    line-height: 1.5;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    padding: 25px 35px;
    min-height: 100vh;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
}

header {
    text-align: center;
    margin-bottom: 25px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 30px;
    margin: -25px -35px 25px -35px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

h1 {
    font-size: 1.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1em;
    opacity: 0.95;
    font-weight: 300;
    letter-spacing: 1px;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.chrono-bar {
    background: linear-gradient(90deg, #34495e 0%, #2c3e50 100%);
    color: white;
    padding: 8px 20px;
    font-size: 1em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex: 0 0 auto;
}

.btn-print {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    padding: 10px 25px;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 3px;
    transition: all 0.3s;
    white-space: nowrap;
    flex: 0 0 auto;
}

.btn-print:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

.scores-summary {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    color: white;
    padding: 8px 15px;
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.scores-summary-title {
    font-size: 0.8em;
    font-weight: 600;
    margin-bottom: 5px;
    text-align: center;
    letter-spacing: 1px;
}

.scores-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.score-item-summary {
    text-align: center;
    font-size: 0.85em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 6px;
    border-radius: 3px;
}

.score-item-summary span {
    color: #ffd700;
}

.info-section {
    max-width: 500px;
    margin: 30px auto;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.info-section h2 {
    color: #1e3c72;
    margin-bottom: 20px;
    font-size: 1.3em;
    text-align: center;
    font-weight: 600;
}

.info-section em {
    display: block;
    text-align: center;
    color: #666;
    font-size: 0.85em;
    margin-bottom: 15px;
}

.info-section input {
    width: 100%;
    padding: 10px 12px;
    margin: 8px 0;
    border: 1px solid #ced4da;
    font-size: 0.9em;
    border-radius: 3px;
    transition: all 0.2s;
}

.info-section input:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 12px 30px;
    border: none;
    font-size: 0.95em;
    cursor: pointer;
    width: 100%;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 3px;
    transition: all 0.3s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(30, 60, 114, 0.3);
}

.levels-container {
    display: none;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    margin-bottom: 15px;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60 0%, #229954 100%);
    transition: width 0.5s ease;
}

.level-selector {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 25px;
}

.level-btn {
    padding: 8px 6px;
    border: 1px solid #ced4da;
    background: #f1f3f5;
    color: #868e96;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    cursor: not-allowed;
    transition: all 0.2s;
    border-radius: 3px;
}

.level-btn.unlocked {
    background: white;
    color: #1e3c72;
    border-color: #2a5298;
    cursor: pointer;
}

.level-btn.unlocked:hover {
    background: #1e3c72;
    color: white;
}

.level-btn.completed {
    background: #95a5a6;
    color: white;
    border-color: #95a5a6;
    cursor: not-allowed;
    opacity: 0.7;
}

.level-btn.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
    box-shadow: 0 2px 8px rgba(42, 82, 152, 0.3);
}

.level-content {
    display: none;
}

.level-content.active {
    display: block;
}

.level-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.level-header h2 {
    font-size: 1.4em;
    margin-bottom: 5px;
    font-weight: 600;
}

.level-header p {
    font-size: 0.9em;
    opacity: 0.95;
}

.exercise-layout {
    display: grid;
    grid-template-columns: 1fr 2fr 0.65fr;
    gap: 25px;
    align-items: start;
}

.document-panel {
    background: #f8f9fa;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.document-panel h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

/* FACTURE */
.facture {
    background: white;
    border: 1px solid #ddd;
    padding: 0;
    font-size: 0.85em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.facture-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 3px solid #1e3c72;
}

.facture-entreprise {
    flex: 1;
}

.facture-entreprise strong {
    display: block;
    font-size: 1.1em;
    color: #1e3c72;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.facture-address {
    width: 100%;
    margin-top: 8px;
    order: 3;
}

.facture-address-line {
    display: block;
    font-size: 0.85em;
    color: #495057;
    line-height: 1.5;
    margin-top: 2px;
}

.facture-numero {
    text-align: right;
    background: white;
    border: 2px solid #1e3c72;
    padding: 12px 18px;
    border-radius: 4px;
}

.facture-numero strong {
    display: block;
    font-size: 1.3em;
    color: #1e3c72;
    font-weight: 700;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.facture-body {
    padding: 20px 25px;
}

.facture-date-section {
    text-align: right;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e9ecef;
    line-height: 1.2;
}

.facture-date-section strong {
    color: #495057;
    font-weight: 600;
}

.facture-line {
    display: flex;
    justify-content: space-between;
    padding: 6px 15px;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
    line-height: 1.2;
}

.facture-line:nth-child(odd) {
    background: #f8f9fa;
}

.facture-line span:first-child {
    flex: 1;
    color: #212529;
    font-weight: 500;
}

.facture-line span:last-child {
    font-weight: 600;
    color: #1e3c72;
    min-width: 100px;
    text-align: right;
    font-size: 1em;
}

.facture-line.facture-total {
    background: #1e3c72;
    color: white;
    margin-top: 5px;
    padding: 10px 15px;
    border: none;
    font-weight: 700;
    font-size: 1.05em;
}

.facture-line.facture-total span {
    color: white;
}

.facture-client-section {
    padding: 10px 25px;
    background: #ffffff;
    border-bottom: 1px solid #e9ecef;
    line-height: 1.3;
}

.facture-client-section strong {
    display: block;
    color: #495057;
    font-weight: 600;
    margin-bottom: 5px;
}

.facture-client-info {
    color: #212529;
    font-size: 0.95em;
}

.facture-payment {
    padding: 15px 25px;
    background: #f8f9fa;
    border-top: 2px solid #1e3c72;
    font-size: 0.85em;
    line-height: 1.6;
}

.facture-payment strong {
    color: #1e3c72;
    display: block;
    margin-bottom: 5px;
}

/* VIREMENT PANEL */
.virement-panel {
    background: #f8f9fa;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.virement-panel h3 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.virement-panel h4 {
    color: #1e3c72;
    margin-bottom: 12px;
    font-size: 1em;
    font-weight: 600;
    border-bottom: 2px solid #1e3c72;
    padding-bottom: 8px;
}

/* SÉLECTION DES COMPTES */
.compte-selection {
    margin-bottom: 25px;
}

.compte-select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
    color: #495057;
}

.compte-select:hover {
    border-color: #2a5298;
}

.compte-select:focus {
    outline: none;
    border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.compte-select option {
    padding: 10px;
}

/* FORMULAIRE DE VIREMENT */
.virement-form {
    background: white;
    padding: 20px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    color: #495057;
    font-weight: 600;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    font-size: 0.9em;
    transition: all 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #2a5298;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
}

.solde-info {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 12px;
    margin-top: 15px;
    border-radius: 4px;
}

.solde-info input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ffc107;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 600;
}

.btn-validate {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 12px 30px;
    border: none;
    font-size: 0.95em;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 3px;
    transition: all 0.3s;
}

.btn-validate:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(30, 60, 114, 0.3);
}

.feedback {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    display: none;
}

.feedback.active {
    display: block;
}

.score-panel {
    background: #f8f9fa;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    position: sticky;
    top: 20px;
}

.score-panel h3 {
    color: #1e3c72;
    margin-bottom: 10px;
    font-size: 1em;
    text-align: center;
    font-weight: 600;
}

.timer-display {
    background: #2c3e50;
    color: white;
    padding: 8px;
    text-align: center;
    font-size: 1.6em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
    margin-bottom: 8px;
}

.time-info {
    text-align: center;
    color: #666;
    font-size: 0.75em;
    margin-bottom: 12px;
}

.score-display {
    text-align: center;
    margin: 15px 0;
}

.score-value {
    font-size: 2em;
    font-weight: 700;
    color: #2a5298;
    margin-bottom: 5px;
}

.score-label {
    font-size: 0.75em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* MODALE */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 20px 25px;
    border-radius: 6px;
    max-width: 500px;
    width: 90%;
    max-height: 75vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border-top: 4px solid #1e3c72;
}

.modal-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.modal-title {
    color: #1e3c72;
    font-size: 1.3em;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-score {
    font-size: 2.8em;
    font-weight: 700;
    margin: 10px 0;
}

.modal-score.success {
    color: #27ae60;
}

.modal-score.warning {
    color: #f39c12;
}

.modal-score.error {
    color: #e74c3c;
}

.modal-time-info {
    background: #f8f9fa;
    padding: 10px 12px;
    border-radius: 4px;
    margin: 12px 0;
    font-size: 0.9em;
    text-align: center;
    color: #666;
}

.modal-time-info div {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #dee2e6;
}

.modal-time-info div:last-child {
    border-bottom: none;
}

.modal-errors {
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
}

.modal-errors h3 {
    color: #1e3c72;
    font-size: 1em;
    margin-bottom: 10px;
    font-weight: 600;
}

.modal-error-item {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    padding: 8px 10px;
    margin: 6px 0;
    color: #856404;
    font-size: 0.85em;
}

.modal-success-item {
    background: #d4edda;
    border-left: 3px solid #28a745;
    padding: 8px 10px;
    margin: 6px 0;
    color: #155724;
    font-size: 0.85em;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
}

.modal-btn {
    flex: 1;
    padding: 10px 20px;
    border: none;
    font-size: 0.9em;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 3px;
    transition: all 0.3s;
}

.modal-btn-next {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
}

.modal-btn-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

.modal-btn-retry {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
}

.modal-btn-retry:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(243, 156, 18, 0.3);
}

/* RÉSULTATS FINAUX */
.final-results {
    display: none;
    max-width: 900px;
    margin: 0 auto;
}

.final-results.active {
    display: block;
}

.certificate-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #1e3c72;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.certificate-header {
    color: #1e3c72;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.certificate-student {
    font-size: 1.5em;
    color: #2a5298;
    margin: 20px 0;
    font-weight: 600;
}

.certificate-score {
    font-size: 4em;
    font-weight: 700;
    color: #27ae60;
    margin: 30px 0;
}

.certificate-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin: 30px 0;
}

.certificate-detail-item {
    background: white;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.certificate-detail-item strong {
    display: block;
    color: #1e3c72;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.certificate-detail-item span {
    font-size: 1.3em;
    color: #2a5298;
    font-weight: 600;
}

.score-details {
    text-align: left;
    margin: 30px 0;
    background: white;
    padding: 20px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.score-details h4 {
    color: #1e3c72;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.score-item {
    padding: 10px;
    margin: 8px 0;
    background: #f8f9fa;
    border-left: 4px solid #2a5298;
}

.btn-print-results {
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    color: white;
    padding: 15px 40px;
    border: none;
    font-size: 1em;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    border-radius: 3px;
    margin-top: 30px;
    transition: all 0.3s;
    width: 100%;
    max-width: 400px;
}

.btn-print-results:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(39, 174, 96, 0.4);
}

/* IMPRESSION */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
        padding: 0;
        max-width: 100%;
    }

    header,
    .top-controls,
    .progress-bar,
    .level-selector,
    .btn-validate,
    .btn-print,
    .btn-print-results,
    .score-panel,
    .modal-overlay {
        display: none !important;
    }

    .levels-container {
        display: block !important;
    }

    .level-content {
        display: block !important;
        page-break-after: always;
        page-break-inside: avoid;
    }

    .level-content:last-child {
        page-break-after: auto;
    }

    .level-header {
        background: #f8f9fa;
        color: #1e3c72;
        border: 2px solid #1e3c72;
        page-break-after: avoid;
    }

    .exercise-layout {
        grid-template-columns: 1fr;
        gap: 15px;
        page-break-inside: avoid;
    }

    .document-panel,
    .virement-panel {
        page-break-inside: avoid;
    }

    .feedback {
        display: block !important;
        page-break-before: avoid;
        border: 2px solid #1e3c72;
        margin-top: 10px;
    }

    .print-score-info {
        display: block !important;
        background: #f8f9fa;
        border: 2px solid #1e3c72;
        padding: 15px;
        margin-top: 10px;
        page-break-inside: avoid;
    }

    .final-results {
        page-break-before: always;
        page-break-inside: avoid;
        display: block !important;
    }

    .certificate-panel {
        page-break-inside: avoid;
    }

    .certificate-details {
        page-break-inside: avoid;
    }

    .score-details {
        page-break-inside: avoid;
    }
}

.print-score-info {
    display: none;
    margin-top: 15px;
}

.print-score-info h4 {
    color: #1e3c72;
    margin-bottom: 10px;
}

.print-score-info p {
    margin: 5px 0;
}

/* FOOTER */
footer {
    text-align: center;
    padding: 10px;
    margin-top: 20px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    font-size: 0.7em;
    margin: 20px -35px -25px -35px;
}

footer p {
    margin: 0;
    font-weight: 500;
    letter-spacing: 1px;
}

@media print {
    footer {
        display: none;
    }
}
