/* ============================================================
   HL EXPERTISE - Styles v3.2.3
   Déploiement SharePoint - Interface professionnelle
   Optimisations responsive pour tableau bilans élargi
   ============================================================ */

/* === Variables CSS === */
:root {
    --hl-primary: #2d3748;
    --hl-secondary: #4a5568;
    --hl-accent: #3182ce;
    --hl-success: #38a169;
    --hl-warning: #ecc94b;
    --hl-danger: #e53e3e;
    --hl-light: #f7fafc;
    --hl-dark: #1a202c;
    --font-main: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* === Base === */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.5;
    color: var(--hl-dark);
    background-color: #f0f2f5;
    margin: 0;
    padding: 0;
}

/* === Page Login === */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--hl-primary) 0%, var(--hl-accent) 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .logo img {
    max-height: 60px;
    width: auto;
}

.login-card h2 {
    text-align: center;
    color: var(--hl-primary);
    margin-bottom: 30px;
    font-weight: 700;
}

/* === Navbar === */
.navbar-hl {
    background: linear-gradient(135deg, var(--hl-primary) 0%, var(--hl-accent) 100%);
    padding: 12px 20px;
    box-shadow: var(--shadow-md);
}

.navbar-hl .navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}

.navbar-hl .navbar-brand img {
    height: 36px;
    width: auto;
}

/* === Dashboard Cards === */
.dashboard-card {
    display: block;
    background: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: var(--hl-dark);
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    height: 100%;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: var(--hl-dark);
}

.dashboard-card .card-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.9;
}

.dashboard-card .card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-card .card-stats {
    font-size: 0.9rem;
    color: var(--hl-secondary);
    margin-bottom: 16px;
}

.dashboard-card .card-progress {
    margin-top: auto;
}

