/* ═══════════════════════════════════════════════════════════════
   OpusWebcam V2.0 - Module Dashboard
   Fichier: dashboard.css
   Description: Styles pour les statistiques, graphiques et KPIs
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   CONTAINER PRINCIPAL
   ─────────────────────────────────────────────────────────────── */
.dashboard-container {
    padding: var(--space-lg) 0;
}

/* ───────────────────────────────────────────────────────────────
   SECTION KPI
   ─────────────────────────────────────────────────────────────── */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.kpi-card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    transition: all var(--transition-base);
    border: 1px solid var(--gray-200);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    transition: width var(--transition-base);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary);
}

.kpi-card:hover::before {
    width: 8px;
}

.kpi-icon {
    font-size: 3rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    opacity: 0.8;
}

.kpi-content {
    flex: 1;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.kpi-label {
    color: var(--gray-600);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ───────────────────────────────────────────────────────────────
   GRILLE DE GRAPHIQUES
   ─────────────────────────────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

@media (max-width: 992px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transition: all var(--transition-base);
}

.chart-card:hover {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-header h5 {
    margin: 0;
    color: #fff;
    font-size: 1.125rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chart-body {
    padding: var(--space-lg);
    height: 300px;
    position: relative;
}

.chart-card.full-width .chart-body {
    height: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* ───────────────────────────────────────────────────────────────
   TABLEAU TOP CARTES
   ─────────────────────────────────────────────────────────────── */
#topCardsContainer .table {
    margin: 0;
    font-size: 0.875rem;
}

#topCardsContainer th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    padding: var(--space-md);
    border-bottom: 2px solid var(--gray-200);
}

#topCardsContainer td {
    padding: var(--space-md);
    vertical-align: middle;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* ───────────────────────────────────────────────────────────────
   GRAPHIQUES CHART.JS OVERRIDES
   ─────────────────────────────────────────────────────────────── */
.chart-card canvas {
    max-height: 100%;
}

/* Loading state */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-600);
}

.chart-loading::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: var(--space-sm);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ───────────────────────────────────────────────────────────────
   STAT CARD V2 - Cartes statistiques compactes
   ─────────────────────────────────────────────────────────────── */
.stat-card-v2 {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: var(--space-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
    transition: all var(--transition-base);
}

.stat-card-v2:hover {
    border-color: rgba(102, 126, 234, 0.4);
    background: rgba(255, 255, 255, 0.12);
}

.stat-card-v2 .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.stat-card-v2 .stat-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: var(--space-xs);
}

.stat-card-v2 small,
.stat-card-v2 .text-muted {
    display: block;
    font-size: 0.75rem;
    margin-top: var(--space-xs);
    color: rgba(255, 255, 255, 0.5) !important;
}

/* ───────────────────────────────────────────────────────────────
   PROGRESS LIST - Liste avec barres de progression
   ─────────────────────────────────────────────────────────────── */
.progress-list {
    max-height: 300px;
    overflow-y: auto;
}

.progress-list-item {
    display: flex;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all var(--transition-base);
}

.progress-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.progress-list-item:last-child {
    margin-bottom: 0;
}

.progress-list-item .set-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-right: var(--space-sm);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px;
}

.progress-list-item .set-info {
    flex: 1;
    min-width: 0;
}

.progress-list-item .set-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-list-item .set-stats {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.progress-list-item .progress-wrapper {
    width: 120px;
    margin: 0 var(--space-sm);
}

.progress-list-item .progress {
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
}

.progress-list-item .progress-bar {
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-list-item .progress-value {
    font-weight: 700;
    font-size: 0.875rem;
    color: #667eea;
    min-width: 45px;
    text-align: right;
}

/* ───────────────────────────────────────────────────────────────
   MOVERS LIST - Liste top hausses/baisses
   ─────────────────────────────────────────────────────────────── */
.movers-list {
    max-height: 200px;
    overflow-y: auto;
}

.mover-item {
    display: flex;
    align-items: center;
    padding: var(--space-sm);
    border-radius: 10px;
    margin-bottom: var(--space-xs);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all var(--transition-base);
}

.mover-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.mover-item .card-thumb {
    width: 36px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    margin-right: var(--space-sm);
}

.mover-item .card-info {
    flex: 1;
    min-width: 0;
}

.mover-item .card-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mover-item .card-set {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

.mover-item .mover-change {
    font-weight: 700;
    font-size: 0.875rem;
    padding: 4px 10px;
    border-radius: 6px;
}

.mover-item .mover-change.positive {
    color: #28a745;
    background: rgba(40, 167, 69, 0.2);
}

.mover-item .mover-change.negative {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.2);
}

/* ───────────────────────────────────────────────────────────────
   CHART HEADER ACTIONS
   ─────────────────────────────────────────────────────────────── */
.chart-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.chart-header-actions .form-select-sm {
    font-size: 0.8rem;
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
}

/* ───────────────────────────────────────────────────────────────
   CHART CONTAINER OVERRIDE
   ─────────────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

/* ───────────────────────────────────────────────────────────────
   TEXTES DANS DASHBOARD (Glassmorphism)
   ─────────────────────────────────────────────────────────────── */
.dashboard-container h6,
.chart-body h6 {
    color: #fff;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.dashboard-container .text-success,
.chart-body .text-success {
    color: #28a745 !important;
}

.dashboard-container .text-danger,
.chart-body .text-danger {
    color: #dc3545 !important;
}

.dashboard-container .text-muted,
.chart-body .text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

.dashboard-container .text-center {
    color: rgba(255, 255, 255, 0.6);
}

/* Boutons dans le header */
.chart-header .btn-outline-secondary {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.2);
    background: transparent;
}

.chart-header .btn-outline-secondary:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

/* Select dans les actions */
.chart-header-actions .form-select-sm {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 8px;
}

.chart-header-actions .form-select-sm:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.chart-header-actions .form-select-sm option {
    background: #1f2937;
    color: #fff;
}