/**
 * Styles CSS Responsive - Application CoolCare
 * Corrections et améliorations pour le responsive design
 * Prestataire: Taaazzz-prog
 * Client: CoolCare
 */

/* ==========================================
   CORRECTIONS RESPONSIVE GÉNÉRALES
   ========================================== */

/* Header responsive amélioré */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--gray-700);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary-color);
}

/* User info responsive */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.user-name {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ==========================================
   CORRECTIONS TABLEAUX DATATABLES
   ========================================== */

/* Container responsive pour tableaux */
.table-container {
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin: 1rem 0;
    position: relative;
}

/* Tableaux responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    min-width: 800px; /* Largeur minimale pour éviter l'écrasement */
}

.table th,
.table td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.875rem;
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    white-space: nowrap;
}

.table td {
    color: var(--gray-800);
}

/* Responsive pour colonnes spécifiques */
.table th:first-child,
.table td:first-child {
    padding-left: 1rem;
}

.table th:last-child,
.table td:last-child {
    padding-right: 1rem;
}

/* Actions column responsive */
.actions-column {
    white-space: nowrap;
    width: 120px;
}

.btn-action {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    display: inline-block;
    margin: 0.125rem;
    transition: var(--transition);
}

.btn-action.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-action.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ==========================================
   CORRECTIONS FILTRES ET ACTIONS
   ========================================== */

/* Filtres responsive */
.filters-section {
    margin: 1rem 0;
}

.filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: end;
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
    flex: 1;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.25rem;
}

.filter-select {
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background: var(--white);
}

/* Actions bar responsive */
.actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.actions-left,
.actions-right {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    width: 200px;
    max-width: 100%;
}

/* ==========================================
   CORRECTIONS STATISTIQUES
   ========================================== */

/* Stats grid responsive */
.stats-section {
    margin: 2rem 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    border: 1px solid var(--gray-200);
}

.stat-card h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-card p {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin: 0;
}

/* ==========================================
   CORRECTIONS FORMULAIRES
   ========================================== */

/* Page header responsive */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--gray-600);
    font-size: 1rem;
}

/* Boutons responsive */
.btn-primary,
.btn-secondary {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

/* ==========================================
   MEDIA QUERIES RESPONSIVE
   ========================================== */

/* Mobile Small (jusqu'à 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .nav {
        justify-content: center;
        order: 2;
    }
    
    .user-info {
        order: 1;
        justify-content: space-between;
    }
    
    .user-name {
        font-size: 0.75rem;
        max-width: 150px;
    }
    
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .actions-left,
    .actions-right {
        justify-content: center;
    }
    
    .search-input {
        width: 100%;
    }
    
    .filters-container {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .filter-group {
        min-width: unset;
    }
    
    .table-container {
        margin: 0.5rem 0;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .page-header p {
        font-size: 0.875rem;
    }
}

/* Mobile (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .actions-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .actions-left,
    .actions-right {
        justify-content: center;
    }
    
    .search-input {
        width: 100%;
        max-width: 300px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        font-size: 0.8125rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablette (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .header-content {
        flex-wrap: nowrap;
    }
    
    .nav {
        flex-wrap: nowrap;
    }
    
    .user-name {
        max-width: 250px;
    }
    
    .actions-bar {
        flex-wrap: nowrap;
    }
    
    .search-input {
        width: 250px;
    }
    
    .filters-container {
        flex-wrap: nowrap;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Desktop (1025px et plus) */
@media (min-width: 1025px) {
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
    
    .container {
        max-width: 1200px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* ==========================================
   CORRECTIONS DATATABLES RESPONSIVE
   ========================================== */

/* DataTables responsive fixes */
.dataTables_wrapper {
    width: 100%;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 1rem;
}

.dataTables_wrapper .dataTables_paginate {
    text-align: center;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.5rem 0.75rem;
    margin: 0 0.125rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--white);
}

/* Mobile DataTables adaptations */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_info {
        text-align: center;
        font-size: 0.875rem;
    }
    
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Masquer certaines colonnes sur mobile */
    .table .d-none-mobile {
        display: none;
    }
}

/* ==========================================
   CORRECTIONS BADGES ET STATUTS
   ========================================== */

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge.badge-success {
    background: var(--secondary-color);
    color: var(--white);
}

.badge.badge-warning {
    background: var(--warning-color);
    color: var(--white);
}

.badge.badge-danger {
    background: var(--danger-color);
    color: var(--white);
}

.badge.badge-info {
    background: var(--primary-light);
    color: var(--white);
}

.badge.badge-secondary {
    background: var(--gray-500);
    color: var(--white);
}

/* ==========================================
   CORRECTIONS ALERTS ET MESSAGES
   ========================================== */

.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin: 1rem 0;
    border: 1px solid transparent;
    font-size: 0.875rem;
}

