/**
 * Utilitaires & DataTable
 * Styles pour les tableaux de données et composants utilitaires
 * Dépend de: variables-globales.css et composants-communs.css
 */

/* ========================================
   DATATABLE WRAPPER
   ======================================== */

.dt-wrap {
    border: 1px solid var(--glass-shadow-light);
    border-radius: var(--border-radius-lg);
    background: var(--background);
    box-shadow: var(--card-shadow);
    padding: var(--spacing-lg);
}

/* ========================================
   TOOLBAR
   ======================================== */

.dt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.dt-toolbar .form-control {
    border-radius: var(--border-radius-pill);
    border: 1px solid var(--border-light);
    padding: 0.5rem var(--spacing-md);
}

.dt-toolbar .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.15);
}

/* ========================================
   TABLE
   ======================================== */

.table {
    margin-bottom: 0;
}

.table thead th {
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--background-gradient);
    z-index: 1;
    font-weight: 600;
    color: var(--text-900);
    border-bottom: 2px solid var(--border-light);
    padding: var(--spacing-md);
}

.table tbody td {
    padding: var(--spacing-md);
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover {
    background: var(--background-light);
}

/* Colonnes triables */
th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

th[data-sort]:hover {
    background: var(--background-light);
}

th[data-sort] .sort-ind {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-600);
}

th[data-sort].asc .sort-ind:before {
    content: "▲";
    font-size: .7rem;
    color: var(--primary-color);
}

th[data-sort].desc .sort-ind:before {
    content: "▼";
    font-size: .7rem;
    color: var(--primary-color);
}

/* ========================================
   PAGINATION DATATABLE
   ======================================== */

.dt-pagination {
    display: flex;
    gap: var(--spacing-xs);
    justify-content: center;
    margin-top: var(--spacing-lg);
}

.dt-pagination .page-item {
    /* Styles de base pour les items */
}

.dt-pagination .page-link {
    border-radius: var(--border-radius-pill);
    border: 1px solid rgba(13, 110, 253, .18);
    background: var(--background);
    box-shadow: 0 6px 14px var(--shadow-light);
    padding: .3rem .7rem;
    transition: all var(--transition-fast);
}

.dt-pagination .page-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px var(--glass-shadow-light);
}

.dt-pagination .page-item.active .page-link {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--btn-text-color);
    box-shadow: 0 8px 18px rgba(13, 110, 253, .25);
}

.dt-pagination .page-item.disabled .page-link {
    opacity: .6;
    background: #f5f7ff;
    cursor: not-allowed;
}

/* ========================================
   UTILITAIRES - CARDS
   ======================================== */

.util-card {
    border: 1px solid var(--glass-shadow-light);
    border-radius: var(--border-radius-lg);
    background: var(--background);
    box-shadow: var(--card-shadow);
    padding: var(--spacing-lg);
}

/* ========================================
   UTILITAIRES - DASHBOARD
   ======================================== */

.dash-card {
    border: 1px solid var(--glass-shadow-light);
    border-radius: var(--border-radius-lg);
    background: var(--background-gradient);
    box-shadow: var(--card-shadow);
    padding: var(--spacing-lg);
}

/* ========================================
   UTILITAIRES - DÉMO
   ======================================== */

.util-demo .progress {
    height: 8px;
    border-radius: var(--border-radius-pill);
    background: var(--background-light);
}

.util-demo .progress-bar {
    background: var(--primary-gradient);
}

.util-demo .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--background);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========================================
   FILTRES AVANCÉS
   ======================================== */

.filters-advanced {
    background: var(--background-light);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filter-row:last-child {
    margin-bottom: 0;
}

/* ========================================
   STATISTIQUES / MÉTRIQUES
   ======================================== */

.metric-card {
    background: var(--background);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--primary-color);
}

.metric-card.success {
    border-left-color: var(--badge-success);
}

.metric-card.warning {
    border-left-color: var(--badge-warning);
}

.metric-card.danger {
    border-left-color: var(--badge-danger);
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-900);
    line-height: 1;
    margin-bottom: var(--spacing-xs);
}

.metric-label {
    color: var(--text-600);
    font-size: 0.875rem;
    font-weight: 500;
}

.metric-change {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
    margin-top: var(--spacing-sm);
}

.metric-change.positive {
    color: var(--badge-success);
}

.metric-change.negative {
    color: var(--badge-danger);
}

/* ========================================
   ACTIONS RAPIDES
   ======================================== */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-md);
    text-decoration: none;
    color: var(--text-900);
    transition: all var(--transition-base);
}

.quick-action:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
}

.quick-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
}

.quick-action-label {
    font-size: 0.875rem;
    text-align: center;
}

/* ========================================
   TIMELINE
   ======================================== */

.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--spacing-xl);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -2.5rem;
    top: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid var(--background);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-date {
    font-size: 0.875rem;
    color: var(--text-600);
    margin-bottom: var(--spacing-xs);
}

.timeline-content {
    background: var(--background);
    border: 1px solid var(--border-light);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
}

/* ========================================
   ALERTS PERSONNALISÉES
   ======================================== */

.custom-alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    border-left: 4px solid;
    background: var(--background);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--spacing-md);
}

.custom-alert.alert-info {
    border-left-color: var(--badge-info);
    background: rgba(23, 162, 184, 0.05);
}

.custom-alert.alert-success {
    border-left-color: var(--badge-success);
    background: rgba(40, 167, 69, 0.05);
}

.custom-alert.alert-warning {
    border-left-color: var(--badge-warning);
    background: rgba(255, 193, 7, 0.05);
}

.custom-alert.alert-danger {
    border-left-color: var(--badge-danger);
    background: rgba(220, 53, 69, 0.05);
}

/* ========================================
   EMPTY STATES
   ======================================== */

.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-600);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-light);
    margin-bottom: var(--spacing-lg);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-900);
    margin-bottom: var(--spacing-sm);
}

.empty-state-message {
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   LOADING STATES
   ======================================== */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

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

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

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .dt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .dt-wrap {
        padding: var(--spacing-md);
        overflow-x: auto;
    }

    .table {
        font-size: 0.875rem;
    }

    .table thead th,
    .table tbody td {
        padding: var(--spacing-sm);
    }

    .quick-actions {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .filter-row {
        grid-template-columns: 1fr;
    }
}
