/**
 * ==========================================================================
 * DASHBOARD CRM ULK - Styles avancés
 * ==========================================================================
 * 
 * Styles pour le tableau de bord CRM avec graphiques interactifs
 * Style Google/Ringover - Professionnel et moderne
 * 
 * ==========================================================================
 */

/* ==========================================================================
   1. VARIABLES DASHBOARD
   ========================================================================== */

:root {
    /* Couleurs graphiques */
    --chart-blue: #4285F4;
    --chart-green: #34C759;
    --chart-orange: #FF9500;
    --chart-red: #FF3B30;
    --chart-purple: #AF52DE;
    --chart-teal: #5AC8FA;
    --chart-gray: #9AA0A6;
    
    /* KPI Colors */
    --kpi-up: #34C759;
    --kpi-down: #FF3B30;
    --kpi-neutral: #5F6368;
}

/* ==========================================================================
   2. DASHBOARD CONTAINER
   ========================================================================== */

.dashboard-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    min-height: calc(100vh - 120px);
}

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 1400px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }
    
    .dashboard-sidebar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

@media (max-width: 900px) {
    .dashboard-sidebar {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   3. BARRE DE FILTRE TEMPORELLE
   ========================================================================== */

.filter-bar {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
    position: sticky;
    top: 80px;
    z-index: 10;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #E8EAED;
    background: #F8F9FA;
    color: #5F6368;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #E8EAED;
    color: #202124;
}

.filter-btn.active {
    background: var(--chart-blue);
    color: #FFFFFF;
    border-color: var(--chart-blue);
}

.filter-dates {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.filter-dates input[type="date"] {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #E8EAED;
    background: #F8F9FA;
    font-size: 13px;
    color: #202124;
}

.filter-dates input[type="date"]:focus {
    outline: none;
    border-color: var(--chart-blue);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.2);
}

.filter-arrow {
    color: #9AA0A6;
    font-size: 14px;
}

/* ==========================================================================
   4. KPI CARDS
   ========================================================================== */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

@media (max-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.kpi-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 12px 0 0 12px;
}

.kpi-card.kpi-ca-total::before { background: var(--chart-blue); }
.kpi-card.kpi-ca-facture::before { background: var(--chart-green); }
.kpi-card.kpi-reste-facturer::before { background: var(--chart-orange); }
.kpi-card.kpi-marge::before { background: var(--chart-purple); }
.kpi-card.kpi-taux-marge::before { background: var(--chart-teal); }
.kpi-card.kpi-dossiers::before { background: var(--chart-gray); }

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: #5F6368;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.kpi-ca-total .kpi-icon { background: rgba(66, 133, 244, 0.1); color: var(--chart-blue); }
.kpi-ca-facture .kpi-icon { background: rgba(52, 199, 89, 0.1); color: var(--chart-green); }
.kpi-reste-facturer .kpi-icon { background: rgba(255, 149, 0, 0.1); color: var(--chart-orange); }
.kpi-marge .kpi-icon { background: rgba(175, 82, 222, 0.1); color: var(--chart-purple); }
.kpi-taux-marge .kpi-icon { background: rgba(90, 200, 250, 0.1); color: var(--chart-teal); }
.kpi-dossiers .kpi-icon { background: rgba(154, 160, 166, 0.1); color: var(--chart-gray); }

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: #202124;
    line-height: 1.2;
    margin-bottom: 8px;
}

.kpi-evolution {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

.kpi-evolution.up {
    color: var(--kpi-up);
}

.kpi-evolution.down {
    color: var(--kpi-down);
}

.kpi-evolution.neutral {
    color: var(--kpi-neutral);
}

.kpi-evolution i {
    font-size: 10px;
}

.kpi-period {
    color: #9AA0A6;
    font-size: 11px;
    margin-left: 4px;
}

/* ==========================================================================
   5. CHART CARDS
   ========================================================================== */

.chart-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 16px;
    font-weight: 600;
    color: #202124;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-title i {
    font-size: 18px;
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.chart-action-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #E8EAED;
    background: #F8F9FA;
    color: #5F6368;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chart-action-btn:hover {
    background: #E8EAED;
}

.chart-action-btn.active {
    background: #202124;
    color: #FFFFFF;
    border-color: #202124;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-container.small {
    height: 200px;
}

.chart-container.large {
    height: 350px;
}

/* Chart Legend Custom */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #F1F3F4;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #5F6368;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.legend-item:hover {
    opacity: 0.7;
}

.legend-item.disabled {
    opacity: 0.4;
    text-decoration: line-through;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ==========================================================================
   6. GRID LAYOUTS
   ========================================================================== */

.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.charts-row.three-cols {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1200px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .charts-row.three-cols {
        grid-template-columns: 1fr;
    }
}

.chart-full-width {
    grid-column: 1 / -1;
}

/* ==========================================================================
   7. DONUT CHART CENTER
   ========================================================================== */

.donut-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-center-value {
    font-size: 24px;
    font-weight: 700;
    color: #202124;
}

.donut-center-label {
    font-size: 12px;
    color: #5F6368;
}

/* ==========================================================================
   8. DATA TABLE
   ========================================================================== */

.table-card {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
    overflow: hidden;
}

.table-tabs {
    display: flex;
    border-bottom: 1px solid #E8EAED;
}

.table-tab {
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #5F6368;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.table-tab:hover {
    color: #202124;
    background: #F8F9FA;
}

.table-tab.active {
    color: var(--chart-blue);
    border-bottom-color: var(--chart-blue);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #F1F3F4;
}

.table-search {
    position: relative;
    width: 280px;
}

.table-search input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border-radius: 8px;
    border: 1px solid #E8EAED;
    background: #F8F9FA;
    font-size: 14px;
    color: #202124;
}

