/* 
 * Styles pour l'annuaire des membres CST
 * Couleurs: #0175BC (bleu CST), blanc, noir
 * Typographie: Ridley (ou fallback system)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Variables CSS */
:root {
    --cst-primary: #0175BC;
    --cst-primary-dark: #015a94;
    --cst-primary-light: #e8f4fd;
    --cst-text: #1a1a1a;
    --cst-text-light: #6c757d;
    --cst-border: #e0e6ed;
    --cst-background: #f8f9fa;
    --cst-white: #ffffff;
    --cst-shadow: 0 2px 4px rgba(0,0,0,0.08);
    --cst-shadow-hover: 0 4px 12px rgba(1, 117, 188, 0.15);
    --cst-radius: 8px;
    --cst-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset et styles globaux */
#cst-members-directory {
    font-family: 'Ridley', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 300;
    color: var(--cst-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#cst-members-directory * {
    box-sizing: border-box;
}

/* Container principal */
.cst-directory-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    background: var(--cst-white);
    min-height: 100vh;
}

/* En-tête */
.cst-header {
    display: none; /* Masquer le titre */
    text-align: center;
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--cst-primary);
}

.cst-title {
    font-size: 2.5rem;
    font-weight: 400;
    color: var(--cst-primary);
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.cst-subtitle {
    font-size: 1.1rem;
    color: var(--cst-text-light);
    font-weight: 300;
}

/* Section des filtres */
.cst-filters-section {
    background: var(--cst-background);
    padding: 30px;
    border-radius: var(--cst-radius);
    margin-bottom: 40px;
    box-shadow: var(--cst-shadow);
}

.cst-filters-section .form-label {
    font-weight: 400;
    color: var(--cst-text);
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.cst-filters-section .form-select,
.cst-filters-section .form-control {
    border: 1px solid var(--cst-border);
    border-radius: 6px;
    padding: 10px 12px;
    font-weight: 300;
    transition: var(--cst-transition);
}

.cst-filters-section .form-select:focus,
.cst-filters-section .form-control:focus {
    border-color: var(--cst-primary);
    box-shadow: 0 0 0 3px rgba(1, 117, 188, 0.1);
}

.cst-filters-section .input-group-text {
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    color: var(--cst-primary);
}

#reset-filters {
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    color: var(--cst-text);
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 400;
    transition: var(--cst-transition);
}

#reset-filters:hover {
    background: var(--cst-primary);
    color: var(--cst-white);
    border-color: var(--cst-primary);
    transform: translateY(-2px);
    box-shadow: var(--cst-shadow-hover);
}

/* Compteur de résultats */
.results-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--cst-white);
    border: 1px solid var(--cst-border);
    border-radius: 6px;
    color: var(--cst-text);
    font-weight: 400;
    font-size: 0.95rem;
}

.results-info i {
    color: var(--cst-primary);
}

#count-display {
    font-weight: 600;
    color: var(--cst-primary);
}

/* Tableau des membres */
.cst-table-container {
    background: var(--cst-white);
    border-radius: var(--cst-radius);
    overflow-x: auto;
    box-shadow: var(--cst-shadow);
    width: 100%;
    position: relative;
}

/* Indicateur de scroll sur mobile */
.cst-table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to left, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

/* Indicateur gauche pour montrer qu'on peut retourner */
.cst-table-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to right, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

@media (max-width: 768px) {
    /* Afficher l'indicateur droit sur mobile */
    .cst-table-container::after {
        opacity: 1;
    }
    
    /* Afficher l'indicateur gauche quand on a scrollé */
    .cst-table-container:not(.scrolled-start)::before {
        opacity: 1;
    }
    
    /* Masquer l'indicateur droit quand on est au bout */
    .cst-table-container.scrolled-end::after {
        opacity: 0;
    }
    
    /* Ajouter un message de scroll avant le tableau */
    .cst-table-container {
        margin-top: 15px;
    }
    
    .cst-filters-section::after {
        content: '💡 Faites glisser le tableau vers la droite pour voir toutes les colonnes →';
        display: block;
        background: var(--cst-primary-light);
        color: var(--cst-primary);
        text-align: center;
        padding: 10px;
        font-size: 0.85rem;
        font-weight: 500;
        border-radius: 6px;
        margin-top: 15px;
        border: 2px solid var(--cst-primary);
    }
}

#members-table {
    width: 100% !important;
    margin-bottom: 0;
    table-layout: fixed !important;
}

/* Forcer les largeurs de colonnes de manière stricte pour éviter tout décalage */
#members-table thead th:nth-child(1),
#members-table tbody td:nth-child(1) {
    width: 230px !important;
    min-width: 230px !important;
    max-width: 230px !important;
}

#members-table thead th:nth-child(2),
#members-table tbody td:nth-child(2) {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}

#members-table thead th:nth-child(3),
#members-table tbody td:nth-child(3) {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
}

#members-table thead th:nth-child(4),
#members-table tbody td:nth-child(4) {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;
}

