/* ===========================================
   Ratio Locaux — Feuille de styles principale
   =========================================== */

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
    color: #333;
    line-height: 1.6;
}

h1, h2, h3 {
    font-family: 'Catamaran', sans-serif;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: left;
    line-height: 1.3;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    color: #1a365d;
    margin: 0;
    padding: 0;
    text-decoration: none;
    border-bottom: 3px solid #3182ce;
    padding-bottom: 10px;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 15px;
}

h3 {
    font-size: 17px;
    font-weight: 700;
}

a {
    color: #3182ce;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #2c5282;
    text-decoration: underline;
}

/* ===========================================
   Layout principal
   =========================================== */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* Header / Titre principal */
.admin-container > .admin-title {
    margin-bottom: 30px;
}

.forms-wrapper,
.lists-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

/* ===========================================
   Section Comptes administratifs
   =========================================== */
.presentations-wrapper {
    margin-bottom: 30px;
}

.presentation-card {
    background: #ffffff;
    padding: 24px;
    border: 1px solid #e2e8f0;
}

.presentation-card h3 {
    font-family: 'Catamaran', sans-serif;
    font-weight: 800;
    font-size: 17px;
    color: #1a365d;
    margin: 0 0 12px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.presentation-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.presentation-list li {
    padding: 10px 0;
    border-bottom: 1px solid #edf2f7;
    font-size: 14px;
    line-height: 1.5;
}

.presentation-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.presentation-list li a {
    color: #3182ce;
    font-weight: 600;
    text-decoration: none;
}

.presentation-list li a:hover {
    text-decoration: underline;
}

.presentation-desc {
    color: #718096;
    font-size: 13px;
}

/* ===========================================
   Cards / Formulaires
   =========================================== */
.admin-form {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s ease;
}

.admin-form:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.admin-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #4a5568;
    font-size: 14px;
    letter-spacing: 0.01em;
}

.admin-form input[type="text"],
.admin-form select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    color: #2d3748;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.admin-form input[type="text"]:focus,
.admin-form select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15);
}

.admin-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
    accent-color: #3182ce;
}

.admin-form input[type="submit"] {
    background-color: #3182ce;
    color: white;
    padding: 11px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s ease, transform 0.1s ease;
    letter-spacing: 0.02em;
}

.admin-form input[type="submit"]:hover {
    background-color: #2c5282;
}

.admin-form input[type="submit"]:active {
    transform: scale(0.98);
}

.btn-effacer {
    display: inline-block;
    margin-top: 8px;
    color: #718096;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.2s ease;
}

.btn-effacer:hover {
    color: #e53e3e;
    text-decoration: underline;
}

/* Radio buttons */
.admin-form input[type="radio"] {
    margin-right: 6px;
    accent-color: #3182ce;
}

.admin-form .checkbox-container {
    display: flex;
    align-items: center;
}

.admin-form .checkbox-container label {
    margin-bottom: 0;
}

/* ===========================================
   Sections surlignées (blue)
   =========================================== */
.blue {
    background-color: #ebf8ff;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid #bee3f8;
    border-radius: 8px;
}

.rounded {
    border-radius: 8px;
}

.shadow {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ===========================================
   Query Buttons (Super requêtes +/-)
   =========================================== */
.query-buttons {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    justify-content: center;
}

.query-buttons button {
    background-color: #3182ce;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.query-buttons button:hover {
    background-color: #2c5282;
}

/* ===========================================
   Listes (requêtes et super requêtes)
   =========================================== */
.admin-list-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e2e8f0;
}

.admin-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-list-item {
    padding: 12px 10px;
    border-bottom: 1px solid #edf2f7;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    transition: background-color 0.15s ease;
}

.admin-list-item:hover {
    background-color: #f7fafc;
}

.admin-list-item:last-child {
    border-bottom: none;
}

.admin-list-item a {
    color: #3182ce;
    text-decoration: none;
}

