/* ==========================================================================
   FORMULAIRES ET CONTENEURS PRINCIPAUX
   ========================================================================== */

.compta-form {
    max-width: 90%;
    margin: 30px auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 24px 32px;
}

.compta-form h3 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 1.5em;
    border-bottom: 2px solid #059669;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* ==========================================================================
   CHAMPS DE FORMULAIRE
   ========================================================================== */

.compta-form label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    margin-top: 5px;
    color: #374151;
}

.compta-form input[type="text"],
.compta-form input[type="date"],
.compta-form input[type="number"],
.compta-form input[type="file"],
.compta-form select,
.compta-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1em;
    background: #f9fafb;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.compta-form input[type="text"]:focus,
.compta-form input[type="date"]:focus,
.compta-form input[type="number"]:focus,
.compta-form select:focus,
.compta-form textarea:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
    background: #fff;
}

.compta-form textarea {
    min-height: 80px;
    resize: vertical;
}

.compta-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #059669;
}

/* ==========================================================================
   BOUTONS
   ========================================================================== */

.compta-form button[type="submit"] {
    background: #059669;
    color: #fff;
    border: none;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 20px;
}

.compta-form button[type="submit"]:hover {
    background: #047857;
    transform: translateY(-1px);
}

.compta-form button[type="submit"]:active {
    transform: translateY(0);
}

.compta-form button[type="submit"] i {
    margin-right: 8px;
}

.compta-form button[type="button"] {
    background: #065f46;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.compta-form button[type="button"]:hover {
    background: #064e3b;
}

/* Boutons secondaires / d'annulation */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #6b7280;
    color: #fff;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    color: #fff;
}

/* ==========================================================================
   CONTENEURS CONDITIONNELS
   ========================================================================== */

#lib_detailSelectContainer {
    background: #f0fdf4;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #059669;
}

#justificatifContainer {
    background: #fef3c7;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #f59e0b;
    margin-top: 20px;
}

#factureContainer {
    margin-top: 20px;
}

/* ==========================================================================
   LISTES
   ========================================================================== */

.compta-list,
.categorie-list {
    max-width: 90%;
    margin: 30px auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 24px 32px;
}

.compta-list h3,
.categorie-list h3 {
    color: #2c3e50;
    font-size: 1.3em;
    margin-bottom: 15px;
    padding-left: 5px;
}

/* ==========================================================================
   MESSAGES
   ========================================================================== */

.asso-message {
    max-width: 90%;
    margin: 20px auto;
    padding: 14px 20px;
    border-radius: 6px;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

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

.asso-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
    border-left: 4px solid #10b981;
}

.asso-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
    border-left: 4px solid #ef4444;
}

/* ==========================================================================
   MODALES
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 500px;
    width: 90%;
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal h4 {
    margin: 0 0 20px;
    color: #2c3e50;
    font-size: 1.5em;
}

.modal label {
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
    color: #4a5568;
}

.modal input[type="text"],
.modal select,
.modal textarea {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 20px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1em;
    background: #f9fafb;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.modal input[type="text"]:focus,
.modal select:focus,
.modal textarea:focus {
    outline: none;
    border-color: #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

.modal button {
    background: #059669;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.modal button:hover {
    background: #047857;
    transform: translateY(-1px);
}

.modal button.cancel {
    background: #6b7280;
}

.modal button.cancel:hover {
    background: #4b5563;
}

/* ==========================================================================
   PLAN COMPTABLE
   ========================================================================== */

.plan-comptable-section {
    background: #f9fafb;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
}