#members-table thead th:nth-child(5),
#members-table tbody td:nth-child(5) {
    width: 150px !important;
    min-width: 150px !important;
    max-width: 150px !important;
}

#members-table thead th:nth-child(6),
#members-table tbody td:nth-child(6) {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
}

#members-table thead th:nth-child(7),
#members-table tbody td:nth-child(7) {
    width: 100px !important;
    min-width: 100px !important;
    max-width: 100px !important;
}

/* Wrapper DataTables */
.dataTables_wrapper {
    width: 100%;
    overflow-x: auto;
}

.dataTables_scroll {
    overflow-x: auto !important;
}

.dataTables_scrollBody {
    overflow-x: auto !important;
}

/* Correction mobile : forcer les largeurs même sur petit écran */
@media (max-width: 768px) {
    .cst-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #members-table {
        min-width: 1080px !important;
    }
    
    /* S'assurer que les colonnes gardent leur largeur exacte */
    #members-table th,
    #members-table td {
        white-space: nowrap;
        box-sizing: border-box;
    }
    
    /* Forcer les largeurs exactes pour éviter le décalage */
    #members-table thead th:nth-child(1),
    #members-table tbody td:nth-child(1) {
        width: 230px !important;
        min-width: 230px !important;
        max-width: 230px !important;
    }
    
    #members-table thead th:nth-child(2),
    #members-table tbody td:nth-child(2) {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
    }
    
    #members-table thead th:nth-child(3),
    #members-table tbody td:nth-child(3) {
        width: 120px !important;
        min-width: 120px !important;
        max-width: 120px !important;
    }
    
    #members-table thead th:nth-child(4),
    #members-table tbody td:nth-child(4) {
        width: 180px !important;
        min-width: 180px !important;
    }
    
    #members-table thead th:nth-child(5),
    #members-table tbody td:nth-child(5) {
        width: 150px !important;
        min-width: 150px !important;
    }
    
    #members-table thead th:nth-child(6),
    #members-table tbody td:nth-child(6) {
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
    }
    
    #members-table thead th:nth-child(7),
    #members-table tbody td:nth-child(7) {
        width: 100px !important;
        min-width: 100px !important;
        max-width: 100px !important;
    }
    
    /* Désactiver tout ajustement automatique de DataTables */
    .dataTables_wrapper {
        overflow-x: visible !important;
    }
    
    table.dataTable {
        table-layout: fixed !important;
        width: 1080px !important;
    }
}

#members-table thead {
    background: var(--cst-primary);
    color: var(--cst-white);
}

#members-table thead th {
    padding: 15px;
    font-weight: 400;
    text-align: left;
    border: none;
    position: relative;
}

#members-table thead th:hover {
    background: var(--cst-primary-dark);
}

#members-table tbody tr {
    transition: var(--cst-transition);
    cursor: pointer;
}

#members-table tbody tr:hover {
    background: var(--cst-primary-light);
    transform: scale(1.01);
}

#members-table tbody td {
    padding: 15px;
    border-top: 1px solid var(--cst-border);
    vertical-align: middle;
}

/* Forcer DataTables à ne pas réduire les colonnes */
table.dataTable {
    table-layout: fixed !important;
}

table.dataTable th,
table.dataTable td {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Exception pour la colonne département - pas d'ellipsis */
table.dataTable th:nth-child(1),
table.dataTable td:nth-child(1) {
    text-overflow: clip !important;
    overflow: visible !important;
}

/* Badges dans le tableau */
.badge-imdb {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    background: #f5c518;
    color: #000;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--cst-transition);
}

.badge-imdb:hover {
    background: #e5b508;
    color: #000;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(245, 197, 24, 0.3);
}

.badge-imdb i {
    margin-right: 4px;
}

/* Bouton voir détails */
.btn-view-details {
    background: var(--cst-primary);
    color: var(--cst-white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--cst-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-view-details:hover {
    background: var(--cst-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--cst-shadow-hover);
}

/* Panneau de détails latéral */
.cst-details-panel {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    height: 100vh;
    background: var(--cst-white);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
}

.cst-details-panel.active {
    right: 0;
}

.panel-header {
    background: var(--cst-primary);
    color: var(--cst-white);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
    font-weight: 400;
    font-size: 1.25rem;
}

.btn-close-panel {
    background: none;
    border: none;
    color: var(--cst-white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--cst-transition);
}

.btn-close-panel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 100px 30px 30px 30px;
}

/* Overlay */
.cst-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: var(--cst-transition);
    z-index: 1040;
}

.cst-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Détails du membre */
.member-details {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.member-header {
    display: flex;
    gap: 20px;
    padding-bottom: 25px;
    border-bottom: 2px solid var(--cst-border);
    margin-bottom: 30px;
}

.member-avatar {
    width: 80px;
    height: 80px;
    background: var(--cst-primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-avatar i {
    font-size: 3rem;
    color: var(--cst-primary);
}

.member-info {
    flex: 1;
}

.member-name {
    margin: 0 0 5px 0;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--cst-text);
}

.member-org {
    margin: 0 0 10px 0;
    color: var(--cst-text-light);
    font-size: 1rem;
}

.member-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 400;
    display: inline-block;
}

.badge-department {
    background: var(--cst-primary);
    color: var(--cst-white);
}

.badge-membership {
    background: var(--cst-primary-light);
    color: var(--cst-primary);
}

.badge-function {
    background: #e8f4fd;
    color: #015a94;
}

.badge-upcoming {
    background: #28a745;
    color: var(--cst-white);
}

/* Sections d'information */
.member-section {
    margin-bottom: 35px;
}

.member-section h4 {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--cst-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.member-section h4 i {
    font-size: 1rem;
}

.info-grid {
    display: grid;
    gap: 15px;
}

.info-item {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--cst-border);
}

.info-item label {
    font-weight: 400;
    color: var(--cst-text-light);
    font-size: 0.9rem;
}

.info-item span {
    color: var(--cst-text);
    word-break: break-word;
}

.info-item a {
    color: var(--cst-primary);
    text-decoration: none;
}

.info-item a:hover {
    text-decoration: underline;
}

/* Section filmographie */
.imdb-section {
    background: var(--cst-background);
    padding: 20px;
    border-radius: var(--cst-radius);
    margin-top: 30px;
}

.loading-spinner {
    text-align: center;
    padding: 30px;
    color: var(--cst-text-light);
}

.loading-spinner i {
    font-size: 1.5rem;
    color: var(--cst-primary);
    margin-right: 10px;
}

.films-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--cst-border);
}