.admin-list-item a:hover {
    text-decoration: underline;
}

.admin-link {
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.admin-link.edit-link {
    color: #2f855a;
    background-color: #f0fff4;
}

.admin-link.edit-link:hover {
    background-color: #c6f6d5;
    text-decoration: none;
}

.admin-link.delete-link {
    color: #c53030;
    background-color: #fff5f5;
}

.admin-link.delete-link:hover {
    background-color: #fed7d7;
    text-decoration: none;
}

/* ===========================================
   Résultats
   =========================================== */
.results-container {
    margin-top: 25px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.results-container h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2d3748;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.result-item {
    margin-bottom: 15px;
    padding: 16px;
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    border-radius: 8px;
    font-size: 14px;
}

.result-item.total {
    background: #ebf8ff;
    font-weight: bold;
    border: 2px solid #3182ce;
    border-radius: 8px;
}

.result-item h4 {
    font-size: 15px;
    margin-bottom: 8px;
    color: #2c5282;
    font-weight: 700;
}

.result-item p {
    margin: 5px 0;
    font-size: 14px;
}

.result-item a {
    color: #3182ce;
    text-decoration: none;
    font-size: 13px;
}

.result-item a:hover {
    text-decoration: underline;
}

/* ===========================================
   Tables
   =========================================== */
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-family: 'Open Sans', Arial, sans-serif;
    font-size: 14px;
    margin-top: 15px;
}

thead th {
    background-color: #2d3748;
    color: white;
    font-weight: 600;
    border: 1px solid #2d3748;
    padding: 10px 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

tbody td, tbody th {
    border: 1px solid #e2e8f0;
    padding: 9px 12px;
}

tbody tr:hover {
    background-color: #f7fafc;
}

/* Niveaux hiérarchiques */
.level-1 {
    font-weight: bold;
    background-color: #e2e8f0;
}

.level-2 {
    font-weight: 600;
    background-color: #edf2f7;
}

.level-3 {
    background-color: #f7fafc;
}

.right-align {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Cellules cliquables */
.toggle-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 5px;
    color: #c53030;
    font-weight: bold;
    cursor: pointer;
}

.code-cell {
    cursor: pointer;
    white-space: nowrap;
}

.code-cell:hover {
    background-color: rgba(49, 130, 206, 0.08);
}

/* Lignes expandables */
.expandable {
    cursor: pointer;
}

.expandable.collapsed + tr {
    display: none;
}

/* Détails des comptes */
.compte-detail {
    background-color: #fff;
}

.compte-detail td {
    padding-left: 25px;
}

/* ===========================================
   Comparaisons multi-entités
   =========================================== */
.comparison-form {
    position: relative;
}

.comparison-form.with-remove-button {
    padding-right: 50px;
}

.btn-remove-entity {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    padding: 0;
    transition: background-color 0.2s ease;
}

.btn-remove-entity:hover {
    background: #c53030;
}

.entity-separator {
    height: 20px;
    border-bottom: 3px dashed #e2e8f0;
    margin: 20px 0;
}

.comparison-search[value]:not([value=""]) {
    background-color: #ebf8ff;
    font-weight: 500;
}

/* ===========================================
   Tooltip
   =========================================== */
.info-icon {
    margin-left: 5px;
    cursor: help;
    font-size: 0.9em;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.info-icon:hover {
    opacity: 1;
}

.tooltip-content {
    text-align: left;
    font-size: 0.9em;
    white-space: nowrap;
}

.tooltip-content div {
    margin: 2px 0;
}

/* Liens vue nature */
.nature-link {
    color: #3182ce;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.nature-link:hover {
    background-color: #ebf8ff;
    text-decoration: underline;
    color: #2c5282;
}

.nature-link:active {
    background-color: #bee3f8;
}

/* ===========================================
   Page Détails (details_query.php)
   =========================================== */

/* Layout pleine largeur pour les tableaux financiers */
.admin-container:has(.details-query-form) {
    max-width: 98vw;
    padding: 20px 24px;
}

/* --- Formulaire de recherche --- */
.details-query-form {
    margin-bottom: 30px;
    max-width: 560px;
    padding: 20px 24px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.details-query-form h2 {
    font-size: 18px;
    margin-bottom: 14px;
    color: #1a365d;
    font-weight: 700;
    border: none;
    padding-bottom: 0;
}

/* --- Résumé de la requête --- */
.query-summary {
    background-color: #fafbfc;
    border-left: 3px solid #3182ce;
    border-radius: 0 6px 6px 0;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 12.5px;
    line-height: 1.8;
    color: #4a5568;
}

.query-summary p {
    margin: 2px 0;
}

.query-summary strong {
    color: #2d3748;
}

/* --- Conteneur des tableaux de données --- */
.table-container {
    margin-bottom: 20px;
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
    padding: 0;
}

.table-container table {
    margin-top: 0;
    border-radius: 10px;
    overflow: hidden;
    font-size: 13px;
}

/* En-tête des entités (bande d'info principale) */
thead th.entity {
    background: #1e3a5f;
    color: #e8eef5;
    font-weight: 500;
    border: none;
    border-bottom: 1px solid #2d4a6f;
    padding: 10px 14px;
    font-size: 12.5px;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
}

thead th.entity:first-child {
    border-right: 1px solid #2d4a6f;
}

thead th.entity a {
    color: #90cdf4;
    text-decoration: underline;
    text-decoration-color: rgba(144,205,244,0.4);
}

thead th.entity a:hover {
    color: #fff;
    text-decoration-color: #fff;
}

/* En-têtes de colonnes (Code, Libellé, etc.) */
.table-container thead th:not(.entity) {
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: none;
    border-bottom: 2px solid #cbd5e1;
    padding: 8px 12px;
    white-space: nowrap;
}

/* Corps du tableau */
.table-container tbody td {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 7px 12px;
    font-size: 12.5px;
    color: #334155;
}

.table-container tbody tr:last-child td {
    border-bottom: none;
}

.table-container tbody tr:hover {
    background-color: #f8fafc;
}

/* Niveaux hiérarchiques dans les tableaux de détail */
.table-container .level-1 {
    background-color: #f0f4f8;
    font-weight: 700;
}

.table-container .level-1 td {
    border-bottom-color: #d0d7e0;
    color: #1e293b;
    padding-top: 9px;
    padding-bottom: 9px;
}

.table-container .level-2 {
    background-color: #f7f9fb;
    font-weight: 600;
}

.table-container .level-2 td {
    color: #334155;
}

.table-container .level-3 {
    background-color: #fff;
}

/* Niveaux 4 et 5 (sous-détails MXX) */
.table-container .level-4 {
    background-color: #fcfcfd;
    font-size: 12px;
    font-style: normal;
    color: #64748b;
}

.table-container .level-4 td:first-child {
    padding-left: 48px !important;
}

.table-container .level-5 {
    background-color: #fafbfc;
    font-size: 11.5px;
}

.table-container .level-5 td:first-child {
    padding-left: 64px !important;
}

/* Parents MXX (lignes de regroupement) */
.table-container .mxx-parent.level-1 {
    background-color: #e8edf3;
}

.table-container .mxx-parent.level-2 {
    background-color: #eff2f7;
}

/* --- Toggle nomenclature MXX --- */
.mxx-toggle {
    margin-bottom: 16px;
    padding: 9px 14px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mxx-toggle label {
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 500;
    color: #475569;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mxx-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3182ce;
}

/* --- Badges et indicateurs --- */
.original-code {
    font-size: 0.8em;
    color: #94a3b8;
    font-style: italic;
}

.nomenclature-indicator {
    display: inline-block;
    margin-right: 8px;
    padding: 2px 8px;
    background-color: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    font-size: 0.85em;
    color: #cbd5e1;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* --- Lien vers les agrégats --- */
.agregats-link {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #90cdf4 !important;
    font-size: 0.85em;
    transition: all 0.2s ease;
    text-decoration: none !important;
}

.agregats-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff !important;
    border-color: rgba(255,255,255,0.3);
}

/* Lien JSON dans les en-têtes */
.json-link {
    color: #90cdf4 !important;
    font-size: 0.85em;
    text-decoration: none !important;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.json-link:hover {
    opacity: 1;
    color: #fff !important;
    text-decoration: underline !important;
}

/* Libellés non référencés */
.label-unknown {
    color: #d97706;
    font-style: italic;
    font-size: 0.95em;
}

/* --- Formulaire de comparaison --- */
.comparison-form {
    position: relative;
    background: #f8fafc;
    border: 1px dashed #cbd5e0;
    border-radius: 8px;
    padding: 14px 18px;
    margin-top: 0;
}

.comparison-form.with-remove-button {
    padding-right: 50px;
}

.comparison-form label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

.comparison-form .comparison-search {
    border: 1px solid #cbd5e0;
    background: #fff;
    font-size: 13px;
    padding: 8px 12px;
}

.comparison-form .comparison-search:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.12);
    outline: none;
}

.comparison-search[value]:not([value=""]) {
    background-color: #f0f7ff;
    font-weight: 500;
    border-color: #93c5fd;
}

/* --- Séparateur entre entités --- */
.entity-separator {
    height: 1px;
    border: none;
    border-bottom: none;
    margin: 16px 0;
    background: transparent;
}

/* --- Bouton suppression entité --- */
.btn-remove-entity {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 16px;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.btn-remove-entity:hover {
    background: #dc2626;
}

/* --- Montants: alignement et style --- */
.table-container .right-align {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    white-space: nowrap;
}

/* Cellules cliquables dans les tableaux */
.table-container .code-cell {
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.table-container .code-cell:hover {
    background-color: rgba(49, 130, 206, 0.06);
}

.table-container .toggle-icon {
    display: inline-block;
    width: 18px;
    text-align: center;
    margin-right: 4px;
    color: #3182ce;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}

/* Comptes détaillés */
.table-container .compte-detail {
    background-color: #fefefe;
}

.table-container .compte-detail td {
    color: #64748b;
    font-size: 12px;
}

/* Info icon dans les tableaux */
.table-container .info-icon {
    margin-left: 4px;
    font-size: 0.8em;
    opacity: 0.4;
}

.table-container .info-icon:hover {
    opacity: 0.9;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 900px) {
    .forms-wrapper,
    .lists-wrapper {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .admin-container {
        padding: 15px 10px;
    }

    .admin-container:has(.details-query-form) {
        padding: 10px 8px;
    }

    h1 {
        font-size: 22px;
    }

    .admin-form {
        padding: 16px;
    }

    .admin-form label {
        font-size: 13px;
    }

    .admin-form input[type="text"],
    .admin-form select {
        font-size: 13px;
        padding: 9px 10px;
    }

    .admin-form input[type="submit"] {
        font-size: 13px;
    }

    .admin-list-item {
        font-size: 13px;
        padding: 10px 8px;
    }

    .query-buttons button {
        font-size: 13px;
        padding: 7px 14px;
    }

    table {
        font-size: 12px;
    }

    thead th,
    tbody td,
    tbody th {
        padding: 6px 8px;
    }

    .details-query-form {
        max-width: 100%;
    }

    .table-container {
        border-radius: 6px;
    }

    .table-container table {
        font-size: 11px;
    }

    .table-container thead th:not(.entity) {
        font-size: 10px;
        padding: 6px 8px;
    }

    .table-container tbody td {
        padding: 5px 8px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 19px;
    }

    .admin-form {
        padding: 12px;
    }

    .blue {
        padding: 10px 12px;
    }
}