.progress-bar-hl {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-hl .progress-fill {
    height: 100%;
    background: currentColor;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Card Colors */
.card-blue { border-left-color: #3182ce; }
.card-blue .card-icon { color: #3182ce; }
.card-blue .progress-fill { background: #3182ce; }

.card-purple { border-left-color: #805ad5; }
.card-purple .card-icon { color: #805ad5; }
.card-purple .progress-fill { background: #805ad5; }

.card-teal { border-left-color: #319795; }
.card-teal .card-icon { color: #319795; }
.card-teal .progress-fill { background: #319795; }

.card-orange { border-left-color: #dd6b20; }
.card-orange .card-icon { color: #dd6b20; }
.card-orange .progress-fill { background: #dd6b20; }

.card-pink { border-left-color: #d53f8c; }
.card-pink .card-icon { color: #d53f8c; }
.card-pink .progress-fill { background: #d53f8c; }

.card-green { border-left-color: #38a169; }
.card-green .card-icon { color: #38a169; }
.card-green .progress-fill { background: #38a169; }

.card-cyan { border-left-color: #0987a0; }
.card-cyan .card-icon { color: #0987a0; }
.card-cyan .progress-fill { background: #0987a0; }

/* === Legend Box === */
.legend-box {
    background: linear-gradient(135deg, var(--hl-primary) 0%, var(--hl-accent) 100%);
    color: white;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.legend-sample {
    width: 40px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--hl-dark);
}

.legend-sample.status-0 {
    background: white;
    border: 1px solid #e2e8f0;
}

.legend-sample.status-1 {
    background: #fbbf24;
}

.legend-sample.status-2 {
    background: #34d399;
}

.legend-sample.status-3 {
    background: #a0aec0;
    color: white;
}

/* === Stats Banner === */
.stats-banner {
    background: linear-gradient(135deg, var(--hl-primary) 0%, var(--hl-accent) 100%);
    color: white;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* === Filters Section === */
.filters-section {
    background: white;
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.filters-section .form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hl-secondary);
    margin-bottom: 6px;
}

/* === Table Container === */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
    max-height: calc(100vh - 420px); /* Hauteur adaptative selon la taille de l'écran */
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Container pour le scroll avec header fixe */
#tableContainer {
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    position: relative;
}

/* === Loading Overlay === */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    min-height: 300px;
}

.spinner-hl {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--hl-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Tables === */
.table-hl {
    margin: 0;
    font-size: 13px;
}

.table-hl thead th {
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: var(--hl-secondary);
    padding: 12px 8px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Ombre légère pour bien séparer du contenu */
}

.table-hl tbody tr {
    transition: background-color 0.15s ease;
}

.table-hl tbody tr:hover {
    background-color: #f7fafc;
}

.table-hl tbody td {
    padding: 10px 8px;
    vertical-align: middle;
    border-bottom: 1px solid #edf2f7;
}

/* === Client Column === */
.client-col {
    max-width: 220px;
}

.client-name {
    display: block;
    font-weight: 600;
    color: var(--hl-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === SIREN Code === */
.siren-code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: #f7fafc;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--hl-secondary);
}

/* === Badges === */
.badge-collab {
    background: #e2e8f0;
    color: var(--hl-dark);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.badge-regime {
    background: #ebf8ff;
    color: #2b6cb0;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

/* === Status Cells === */
.status-cell {
    width: 36px;
    height: 28px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--hl-dark);
    transition: all 0.15s ease;
    border: 1px solid #e2e8f0;
    background: white;
}

.status-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.status-cell[data-status="0"] {
    background: white;
}

.status-cell[data-status="1"] {
    background: #fbbf24;
    border-color: #f59e0b;
}

.status-cell[data-status="2"] {
    background: #34d399;
    border-color: #10b981;
}

.status-cell[data-status="3"] {
    background: #a0aec0 !important;
    color: #fff !important;
    font-weight: 600;
    cursor: default;
}

.status-cell-large {
    width: 60px;
    height: 32px;
}

/* === Comment Input === */
.comment-input {
    font-size: 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    width: 100%;
    transition: border-color 0.15s ease;
}

.comment-input:focus {
    border-color: var(--hl-accent);
    outline: none;
    box-shadow: 0 0 0 2px rgba(49, 130, 206, 0.2);
}

/* === Coefficient Select === */
.coeff-select {
    width: 60px;
    font-size: 12px;
    padding: 4px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
}

/* === Bilans Table Specific === */
.bilans-table .cycle-col {
    width: 55px;
    min-width: 55px;
}

.bilans-table .comment-cell {
    width: 20%;
    min-width: 180px;
}

/* === Portefeuille Table === */
.portefeuille-table td {
    font-size: 12px;
}

/* === Toast Notifications === */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast-hl {
    background: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.toast-hl.success {
    border-left: 4px solid var(--hl-success);
}

.toast-hl.error {
    border-left: 4px solid var(--hl-danger);
}

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

/* === Export Button === */
.export-btn {
    background: white;
    color: var(--hl-dark);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-btn:hover {
    background: #f7fafc;
    transform: translateY(-1px);
}

/* === Responsive - OPTIMISÉ POUR TABLEAU BILANS ÉLARGI === */
@media (max-width: 1600px) {
    /* Optimisation tableau bilans pour écrans < 1600px */
    .bilans-table {
        font-size: 12px;
    }
    
    .bilans-table th {
        font-size: 10px;
        padding: 8px 4px;
    }
    
    .bilans-table .cycle-col {
        width: 48px;
        min-width: 48px;
    }
    
    .bilans-table .status-cell {
        width: 34px;
        height: 26px;
        font-size: 10px;
    }
    
    .bilans-table .comment-cell {
        min-width: 150px;
    }
}

@media (max-width: 1400px) {
    /* Réduction supplémentaire pour écrans < 1400px */
    .bilans-table {
        font-size: 11px;
    }
    
    .bilans-table .cycle-col {
        width: 45px;
        min-width: 45px;
    }
    
    .bilans-table .status-cell {
        width: 32px;
        height: 24px;
        font-size: 9px;
    }
    
    .bilans-table .coeff-select {
        width: 50px;
        font-size: 11px;
    }
}

@media (max-width: 1200px) {
    /* Compression maximale pour écrans < 1200px */
    .bilans-table {
        font-size: 10px;
    }
    
    .bilans-table th {
        font-size: 9px;
        padding: 6px 2px;
    }
    
    .bilans-table .cycle-col {
        width: 42px;
        min-width: 42px;
    }
    
    .bilans-table .status-cell {
        width: 30px;
        height: 22px;
        font-size: 8px;
    }
    
    .bilans-table .client-name {
        font-size: 11px;
    }
    
    .bilans-table .comment-cell {
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    /* Ajustements tablettes et mobiles */
    .legend-box .d-flex {
        flex-direction: column;
        gap: 16px;
    }
    
    .stats-banner .row {
        gap: 16px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .filters-section .row > div {
        margin-bottom: 12px;
    }
    
    /* Ajuster la hauteur du conteneur sur mobile */
    .table-container {
        max-height: calc(100vh - 500px);
        min-height: 300px;
    }
    
    /* Forcer le scroll horizontal sur tablette/mobile pour les bilans */
    #tableContainer {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .bilans-table {
        min-width: 1400px; /* Force le tableau à garder sa largeur minimale */
    }
    
    /* S'assurer que le header reste sticky même en scroll horizontal */
    .table-hl thead th {
        background: #f7fafc;
        z-index: 101;
    }
}

@media (max-width: 480px) {
    /* Optimisation pour très petits écrans */
    .navbar-hl .navbar-brand {
        font-size: 0.9rem;
    }
    
    .navbar-hl .navbar-brand img {
        height: 28px;
    }
    
    .dashboard-card {
        padding: 16px;
    }
    
    .dashboard-card .card-icon {
        font-size: 2rem;
    }
    
    .filters-section {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Scrollbar plus visible pour le tableau */
#tableContainer::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#tableContainer::-webkit-scrollbar-track {
    background: #edf2f7;
}

#tableContainer::-webkit-scrollbar-thumb {
    background: var(--hl-accent);
    border-radius: 6px;
}

#tableContainer::-webkit-scrollbar-thumb:hover {
    background: var(--hl-primary);
}

/* === Print Styles === */
@media print {
    .navbar-hl,
    .filters-section,
    .legend-box,
    .toast-container,
    .btn {
        display: none !important;
    }
    
    .table-container {
        box-shadow: none;
    }
    
    .status-cell {
        border: 1px solid #000 !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
