/**
 * Page Fixes - Corrections spécifiques pour les pages listées
 * Correction des boutons, alignements, et problèmes de présentation
 */

/* ========================================
   CORRECTIONS DES BOUTONS
   ======================================== */

/* Groupe de boutons - Alignement horizontal */
.btn-group,
.button-group,
.action-buttons,
.form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}

/* Boutons isolés - Espacement */
.btn + .btn {
    margin-left: 0.5rem;
}

/* Correction des boutons dans les headers de cartes */
.card-header .btn,
.card-header .btn-group {
    margin-top: 0;
    margin-bottom: 0;
}

/* Boutons dans les footers */
.card-footer .btn {
    margin-right: 0.5rem;
}

.card-footer .btn:last-child {
    margin-right: 0;
}

/* Boutons d'action sur la droite */
.text-end .btn,
.text-right .btn {
    margin-left: 0.5rem;
}

.text-end .btn:first-child,
.text-right .btn:first-child {
    margin-left: 0;
}

/* Correction des boutons dans les tableaux */
.table .btn {
    display: inline-block !important;
    width: auto !important;
    margin: 0.125rem;
    white-space: nowrap;
    vertical-align: middle !important;
    line-height: 1 !important;
}

.table .btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
}

.table td.text-nowrap,
.table th.text-nowrap {
    white-space: nowrap !important;
    vertical-align: middle !important;
}

.table td.text-nowrap .btn,
.table th.text-nowrap .btn {
    margin: 0 0.125rem;
    vertical-align: middle !important;
}

.table td.text-nowrap .btn:first-child,
.table th.text-nowrap .btn:first-child {
    margin-left: 0;
}

.table td.text-nowrap .btn:last-child,
.table th.text-nowrap .btn:last-child {
    margin-right: 0;
}

.table .btn-group {
    gap: 0.25rem;
    display: inline-flex !important;
    width: auto !important;
    vertical-align: middle !important;
}

/* Uniformiser l'alignement vertical de toutes les cellules */
.table tbody td {
    vertical-align: middle !important;
}

.table thead th {
    vertical-align: middle !important;
}

/* Empêcher les écarts entre les lignes */
.table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

.table tbody tr {
    margin: 0 !important;
    padding: 0 !important;
}

.table td.text-nowrap {
    position: relative !important;
}

.table td.text-nowrap .btn {
    position: relative !important;
    float: none !important;
}

/* Réduire la hauteur des badges dans les tableaux */
.table .badge {
    padding: 0.25em 0.5em !important;
    font-size: 0.875em !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

/* Boutons pleine largeur sur mobile */
@media (max-width: 576px) {
    /* Exception pour les boutons dans les tableaux DataTables */
    .btn:not(.btn-sm):not(.btn-lg):not(.table .btn):not(.dataTables_wrapper .btn) {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group:not(.table .btn-group) {
        flex-direction: column;
        width: 100%;
    }

    .btn-group:not(.table .btn-group) .btn {
        width: 100%;
        margin: 0.25rem 0;
    }

    /* Boutons d'action dans les tableaux restent compacts */
    .table .btn,
    .dataTables_wrapper .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .table .btn i {
        font-size: 0.875rem;
    }
}

/* ========================================
   CORRECTIONS DES FORMULAIRES
   ======================================== */

/* Labels et inputs bien espacés */
.form-group,
.mb-3 {
    margin-bottom: 1rem !important;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Inputs en largeur complète */
.form-control,
.form-select,
textarea.form-control {
    width: 100%;
    max-width: 100%;
}

/* Select2 - Styles centralises dans /assets/css/select2-dark-theme.css */

/* Input groups correctement alignés */
.input-group {
    display: flex;
    flex-wrap: nowrap;
}

.input-group > * {
    flex: 1 1 auto;
}

/* ========================================
   CORRECTIONS DES TABLEAUX
   ======================================== */

/* Tableaux responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Correction des cellules d'action */
.table td:last-child,
.table th:last-child {
    white-space: nowrap;
}

/* DataTables - Correction des contrôles */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 0.5rem 0;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_paginate {
    padding: 0.5rem 0;
}

/* Correction des badges dans les tableaux */
.table .badge {
    display: inline-block;
    white-space: nowrap;
}

/* DataTables responsive sur mobile */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_length label,
    .dataTables_wrapper .dataTables_filter label {
        justify-content: center;
    }

    /* Réduire la taille des contrôles de pagination */
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }

    /* Scroll horizontal pour les tableaux larges */
    .dataTables_wrapper {
        overflow-x: auto;
    }

    .card .table-responsive,
    .card-body > .table-responsive {
        margin-left: -1.25rem;
        margin-right: -1.25rem;
        margin-bottom: -1.25rem;
        border-radius: 0;
    }
}

@media (max-width: 576px) {
    /* Masquer certaines colonnes sur très petits écrans */
    .table thead th:first-child {
        min-width: 40px;
    }

    /* Réduire encore plus la pagination */
    .dataTables_wrapper .dataTables_paginate {
        font-size: 0.75rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.2rem 0.4rem;
        margin: 0 0.1rem;
    }
}

/* ========================================
   CORRECTIONS DES CARTES
   ======================================== */

/* En-têtes de cartes avec boutons */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5 {
    margin-bottom: 0;
    flex: 1;
}

.card-header .btn-group,
.card-header .action-buttons {
    margin-bottom: 0;
}

/* Corps de carte avec padding uniforme */
.card-body {
    padding: 1.25rem;
}

/* Footer de carte */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
}