.alert-success {
    background: #f0fdf4;
    color: var(--secondary-color);
    border-color: #bbf7d0;
}

.alert-warning {
    background: #fffbeb;
    color: var(--warning-color);
    border-color: #fed7aa;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger-color);
    border-color: #fecaca;
}

.alert-info {
    background: #eff6ff;
    color: var(--primary-color);
    border-color: #bfdbfe;
}

/* ==========================================
   CORRECTIONS LOADING ET SPINNER
   ========================================== */

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--gray-600);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   CORRECTIONS ACCESSIBILITÉ
   ========================================== */

/* Focus visible amélioré */
*:focus {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

/* Skip link pour navigation clavier */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--white);
    padding: 8px;
    text-decoration: none;
    border-radius: var(--border-radius);
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* ==========================================
   CORRECTIONS PERFORMANCE
   ========================================== */

/* Optimisation des animations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimisation des images */
img {
    max-width: 100%;
    height: auto;
}

/* ==========================================
   CORRECTIONS IMPRESSION
   ========================================== */

@media print {
    .header,
    .actions-bar,
    .filters-section,
    .btn-primary,
    .btn-secondary,
    .pagination {
        display: none !important;
    }
    
    .table-container {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
    
    .table th,
    .table td {
        border: 1px solid var(--gray-300);
        padding: 0.5rem;
    }
    
    body {
        font-size: 12px;
        line-height: 1.4;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
}

/* ==========================================
   AMÉLIORATION TABLES ADMINISTRATION
   ========================================== */

/* Tables d'administration responsive */
.admin-table-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 1rem;
}

.admin-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-table-scroll table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

.admin-table-scroll th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.admin-table-scroll td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

.admin-table-scroll tr:hover {
    background: #f8f9fa;
}

/* Actions de table responsive */
.table-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.table-actions .btn {
    white-space: nowrap;
    min-width: auto;
}

/* Contrôles de recherche et filtres */
.admin-controls-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.admin-search-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
    min-width: 200px;
}

.admin-filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Pagination responsive */
.admin-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.admin-pagination .btn {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   RESPONSIVE MOBILE POUR ADMINISTRATION
   ========================================== */

@media (max-width: 768px) {
    /* Tables mobiles */
    .admin-table-scroll {
        border-radius: 6px;
    }
    
    .admin-table-scroll table {
        min-width: 600px;
    }
    
    .admin-table-scroll th,
    .admin-table-scroll td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    .admin-table-scroll th {
        padding: 0.75rem 0.5rem;
    }
    
    /* Actions de table mobiles */
    .table-actions {
        flex-direction: column;
        gap: 0.25rem;
        align-items: stretch;
    }
    
    .table-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Contrôles mobiles */
    .admin-controls-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .admin-search-group {
        flex-direction: column;
        align-items: stretch;
        min-width: unset;
    }
    
    .admin-search-group input {
        width: 100%;
    }
    
    .admin-filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .admin-filter-group select {
        width: 100%;
    }
    
    /* Pagination mobile */
    .admin-pagination {
        gap: 0.25rem;
    }
    
    .admin-pagination .btn {
        min-width: 35px;
        height: 35px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    /* Tables très petit écran */
    .admin-table-scroll table {
        min-width: 500px;
    }
    
    .admin-table-scroll th,
    .admin-table-scroll td {
        padding: 0.4rem 0.3rem;
        font-size: 0.8rem;
    }
    
    .table-actions .btn {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
    
    .admin-controls-wrapper {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .admin-pagination .btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }
}

/* ==========================================
   CORRECTIONS SPÉCIFIQUES POUR DATABLES
   ========================================== */

/* DataTables responsive */
.dataTables_wrapper {
    width: 100%;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none;
        text-align: left;
        margin-bottom: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none;
        text-align: center;
        margin-top: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 0.25rem;
    }
    
    .dataTables_wrapper .dataTables_length select {
        width: auto;
        margin: 0 0.25rem;
    }
}

/* Amélioration de l'overlay de chargement */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
