/* ========================================
   SYSTÈME RESPONSIVE AUTOMATIQUE - VERSION CORRIGÉE
   ======================================== */

/* Variables CSS pour la cohérence */
:root {
    --mobile-breakpoint: 768px;
    --tablet-breakpoint: 1024px;
    --desktop-breakpoint: 1200px;
}

/* ========================================
   NAVIGATION AUTOMATIQUE RESPONSIVE
   ======================================== */

/* Ajout automatique du bouton hamburger mobile */
@media (max-width: 767px) {
    /* Bouton hamburger automatique */
    body::before {
        content: '';
        position: fixed;
        top: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
        background: var(--bs-primary, #0d6efd);
        border-radius: 8px;
        z-index: 9999;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833, 37, 41, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: center;
        background-size: 20px;
        display: block;
    }
    
    /* Overlay automatique */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    /* Sidebar automatique responsive */
    .sidebar, 
    .col-md-3, 
    .col-lg-2,
    .col-sm-3,
    .col-xl-2 {
        position: fixed !important;
        top: 0;
        left: 0;
        height: 100vh !important;
        width: 280px !important;
        z-index: 1000;
        transform: translateX(0);
        transition: transform 0.3s ease;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    /* Contenu principal automatique */
    .main-content,
    .col-md-9,
    .col-lg-10,
    .col-sm-9,
    .col-xl-10 {
        margin-left: 280px !important;
        padding-top: 70px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
}

/* ========================================
   COMPOSANTS AUTOMATIQUES RESPONSIVE
   ======================================== */

/* Cartes automatiques */
@media (max-width: 767px) {
    .card {
        margin-bottom: 15px !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }
    
    .card-body {
        padding: 15px !important;
    }
    
    .card-header {
        padding: 15px !important;
        font-size: 14px !important;
    }
    
    .card-footer {
        padding: 15px !important;
    }
}

/* Boutons automatiques */
@media (max-width: 767px) {
    .btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        border-radius: 8px !important;
    }
    
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
    }
    
    .btn-group .btn {
        border-radius: 8px !important;
        margin-bottom: 5px;
    }
    
    .btn-group .btn:first-child {
        border-top-left-radius: 8px !important;
        border-top-right-radius: 8px !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }
    
    .btn-group .btn:last-child {
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-bottom-left-radius: 8px !important;
        border-bottom-right-radius: 8px !important;
    }
    
    .btn-sm {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
    
    .btn-lg {
        padding: 16px 20px !important;
        font-size: 16px !important;
    }
}

/* Formulaires automatiques */
@media (max-width: 767px) {
    .form-control,
    .form-select {
        padding: 12px 16px !important;
        font-size: 16px !important;
        border-radius: 8px !important;
    }
    
    .form-label {
        font-size: 14px !important;
        font-weight: 600 !important;
        margin-bottom: 8px !important;
    }
    
    .input-group {
        flex-direction: column !important;
    }
    
    .input-group .form-control,
    .input-group .form-select {
        border-radius: 8px !important;
        margin-bottom: 5px !important;
    }
    
    .input-group .btn {
        border-radius: 8px !important;
        width: 100% !important;
    }
}

/* Tableaux automatiques */
@media (max-width: 767px) {
    .table-responsive {
        border-radius: 8px !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }
    
    .table {
        font-size: 14px !important;
    }
    
    .table th,
    .table td {
        padding: 8px 12px !important;
        vertical-align: middle !important;
    }
    
    .table thead th {
        background-color: #f8f9fa !important;
        border-bottom: 2px solid #dee2e6 !important;
        font-weight: 600 !important;
    }
}

/* Pagination automatique */
@media (max-width: 767px) {
    .pagination {
        justify-content: center !important;
        flex-wrap: wrap !important;
        margin: 0 !important;
    }
    
    .pagination .page-link {
        padding: 8px 12px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
        margin: 2px !important;
    }
    
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link {
        display: none; /* Cache les flèches sur mobile */
    }
}

/* Alerts automatiques */
@media (max-width: 767px) {
    .alert {
        padding: 15px !important;
        margin-bottom: 15px !important;
        border-radius: 8px !important;
        font-size: 14px !important;
    }
    
    .alert-dismissible .btn-close {
        padding: 15px !important;
    }
}

/* ========================================
   ANIMATIONS ET TRANSITIONS
   ======================================== */

/* Animations d'entrée automatiques */
@media (prefers-reduced-motion: no-preference) {
    .card,
    .btn,
    .form-control,
    .table-responsive {
        transition: all 0.3s ease;
    }
    
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    }
    
    .btn:hover {
        transform: translateY(-1px);
    }
}

/* GPU acceleration pour les transformations */
.sidebar,
.card,
.btn,
.table-responsive {
    will-change: transform;
}

/* ========================================
   IMPRESSION AUTOMATIQUE
   ======================================== */

@media print {
    /* Masquer les éléments non nécessaires à l'impression */
    .sidebar,
    .col-md-3,
    .col-lg-2,
    .btn,
    .pagination,
    .alert {
        display: none !important;
    }
    
    .main-content,
    .col-md-9,
    .col-lg-10 {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        page-break-inside: avoid;
    }
    
    .table {
        font-size: 12px !important;
    }
    
    .table th,
    .table td {
        padding: 4px 8px !important;
    }
    
    /* Optimiser les couleurs pour l'impression */
    .text-primary { color: #000 !important; }
    .text-success { color: #000 !important; }
    .text-warning { color: #000 !important; }
    .text-danger { color: #000 !important; }
    .text-info { color: #000 !important; }
    
    /* Masquer les arrière-plans colorés */
    .bg-primary,
    .bg-success,
    .bg-warning,
    .bg-danger,
    .bg-info {
        background-color: transparent !important;
        color: #000 !important;
    }
}