.plan-comptable-section h4 {
    margin-top: 0;
    color: #374151;
    border-bottom: 2px solid #d1d5db;
    padding-bottom: 8px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-comptable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.plan-comptable-grid > div {
    display: flex;
    flex-direction: column;
}

.compte-info-box {
    margin-top: 15px;
    padding: 12px 16px;
    background: #d1fae5;
    border-radius: 6px;
    border-left: 4px solid #059669;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown 0.3s ease-out;
}

.compte-info-box strong {
    color: #065f46;
}

.compte-info-box span {
    color: #047857;
    font-weight: 600;
}

/* ==========================================================================
   TABLEAUX D'ÉCRITURES
   ========================================================================== */

.ecriture-table {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.ecriture-header {
    display: flex;
    background: #f3f4f6;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid #d1d5db;
    color: #374151;
    gap: 10px;
}

.ecriture-header > div:nth-child(1) { width: 80px; }
.ecriture-header > div:nth-child(2) { width: 90px; text-align: center; }
.ecriture-header > div:nth-child(3) { flex: 1; min-width: 200px; }
.ecriture-header > div:nth-child(4) { width: 100px; text-align: center; }
.ecriture-header > div:nth-child(5) { width: 110px; text-align: right; }
.ecriture-header > div:nth-child(6) { width: 80px; text-align: center; }

.ecriture-row {
    display: flex;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
    gap: 10px;
    align-items: center;
    font-family: 'Avenir Next', Avenir, sans-serif;
    font-size: 1em;
}

.ecriture-row:hover {
    background-color: #f9fafb;
}

.ecriture-row:last-child {
    border-bottom: none;
}

.ecriture-row > div:nth-child(1) { width: 80px; font-weight: 500; }
.ecriture-row > div:nth-child(2) { width: 90px; text-align: center; }
.ecriture-row > div:nth-child(3) { flex: 1; min-width: 200px; }
.ecriture-row > div:nth-child(4) { width: 100px; text-align: center; }
.ecriture-row > div:nth-child(5) { width: 110px; text-align: right; font-weight: 600; }
.ecriture-row > div:nth-child(6) { width: 80px; text-align: center; }

/* ==========================================================================
   TABLEAUX DE FACTURES
   ========================================================================== */

.facture-table {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.facture-header {
    display: flex;
    background: #f3f4f6;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid #d1d5db;
    color: #374151;
    gap: 10px;
}

.facture-header > div:nth-child(1) { width: 180px; }
.facture-header > div:nth-child(2) { flex: 1; min-width: 250px; }
.facture-header > div:nth-child(3) { width: 110px; text-align: right; }
.facture-header > div:nth-child(4) { width: 90px; text-align: center; }
.facture-header > div:nth-child(5) { width: 80px; text-align: center; }

.facture-row {
    display: flex;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
    gap: 10px;
    align-items: center;
    font-family: 'Avenir Next', Avenir, sans-serif;
    font-size: 1em;
}

.facture-row:hover {
    background-color: #f9fafb;
}

.facture-row > div:nth-child(1) { width: 180px; font-weight: 500; }
.facture-row > div:nth-child(2) { flex: 1; min-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facture-row > div:nth-child(3) { width: 110px; text-align: right; font-weight: 600; }
.facture-row > div:nth-child(4) { width: 90px; text-align: center; }
.facture-row > div:nth-child(5) { width: 80px; text-align: center; }

/* ==========================================================================
   TABLEAUX DE CATÉGORIES
   ========================================================================== */

.categorie-table {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.categorie-header {
    display: flex;
    background: #f3f4f6;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid #d1d5db;
    color: #374151;
    gap: 10px;
}

.categorie-header > div:nth-child(1) { width: 220px; }
.categorie-header > div:nth-child(2) { flex: 1; min-width: 100px; }
.categorie-header > div:nth-child(3) { width: 120px; text-align: center; }
.categorie-header > div:nth-child(4) { width: 100px; text-align: center; }

.categorie-row {
    display: flex;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
    gap: 10px;
    align-items: center;
    font-family: 'Avenir Next', Avenir, sans-serif;
    font-size: 1em;
}

.categorie-row:hover {
    background-color: #f9fafb;
}

.categorie-row > div:nth-child(1) { width: 220px; font-weight: 500; }
.categorie-row > div:nth-child(2) { flex: 1; min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.categorie-row > div:nth-child(3) { width: 120px; text-align: center; font-weight: 600; }
.categorie-row > div:nth-child(4) { width: 100px; text-align: center; }

/* ==========================================================================
   ACTIONS ET ICÔNES
   ========================================================================== */

.compta-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.compta-actions a,
.compta-list a,
.categorie-list a {
    text-decoration: none;
    transition: opacity 0.2s;
}

.compta-actions a:hover,
.compta-list a:hover,
.categorie-list a:hover {
    opacity: 0.7;
}

.compta-actions a i {
    font-size: 1.2em;
    color: #059669;
}

.compta-actions a i.fa-eye {
    color: #0284c7;
}

.compta-actions a i.fa-download {
    color: #059669;
}

.compta-actions a i.fa-edit {
    color: #f59e0b;
}

.compta-actions a i.fa-trash-alt {
    color: #ef4444;
}

/* ==========================================================================
   LIENS DE FICHIERS
   ========================================================================== */

.file-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.file-link:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #1f2937;
}

.file-link i {
    color: #059669;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .plan-comptable-grid {
        grid-template-columns: 1fr;
    }
    
    .ecriture-header,
    .ecriture-row,
    .facture-header,
    .facture-row,
    .categorie-header,
    .categorie-row {
        flex-wrap: wrap;
    }
    
    .ecriture-header > div,
    .ecriture-row > div,
    .facture-header > div,
    .facture-row > div,
    .categorie-header > div,
    .categorie-row > div {
        width: 100% !important;
        flex: 1 1 100%;
        text-align: left !important;
        padding: 4px 0;
    }

    .compta-actions {
        justify-content: flex-start;
        padding-top: 8px;
        border-top: 1px solid #e5e7eb;
    }
}