/**
 * CORRECTION INTERFACE GHOLAMI V3
 * Version: 1.0 - 16/12/2025
 * 
 * Corrige le problème de boutons écrasés/cachés dans la page Calcul Frais Déplacement
 * Compatible avec les versions locale et Hostinger
 */

/* ================================================================
   CORRECTION HEADER PAGE - Layout Flexible
   ================================================================ */

.page-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 24px !important;
    padding: 16px 20px !important;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap !important;
    gap: 16px !important;
    position: relative;
    z-index: 100;
}

.page-header h1 {
    margin: 0 !important;
    font-size: 24px;
    color: #0f1a2e;
    flex: 1 1 auto;
}

.page-header > div:last-child,
.page-header .btn-group {
    display: flex !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
    align-items: center;
}

/* ================================================================
   CORRECTION BOUTONS - Visibilité Maximale
   ================================================================ */

.btn,
button {
    position: relative !important;
    z-index: 10 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 16px !important;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    min-width: 100px;
}

/* Bouton Primaire */
.btn-primary {
    background: #0f1a2e !important;
    color: white !important;
    border-color: #0f1a2e !important;
}

.btn-primary:hover {
    background: #1a2942 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(15, 26, 46, 0.2);
}

/* Bouton Danger (Supprimer) */
.btn-danger {
    background: #dc3545 !important;
    color: white !important;
    border-color: #dc3545 !important;
}

.btn-danger:hover {
    background: #c82333 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.2);
}

/* Bouton Warning (Purger) */
.btn-warning {
    background: #ffc107 !important;
    color: #000 !important;
    border-color: #ffc107 !important;
}

.btn-warning:hover {
    background: #e0a800 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.2);
}

/* Bouton Secondary */
.btn-secondary {
    background: #6c757d !important;
    color: white !important;
    border-color: #6c757d !important;
}

.btn-secondary:hover {
    background: #5a6268 !important;
}

/* Bouton Success */
.btn-success {
    background: #28a745 !important;
    color: white !important;
    border-color: #28a745 !important;
}

.btn-success:hover {
    background: #218838 !important;
}

/* Bouton Info */
.btn-info {
    background: #17a2b8 !important;
    color: white !important;
    border-color: #17a2b8 !important;
}

.btn-info:hover {
    background: #138496 !important;
}

/* ================================================================
   CORRECTION TABLEAU - Actions Visibles
   ================================================================ */

.table-actions,
td.table-actions,
th.actions {
    white-space: nowrap !important;
    text-align: right !important;
    min-width: 150px !important;
    padding: 8px 12px !important;
}

.table-actions .btn,
.table-actions button {
    margin-left: 4px !important;
    margin-right: 4px !important;
    min-width: auto !important;
    padding: 6px 12px !important;
}

.table-actions .btn-icon {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

/* ================================================================
   CORRECTION CARDS - Layout Propre
   ================================================================ */

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 24px;
    overflow: visible !important;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.card-body {
    padding: 20px;
}

/* ================================================================
   CORRECTION FILTRES - Layout Horizontal
   ================================================================ */

.filters,
.filter-section {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
}

/* ================================================================
   CORRECTION PAGE SPÉCIFIQUE - Calcul Frais Déplacement
   ================================================================ */

/* Container principal */
[data-page="frais-deplacement"] .page-header,
.deplacement-page .page-header {
    min-height: 80px;
}

[data-page="frais-deplacement"] .btn-group,
.deplacement-page .btn-group {
    min-width: 300px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #B8956A;
}

/* Table déplacements */
.deplacement-list {
    overflow-x: auto;
}

.deplacement-list table {
    width: 100%;
    border-collapse: collapse;
}

.deplacement-list th,
.deplacement-list td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.deplacement-list th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 5;
}

/* ================================================================
   CORRECTION BADGES - Statut Lisible
   ================================================================ */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ================================================================
   CORRECTION RESPONSIVENESS - Mobile/Tablet
   ================================================================ */

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .page-header .btn-group {
        width: 100%;
        justify-content: stretch;
    }
    
    .page-header .btn {
        flex: 1 1 auto;
        min-width: auto;
    }
    
    .table-actions {
        display: flex !important;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .btn {
        font-size: 12px;
        padding: 6px 12px !important;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
}

/* ================================================================
   CORRECTION Z-INDEX - Hiérarchie Visuelle
   ================================================================ */

.dropdown-menu,
.modal {
    z-index: 1000 !important;
}

.modal-backdrop {
    z-index: 999 !important;
}

/* ================================================================
   CORRECTIONS UTILITAIRES
   ================================================================ */

/* Espacement */
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }

/* Alignement */
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }

/* Flex */
.d-flex { display: flex !important; }
.flex-wrap { flex-wrap: wrap !important; }
.justify-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }

/* Visibilité */
.visible { 
    visibility: visible !important; 
    opacity: 1 !important;
    display: block !important;
}

/* ================================================================
   CORRECTION SPÉCIFIQUE - Boutons du Header
   ================================================================ */

/* Forcer visibilité des boutons de suppression/purge */
button[onclick*="delete"],
button[onclick*="purge"],
button[onclick*="Purge"],
button[onclick*="supprimer"],
.btn-danger,
.btn-warning {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 50 !important;
}

/* ================================================================
   FIN DU FICHIER DE CORRECTION
   ================================================================ */