.stat-item {
    text-align: center;
    flex: 1;
    padding: 15px;
    background: var(--cst-white);
    border-radius: var(--cst-radius);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    color: var(--cst-primary);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--cst-text-light);
    margin-top: 5px;
}

/* Timeline de films */
.films-timeline h5 {
    font-size: 1rem;
    font-weight: 400;
    color: var(--cst-text);
    margin-bottom: 20px;
}

.timeline-container {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.film-item {
    display: flex;
    gap: 20px;
    padding: 15px;
    background: var(--cst-white);
    border-radius: var(--cst-radius);
    margin-bottom: 12px;
    transition: var(--cst-transition);
}

.film-item:hover {
    transform: translateX(5px);
    box-shadow: var(--cst-shadow-hover);
}

.film-year {
    font-weight: 600;
    color: var(--cst-primary);
    min-width: 50px;
}

.film-details {
    flex: 1;
}

.film-title {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 400;
    color: var(--cst-text);
}

.film-role {
    margin: 0;
    font-size: 0.875rem;
    color: var(--cst-text-light);
}

/* DataTables personnalisation */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 20px;
    color: var(--cst-text);
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--cst-border);
    border-radius: 6px;
    padding: 8px 12px;
    margin-left: 10px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 1px solid var(--cst-border);
    border-radius: 4px;
    padding: 5px 12px;
    margin: 0 2px;
    cursor: pointer;
    background: var(--cst-white);
    color: var(--cst-text);
    transition: var(--cst-transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--cst-primary);
    color: var(--cst-white);
    border-color: var(--cst-primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--cst-primary);
    color: var(--cst-white);
    border-color: var(--cst-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .cst-directory-container {
        padding: 20px 10px;
    }
    
    .cst-title {
        font-size: 1.8rem;
    }
    
    .cst-filters-section {
        padding: 20px 15px;
    }
    
    .cst-details-panel {
        width: 100%;
        right: -100%;
    }
    
    .member-header {
        flex-direction: column;
        text-align: center;
    }
    
    .member-avatar {
        margin: 0 auto;
    }
    
    .info-item {
        grid-template-columns: 1fr;
    }
    
    .info-item label {
        margin-bottom: 5px;
    }
    
    #members-table {
        font-size: 0.8rem;
    }
    
    #members-table thead th,
    #members-table tbody td {
        padding: 8px 4px;
    }
    
    /* Ne plus masquer de colonnes - tout est visible via scroll */
    /* Ancien code commenté :
    #members-table th:nth-child(4),
    #members-table td:nth-child(4) {
        display: none;
    }
    */
    
    /* Améliorer la visibilité du scroll horizontal */
    .results-info {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

/* Scrollbar personnalisée pour le tableau sur mobile */
.cst-table-container::-webkit-scrollbar {
    height: 8px;
}

.cst-table-container::-webkit-scrollbar-track {
    background: var(--cst-border);
    border-radius: 4px;
}

.cst-table-container::-webkit-scrollbar-thumb {
    background: var(--cst-primary);
    border-radius: 4px;
}

.cst-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--cst-primary-dark);
}

/* Animations supplémentaires */
.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in-right {
    animation: slideInRight 0.4s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Scrollbar personnalisée */
.timeline-container::-webkit-scrollbar {
    width: 6px;
}

.timeline-container::-webkit-scrollbar-track {
    background: var(--cst-border);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: var(--cst-primary);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb:hover {
    background: var(--cst-primary-dark);
}