.table-search input:focus {
    outline: none;
    border-color: var(--chart-blue);
    background: #FFFFFF;
}

.table-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9AA0A6;
    font-size: 14px;
}

.table-export-btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #E8EAED;
    background: #FFFFFF;
    color: #202124;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.table-export-btn:hover {
    background: #F8F9FA;
    border-color: #D1D5DB;
}

.table-export-btn i {
    color: var(--chart-green);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #5F6368;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #F8F9FA;
    border-bottom: 1px solid #E8EAED;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.data-table th:hover {
    background: #F1F3F4;
}

.data-table th i {
    margin-left: 6px;
    font-size: 10px;
    opacity: 0.5;
}

.data-table th.sorted i {
    opacity: 1;
    color: var(--chart-blue);
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: #202124;
    border-bottom: 1px solid #F1F3F4;
}

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

.data-table tbody tr:hover {
    background: #F8F9FA;
}

.data-table tbody tr:nth-child(even) {
    background: #FAFBFC;
}

.data-table tbody tr:nth-child(even):hover {
    background: #F1F3F4;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.en-cours {
    background: rgba(66, 133, 244, 0.1);
    color: #1A73E8;
}

.status-badge.facture {
    background: rgba(52, 199, 89, 0.1);
    color: #34C759;
}

.status-badge.paye {
    background: rgba(52, 199, 89, 0.15);
    color: #248A3D;
}

.status-badge.en-retard {
    background: rgba(255, 59, 48, 0.1);
    color: #FF3B30;
}

.status-badge.attente {
    background: rgba(255, 149, 0, 0.1);
    color: #FF9500;
}

/* Pagination */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid #E8EAED;
}

.pagination-info {
    font-size: 13px;
    color: #5F6368;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #E8EAED;
    background: #FFFFFF;
    color: #5F6368;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #F8F9FA;
    border-color: #D1D5DB;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--chart-blue);
    color: #FFFFFF;
    border-color: var(--chart-blue);
}

/* ==========================================================================
   9. SIDEBAR WIDGETS
   ========================================================================== */

.widget-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #E8EAED;
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.widget-title {
    font-size: 14px;
    font-weight: 600;
    color: #202124;
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-title i {
    font-size: 16px;
}

/* Top Clients Widget */
.top-client-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #F1F3F4;
}

.top-client-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.top-client-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.top-client-rank.gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #FFFFFF;
}

.top-client-rank.silver {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: #FFFFFF;
}

.top-client-rank.bronze {
    background: linear-gradient(135deg, #CD7F32, #B8860B);
    color: #FFFFFF;
}

.top-client-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #F1F3F4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #5F6368;
}

.top-client-info {
    flex: 1;
}

.top-client-name {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
}

.top-client-ca {
    font-size: 12px;
    color: #5F6368;
}

/* Gauge Widget */
.gauge-container {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto;
}

.gauge-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-value-number {
    font-size: 24px;
    font-weight: 700;
    color: #202124;
}

.gauge-value-label {
    font-size: 11px;
    color: #5F6368;
}

/* Urgent List Widget */
.urgent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #FFF8F0;
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid var(--chart-orange);
}

.urgent-item:last-child {
    margin-bottom: 0;
}

.urgent-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 149, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chart-orange);
    font-size: 14px;
}

.urgent-info {
    flex: 1;
}

.urgent-title {
    font-size: 13px;
    font-weight: 500;
    color: #202124;
}

.urgent-detail {
    font-size: 11px;
    color: #5F6368;
}

.urgent-days {
    font-size: 12px;
    font-weight: 600;
    color: var(--chart-orange);
}

/* ==========================================================================
   10. ANIMATIONS
   ========================================================================== */

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

.kpi-card,
.chart-card,
.widget-card,
.table-card {
    animation: fadeInUp 0.3s ease forwards;
}

.kpi-card:nth-child(1) { animation-delay: 0.05s; }
.kpi-card:nth-child(2) { animation-delay: 0.1s; }
.kpi-card:nth-child(3) { animation-delay: 0.15s; }
.kpi-card:nth-child(4) { animation-delay: 0.2s; }
.kpi-card:nth-child(5) { animation-delay: 0.25s; }
.kpi-card:nth-child(6) { animation-delay: 0.3s; }

/* Chart loading animation */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9AA0A6;
}

.chart-loading i {
    font-size: 24px;
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   11. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-buttons {
        justify-content: center;
    }
    
    .filter-dates {
        margin-left: 0;
        justify-content: center;
    }
    
    .kpi-value {
        font-size: 22px;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    .table-toolbar {
        flex-direction: column;
        gap: 12px;
    }
    
    .table-search {
        width: 100%;
    }
}