/* ========================================
   CORRECTIONS DES MODALS
   ======================================== */

/* Footer de modal avec boutons alignés */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal-footer .btn {
    margin: 0;
}

/* Modal body avec bon espacement */
.modal-body {
    padding: 1.5rem;
}

.modal-body .form-group:last-child,
.modal-body .mb-3:last-child {
    margin-bottom: 0 !important;
}

/* ========================================
   CORRECTIONS DES TITRES
   ======================================== */

/* Titres de page */
.page-title,
h1.mb-4,
h1.mb-3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem !important;
}

.page-title i,
h1 i {
    flex-shrink: 0;
}

/* ========================================
   CORRECTIONS DES ROWS ET COLUMNS
   ======================================== */

/* Correction des espacements de rows */
.row {
    margin-bottom: 1rem;
}

.row:last-child {
    margin-bottom: 0;
}

/* Correction des colonnes */
.col,
[class*="col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* ========================================
   CORRECTIONS DES BREADCRUMBS
   ======================================== */

.breadcrumb {
    background: transparent;
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
}

/* ========================================
   CORRECTIONS DES ALERTS
   ======================================== */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.alert i {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert .btn-close {
    margin-left: auto;
}

/* ========================================
   CORRECTIONS DES TABS
   ======================================== */

.nav-tabs {
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    white-space: nowrap;
}

.tab-content {
    padding: 1rem 0;
}

/* ========================================
   CORRECTIONS SPÉCIFIQUES PAR PAGE
   ======================================== */

/* Page role-list, user-list */
.user-list-actions,
.role-list-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Page accueil - Widgets dashboard */
.dashboard-widget {
    margin-bottom: 1.5rem;
}

.dashboard-widget .card {
    height: 100%;
}

.dashboard-widget .card-body {
    display: flex;
    flex-direction: column;
}

/* Page roadmap-gantt-project */
#gantt_here {
    width: 100%;
    height: 600px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    overflow: hidden;
}

/* Page FAQ et Lexique */
.faq-item,
.lexique-item {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: rgba(0, 0, 70, 0.3);
    border-radius: 8px;
    border-left: 4px solid var(--color-primary-text, #5dade2);
}

.faq-question,
.lexique-term {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--color-primary-text, #5dade2);
}

.faq-answer,
.lexique-definition {
    color: var(--text-primary, #f0f0f0);
    line-height: 1.6;
}

/* Page menu-permissions, widget-permissions */
.permission-matrix {
    overflow-x: auto;
}

.permission-matrix table {
    min-width: 800px;
}

.permission-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Page db-sync, db-config-editor */
.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background-color: rgba(0, 0, 70, 0.5);
}

.sync-status.success {
    background-color: rgba(40, 167, 69, 0.2);
    border-left: 4px solid var(--color-success-text, #5fd68a);
}

.sync-status.error {
    background-color: rgba(220, 53, 69, 0.2);
    border-left: 4px solid var(--color-danger-text, #f5989d);
}

.sync-status.pending {
    background-color: rgba(255, 193, 7, 0.2);
    border-left: 4px solid var(--color-warning-text, #ffc107);
}

/* Page liste-projets */
.liste-projets-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

@media (max-width: 576px) {
    .liste-projets-header {
        flex-direction: column;
        align-items: stretch;
    }

    .liste-projets-header .btn {
        width: 100%;
    }
}

/* Page OVH API Management */
@media (max-width: 768px) {
    /* Alertes d'aide plus compactes sur mobile */
    .alert h5 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .alert h6 {
        font-size: 0.9rem;
        margin-top: 1rem;
        margin-bottom: 0.5rem;
    }

    .alert ol,
    .alert ul {
        padding-left: 1.25rem;
        font-size: 0.9rem;
    }

    .alert code {
        font-size: 0.8rem;
        word-break: break-all;
    }

    .alert .alert {
        margin-top: 0.75rem;
        margin-bottom: 0;
        padding: 0.75rem;
    }

    .alert .bg-dark {
        padding: 0.5rem;
        font-size: 0.85rem;
        overflow-x: auto;
    }
}

@media (max-width: 576px) {
    /* Container fluid avec moins de padding */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Titres de page plus compacts */
    h1 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .text-muted {
        font-size: 0.85rem;
    }

    /* Alertes encore plus compactes sur très petits écrans */
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    .alert h5 {
        font-size: 0.95rem;
    }

    .alert h6 {
        font-size: 0.85rem;
    }

    .alert ol,
    .alert ul {
        font-size: 0.85rem;
    }
}

/* Page infra-graph */
#network-graph {
    width: 100%;
    height: 700px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    background-color: rgba(0, 0, 60, 0.3);
}

/* Pages Stormshield */
.stormshield-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1rem;
    background-color: rgba(0, 0, 70, 0.4);
    border-radius: 8px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary-text, #5dade2);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #b0b0b0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   CORRECTIONS DES SUMMERNOTE
   ======================================== */

.note-editor {
    border: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    overflow: hidden;
}

.note-editor .note-toolbar {
    background-color: rgba(0, 0, 70, 0.5);
    border-bottom: 1px solid var(--border-light, rgba(255, 255, 255, 0.1));
}

.note-editor .note-editable {
    background-color: rgba(0, 0, 60, 0.3);
    color: var(--text-primary, #f0f0f0);
    min-height: 200px;
}

/* ========================================
   CORRECTIONS DES SPINNERS
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

.loading-text {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
}

/* ========================================
   UTILITAIRES DE CORRECTION
   ======================================== */

/* Correction overflow */
.overflow-auto {
    overflow: auto;
}

.overflow-hidden {
    overflow: hidden;
}

/* Correction du text wrapping */
.text-nowrap {
    white-space: nowrap;
}

.text-wrap {
    white-space: normal;
}

/* Alignement vertical */
.align-middle {
    vertical-align: middle !important;
}

/* Espacement uniforme */
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

/* Padding uniforme */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

/* Display utilities - COMMENTÉ car écrase Bootstrap responsive classes
   Bootstrap gère déjà ces classes avec media queries
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-none { display: none !important; }
*/

/* Flexbox utilities */
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-start { justify-content: flex-start !important; }

.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }

.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }

/* ========================================
   PRINT FIXES
   ======================================== */

@media print {
    .btn,
    .btn-group,
    .pagination,
    .action-buttons,
    .card-header .btn {
        display: none !important;
    }

    .card {
        page-break-inside: avoid;
    }

    .table {
        page-break-inside: auto;
    }

    .table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}
