/* Reset et base */
* {
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
}

body {
    margin: 0px auto;
    max-width: 1000px;
    padding: 0 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100%;
}

.header-titre {
    background-color: #ef3ef556;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Typographie cohérente */
h1 {
    font-size: 28px;
    color: #840455;
    margin: 0 0 10px 0;
    font-weight: 600;
}

h2 {
    font-size: 18px;
    color: #045FB4;
    margin: 20px 0 10px 0;
    font-weight: 600;
}

h3 {
    font-size: 16px;
    color: #495057;
    margin: 15px 0 10px 0;
    font-weight: 600;
}

/* Header du formulaire */
.form-header {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.subtitle {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* Inputs harmonisés */
input[type="text"] {
    width: 120px;
    height: 32px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    text-align: right;
    background: white;
    transition: all 0.2s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #045FB4;
    box-shadow: 0 0 0 2px rgba(4, 95, 180, 0.1);
}

input[type="text"]::placeholder {
    color: #999;
    text-align: center;
}

/* Tables harmonisées */
table {
    width: 100%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    border-collapse: collapse;
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    font-size: 14px;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: rgba(4, 95, 180, 0.03);
}

/* En-têtes de section */
.section-header {
    background: linear-gradient(135deg, #045FB4 0%, #0367d8 100%);
    color: white;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 15px;
}

.subsection-header {
    background: #e3f2fd;
    color: #1565c0;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
}

.total-header {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 14px;
}

/* Section A - Opérations */
.operations-container {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.operations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.operations-section {
    padding: 20px;
}

.operations-section:first-child {
    border-right: 1px solid #f0f0f0;
}

.operation-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 15px;
}

.operation-label {
    font-size: 14px;
    color: #555;
    flex: 1;
}

.operation-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Indicateurs de validation uniformes */
.validation-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.validation-indicator.correct {
    background: #4caf50;
    border-color: #4caf50;
}

.validation-indicator.incorrect {
    background: #f44336;
    border-color: #f44336;
}

.validation-indicator.neutral {
    background: white;
    border-color: #ddd;
}

/* Inputs spécialisés */
.period-input {
    width: 100px;
}

.amount-input {
    background: #faf8ff;
    border-color: #d1c4e9;
}

.amount-input:focus {
    border-color: #9c27b0;
    box-shadow: 0 0 0 2px rgba(156, 39, 176, 0.1);
}

.total-input {
    background: #fff3e0;
    border-color: #ffb74d;
    font-weight: 600;
}

.total-input[readonly] {
    background: #f5f5f5;
    border-color: #ccc;
    color: #666;
    cursor: not-allowed;
}

.credit-input {
    background: #ffebee;
    border-color: #ef5350;
    font-weight: 600;
    text-align: center;
    width: 70px;
}

/* Conteneur pour input + indicateur */
.input-with-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

/* Section score et actions */
.score-section {
    background: white;
    border-radius: 10px;
    padding: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin: 30px 0;
}

.score-display {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
}

.score-title {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.score-value {
    font-size: 25px;
    font-weight: 600;
    color: #045FB4;
}

/* Boutons harmonisés avec infobulles */
.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
    position: relative;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: #045FB4;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

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

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

.btn-info {
    background: #17a2b8;
    color: white;
}

/* Système d'infobulles personnalisées */
.btn[data-tooltip] {
    position: relative;
}

.btn[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: tooltipFadeIn 0.3s ease forwards;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn[data-tooltip]:hover::after {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    animation: tooltipFadeIn 0.3s ease forwards;
    pointer-events: none;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Modale personnalisée sobre */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    font-size: 28px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.modal-body {
    padding: 16px 24px 24px;
    color: #666;
    font-size: 15px;
    line-height: 1.5;
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.modal-btn-primary {
    background: #045FB4;
    color: white;
}

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

.modal-btn-cancel {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.modal-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Bouton scroll to top sobre */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #045FB4;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(4, 95, 180, 0.3);
    transition: all 0.3s ease;
    z-index: 100;
}

.scroll-to-top:hover {
    background: #034a9e;
    transform: translateY(-2px);
}

.scroll-to-top.show {
    display: flex;
}

/* Responsive harmonieux */
@media (max-width: 768px) {
    body {
        margin: 10px;
        padding: 10px;
    }

    .operations-grid {
        grid-template-columns: 1fr;
    }

    .operations-section:first-child {
        border-right: none;
        border-bottom: 1px solid #f0f0f0;
    }

    .operation-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .input-with-indicator {
        justify-content: flex-start;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

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

    h1 {
        font-size: 24px;
    }

    /* Adaptation des infobulles sur mobile */
    .btn[data-tooltip]:hover::before {
        bottom: 130%;
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Animation subtile */
.operations-container,
.score-section,
table {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Styles d'impression */
@media print {
    .action-buttons {
        display: none;
    }

    .scroll-to-top {
        display: none;
    }

    .modal-overlay {
        display: none;
    }

    body {
        background-color: white;
        font-size: 12px;
    }

    .operations-container,
    table {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

.logo-circle {
    width: 55px;
    height: 55px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: rgba(205, 24, 229, 0.387);
    flex-shrink: 0;
    overflow: hidden;
}

.logo-circle img {
    width: 45px;
    height: 45px;
    object-fit: contain;
}

.footer {
    text-align: center;
    color: #666;
    font-size: 0.7rem;
    font-weight: 400;
    margin-top: 10px;
    margin-bottom: 10px;
}