/* Variables */
:root {
    --orange-principal: #FF8C00;
    --orange-fonce: #E67E00;
    --vert-institution: #2E7D32;
    --vert-clair: #4CAF50;
    --blanc: #FFFFFF;
    --gris-clair: #F5F5F5;
    --gris-moyen: #E0E0E0;
    --gris-fonce: #333333;
    --bleu-ciel: #e6f3ff;
    --bleu-fonce: #005a8c;
    --ombre: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset et styles de base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    overflow-x: hidden; /* Évite le défilement horizontal */
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--gris-clair);
    color: var(--gris-fonce);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Header - Correction pour prendre toute la largeur */
header {
    background: linear-gradient(135deg, var(--vert-institution) 0%, var(--vert-clair) 100%);
    color: var(--blanc);
    box-shadow: var(--ombre);
    width: 100%;
    margin: 0;
    padding: 0;
}

.header-top {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.5rem 2rem;
    text-align: right;
    width: 100%;
    box-sizing: border-box;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.btn-logout {
    background-color: var(--orange-principal);
    color: var(--blanc);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.btn-logout:hover {
    background-color: var(--orange-fonce);
}

.header-main {
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.logos-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 1rem auto;
    padding: 0 1rem;
}

.logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.title-container {
    text-align: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.title-container h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--blanc);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.slogan {
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.datetime {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Main container - Centré et largeur maximale */
.main-container {
    width: 100%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    flex: 1;
    box-sizing: border-box;
}

/* Section de recherche */
.search-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    width: 100%;
}

.search-box {
    flex: 2;
    min-width: 300px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid var(--gris-moyen);
    border-radius: 50px;
    font-size: 1rem;
    transition: all 0.3s;
    background-color: var(--blanc);
    box-sizing: border-box;
}

.search-box input:focus {
    outline: none;
    border-color: var(--bleu-fonce);
    box-shadow: 0 0 0 3px rgba(0, 90, 140, 0.1);
}

.items-per-page {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--blanc);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    box-shadow: var(--ombre);
    white-space: nowrap;
}

/* Table container */
.table-container {
    background-color: var(--blanc);
    border-radius: 10px;
    box-shadow: var(--ombre);
    overflow: hidden;
    margin-top: 1rem;
    width: 100%;
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    table-layout: auto;
}

.contacts-table thead {
    background: linear-gradient(135deg, var(--bleu-fonce), #0077be);
    color: var(--blanc);
}

.contacts-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.contacts-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #e9ecef;
}

/* Alternance des couleurs */
.row-sky-blue {
    background-color: #e6f3ff;
}

.row-light-gray {
    background-color: #f8f9fa;
}

.contacts-table tbody tr:hover {
    background-color: #b8e2f2 !important;
    cursor: pointer;
    transition: background-color 0.3s;
}

/* Pagination */
.pagination-container {
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
    background-color: var(--blanc);
    width: 100%;
    box-sizing: border-box;
}

.pagination-info {
    text-align: center;
    color: #6c757d;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 0.5rem;
    border: 1px solid #dee2e6;
    background-color: var(--blanc);
    color: #495057;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.page-btn.active {
    background: linear-gradient(135deg, var(--bleu-fonce), #0077be);
    color: var(--blanc);
    border-color: var(--bleu-fonce);
}

/* Footer - Correction pour prendre toute la largeur */
footer {
    background: linear-gradient(135deg, var(--vert-institution), var(--gris-fonce));
    color: var(--blanc);
    margin-top: auto;
    padding: 2rem 0 0 0;
    width: 100%;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 0 2rem;
    width: 100%;
    box-sizing: border-box;
}

.footer-info, .footer-social {
    width: 100%;
}

.footer-info h4,
.footer-social h4 {
    margin-bottom: 1rem;
    color: var(--orange-principal);
}

.footer-info p {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    word-break: break-word;
}

.footer-info i {
    color: var(--orange-principal);
    width: 20px;
    flex-shrink: 0;
}

.social-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.social-link {
    color: var(--blanc);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s;
}

.social-link:hover {
    color: var(--orange-principal);
}

.footer-bottom {
    text-align: center;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    background-color: rgba(0, 0, 0, 0.1);
}

/* Loading spinner */
.loading-spinner {
    text-align: center;
    padding: 3rem;
    width: 100%;
}

.spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 3px solid #e9ecef;
    border-top-color: var(--bleu-fonce);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Message aucun résultat */
.no-results {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
    width: 100%;
}

.no-results i {
    font-size: 3rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

/* Résultats de recherche */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--blanc);
    border: 1px solid #dee2e6;
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 100%;
    box-sizing: border-box;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.3s;
    width: 100%;
    box-sizing: border-box;
}

/* Responsive Design Amélioré */
@media (max-width: 1400px) {
    .main-container,
    .footer-content,
    .user-info,
    .logos-container,
    .title-container {
        max-width: 95%;
    }
}

@media (max-width: 1024px) {
    .main-container {
        padding: 0 1.5rem;
    }
    
    .contacts-table {
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .header-top {
        padding: 0.5rem 1rem;
    }
    
    .header-main {
        padding: 1rem;
    }
    
    .logos-container {
        flex-direction: column;
        gap: 1rem;
        padding: 0;
    }
    
    .logo {
        height: 50px;
    }
    
    .title-container h1 {
        font-size: 1.5rem;
    }
    
    .slogan {
        font-size: 1rem;
    }
    
    .main-container {
        padding: 0 1rem;
        margin: 1rem auto;
    }
    
    .search-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .items-per-page {
        justify-content: center;
        width: 100%;
    }
    
    /* Tableau responsive avec défilement horizontal */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .contacts-table {
        min-width: 800px; /* Force le défilement si nécessaire */
    }
    
    .contacts-table th,
    .contacts-table td {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
    
    .footer-content {
        padding: 0 1rem;
        gap: 1.5rem;
    }
    
    .footer-info p {
        font-size: 0.9rem;
    }
    
    .pagination {
        gap: 0.25rem;
    }
    
    .page-btn {
        min-width: 35px;
        height: 35px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .header-top {
        padding: 0.5rem;
    }
    
    .user-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .btn-logout {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .logo {
        height: 40px;
    }
    
    .title-container h1 {
        font-size: 1.2rem;
    }
    
    .slogan {
        font-size: 0.9rem;
    }
    
    .datetime {
        font-size: 0.8rem;
    }
    
    .main-container {
        padding: 0 0.5rem;
    }
    
    .search-box input {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .items-per-page {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .limit-select {
        padding: 0.3rem;
        font-size: 0.85rem;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        padding: 0 1rem;
    }
    
    .footer-info p {
        justify-content: center;
        font-size: 0.85rem;
    }
    
    .social-links {
        align-items: center;
    }
    
    .page-btn {
        min-width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .pagination-info {
        font-size: 0.8rem;
    }
    
    .no-results {
        padding: 2rem;
    }
    
    .no-results i {
        font-size: 2.5rem;
    }
}

/* Pour les très petits écrans */
@media (max-width: 360px) {
    .logo {
        height: 35px;
    }
    
    .title-container h1 {
        font-size: 1rem;
    }
    
    .slogan {
        font-size: 0.8rem;
    }
    
    .search-box input {
        font-size: 0.85rem;
    }
    
    .page-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

/* Correction pour les écrans très larges */
@media (min-width: 2000px) {
    .main-container,
    .footer-content,
    .user-info,
    .logos-container,
    .title-container {
        max-width: 1600px;
    }
    
    .contacts-table {
        font-size: 1.1rem;
    }
    
    .contacts-table th,
    .contacts-table td {
        padding: 1.2rem;
    }
}