/**
 * eMairie Dashboard - Professional UI Styles
 * Version 2.0 - Design Moderne et Professionnel
 */

/* ============================================
   VARIABLES CSS PERSONNALISÉES
   ============================================ */
:root {
    /* Couleurs principales */
    --em-primary: #0d6efd;
    --em-primary-rgb: 13, 110, 253;
    --em-primary-dark: #0a58ca;
    --em-primary-light: #cfe2ff;
    
    --em-success: #198754;
    --em-success-rgb: 25, 135, 84;
    --em-success-light: #d1e7dd;
    
    --em-warning: #fd7e14;
    --em-warning-rgb: 253, 126, 20;
    --em-warning-light: #fff3cd;
    
    --em-danger: #dc3545;
    --em-danger-rgb: 220, 53, 69;
    --em-danger-light: #f8d7da;
    
    --em-info: #0dcaf0;
    --em-info-rgb: 13, 202, 240;
    --em-info-light: #cff4fc;
    
    /* Couleurs neutres */
    --em-gray-50: #f8f9fa;
    --em-gray-100: #f1f3f5;
    --em-gray-200: #e9ecef;
    --em-gray-300: #dee2e6;
    --em-gray-400: #ced4da;
    --em-gray-500: #adb5bd;
    --em-gray-600: #6c757d;
    --em-gray-700: #495057;
    --em-gray-800: #343a40;
    --em-gray-900: #212529;
    
    /* Ombres */
    --em-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --em-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --em-shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --em-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --em-shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    
    /* Transitions */
    --em-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --em-transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --em-transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Rayons de bordure */
    --em-radius-sm: 0.375rem;
    --em-radius: 0.5rem;
    --em-radius-md: 0.75rem;
    --em-radius-lg: 1rem;
    --em-radius-xl: 1.5rem;
    --em-radius-full: 9999px;
}

/* ============================================
   LOADING OVERLAY PROFESSIONNEL
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--em-transition-normal), visibility var(--em-transition-normal);
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
    transform: translateY(20px);
    opacity: 0;
    transition: transform var(--em-transition-slow), opacity var(--em-transition-slow);
}

.loading-overlay.show .loading-content {
    transform: translateY(0);
    opacity: 1;
}

/* Spinner moderne avec multiple cercles */
.loading-spinner-pro {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
}

.loading-spinner-pro .circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.loading-spinner-pro .circle:nth-child(1) {
    border-top-color: var(--em-primary);
    animation-delay: -0.45s;
}

.loading-spinner-pro .circle:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-right-color: var(--em-info);
    animation-delay: -0.3s;
    animation-direction: reverse;
}

.loading-spinner-pro .circle:nth-child(3) {
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    border-bottom-color: var(--em-success);
    animation-delay: -0.15s;
}

/* Pulse central */
.loading-spinner-pro .pulse {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--em-primary);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* Texte de loading avec animation de points */
.loading-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--em-gray-700);
    margin-bottom: 8px;
}

.loading-text::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Barre de progression */
.loading-progress {
    width: 200px;
    height: 4px;
    background: var(--em-gray-200);
    border-radius: var(--em-radius-full);
    overflow: hidden;
    margin: 0 auto;
}

        .loading-progress-bar {
            height: 100%;
            background: var(--em-primary);
            width: 40%;
            animation: progress 2s linear infinite;
        }

@keyframes progress {
    0% { transform: translateX(-100%); width: 40%; }
    50% { width: 70%; }
    100% { transform: translateX(250%); width: 40%; }
}

/* ============================================
   SYSTÈME DE TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
}

.toast-notification {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: var(--em-radius-md);
    box-shadow: var(--em-shadow-lg);
    border-left: 4px solid var(--em-primary);
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform var(--em-transition-slow), opacity var(--em-transition-slow);
    overflow: hidden;
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-notification.hide {
    transform: translateX(120%);
    opacity: 0;
}

/* Variantes de toast */
.toast-notification.toast-success {
    border-left-color: var(--em-success);
}

.toast-notification.toast-success .toast-icon {
    background: var(--em-success-light);
    color: var(--em-success);
}

.toast-notification.toast-error {
    border-left-color: var(--em-danger);
}

.toast-notification.toast-error .toast-icon {
    background: var(--em-danger-light);
    color: var(--em-danger);
}

.toast-notification.toast-warning {
    border-left-color: var(--em-warning);
}

.toast-notification.toast-warning .toast-icon {
    background: var(--em-warning-light);
    color: var(--em-warning);
}

.toast-notification.toast-info {
    border-left-color: var(--em-info);
}

.toast-notification.toast-info .toast-icon {
    background: var(--em-info-light);
    color: var(--em-info);
}

/* Icône du toast */
.toast-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--em-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* Contenu du toast */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--em-gray-800);
    margin-bottom: 4px;
    line-height: 1.3;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--em-gray-600);
    line-height: 1.5;
    word-wrap: break-word;
}

/* Bouton fermer */
.toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--em-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--em-gray-400);
    transition: background var(--em-transition-fast), color var(--em-transition-fast);
    margin: -4px -8px -4px 0;
}

.toast-close:hover {
    background: var(--em-gray-100);
    color: var(--em-gray-600);
}

/* Barre de progression du toast */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    width: 100%;
    transform-origin: left;
    animation: toast-progress linear forwards;
}

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ============================================
   DIALOGUES MODAUX PROFESSIONNELS
   ============================================ */
.modal-pro .modal-content {
    border: none;
    border-radius: var(--em-radius-lg);
    box-shadow: var(--em-shadow-xl);
    overflow: hidden;
}

.modal-pro .modal-header {
    border-bottom: 1px solid var(--em-gray-200);
    padding: 20px 24px;
    background: var(--em-gray-50);
}

.modal-pro .modal-title {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--em-gray-800);
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-pro .modal-title .modal-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--em-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.modal-pro .modal-body {
    padding: 24px;
}

.modal-pro .modal-footer {
    border-top: 1px solid var(--em-gray-200);
    padding: 16px 24px;
    background: var(--em-gray-50);
    gap: 12px;
}

/* Animation d'entrée du modal */
.modal-pro.fade .modal-dialog {
    transform: scale(0.95) translateY(-20px);
    transition: transform var(--em-transition-slow);
}

.modal-pro.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* Modal de confirmation */
.modal-confirm .modal-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}

.modal-confirm.confirm-danger .modal-icon {
    background: var(--em-danger-light);
    color: var(--em-danger);
}

.modal-confirm.confirm-warning .modal-icon {
    background: var(--em-warning-light);
    color: var(--em-warning);
}

.modal-confirm.confirm-success .modal-icon {
    background: var(--em-success-light);
    color: var(--em-success);
}

.modal-confirm.confirm-info .modal-icon {
    background: var(--em-info-light);
    color: var(--em-info);
}

.modal-confirm .confirm-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--em-gray-800);
    margin-bottom: 8px;
    text-align: center;
}

.modal-confirm .confirm-message {
    color: var(--em-gray-600);
    text-align: center;
    line-height: 1.6;
}

/* ============================================
   BOUTONS PROFESSIONNELS
   ============================================ */
.btn-pro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 500;
    font-size: 0.9375rem;
    border-radius: var(--em-radius);
    border: none;
    cursor: pointer;
    transition: all var(--em-transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-pro::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--em-transition-slow), height var(--em-transition-slow);
}

.btn-pro:active::before {
    width: 300px;
    height: 300px;
}

.btn-pro-primary {
    background: var(--em-primary);
    color: white;
}

.btn-pro-primary:hover {
    background: var(--em-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--em-shadow);
}

.btn-pro-success {
    background: var(--em-success);
    color: white;
}

.btn-pro-success:hover {
    background: #157347;
    transform: translateY(-1px);
    box-shadow: var(--em-shadow);
}

.btn-pro-danger {
    background: var(--em-danger);
    color: white;
}

.btn-pro-danger:hover {
    background: #bb2d3b;
    transform: translateY(-1px);
    box-shadow: var(--em-shadow);
}

.btn-pro-outline {
    background: transparent;
    border: 2px solid var(--em-gray-300);
    color: var(--em-gray-700);
}

.btn-pro-outline:hover {
    border-color: var(--em-primary);
    color: var(--em-primary);
    background: var(--em-primary-light);
}

/* Bouton avec loading */
.btn-pro.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-pro.loading .btn-text {
    opacity: 0;
}

.btn-pro .btn-spinner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
}

.btn-pro.loading .btn-spinner {
    opacity: 1;
}

/* ============================================
   CARTES PROFESSIONNELLES
   ============================================ */
.card-pro {
    background: white;
    border-radius: var(--em-radius-lg);
    box-shadow: var(--em-shadow);
    border: 1px solid var(--em-gray-100);
    transition: box-shadow var(--em-transition-normal), transform var(--em-transition-normal);
    overflow: hidden;
}

.card-pro:hover {
    box-shadow: var(--em-shadow-md);
}

.card-pro-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--em-gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-pro-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--em-gray-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-pro-body {
    padding: 24px;
}

/* Carte statistique */
.stat-card {
    position: relative;
    padding: 24px;
    background: white;
    border-radius: var(--em-radius-lg);
    box-shadow: var(--em-shadow);
    border: 1px solid var(--em-gray-100);
    transition: all var(--em-transition-normal);
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--stat-color, var(--em-primary));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--em-shadow-md);
}

.stat-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--em-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
    background: var(--stat-bg, var(--em-primary-light));
    color: var(--stat-color, var(--em-primary));
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--em-gray-800);
    line-height: 1.2;
    margin-bottom: 4px;
}

.stat-card-label {
    font-size: 0.875rem;
    color: var(--em-gray-500);
    font-weight: 500;
}

.stat-card-action {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--em-gray-100);
}

/* Variantes de stat card */
.stat-card.stat-primary { --stat-color: var(--em-primary); --stat-bg: var(--em-primary-light); }
.stat-card.stat-success { --stat-color: var(--em-success); --stat-bg: var(--em-success-light); }
.stat-card.stat-warning { --stat-color: var(--em-warning); --stat-bg: var(--em-warning-light); }
.stat-card.stat-danger { --stat-color: var(--em-danger); --stat-bg: var(--em-danger-light); }
.stat-card.stat-info { --stat-color: var(--em-info); --stat-bg: var(--em-info-light); }

/* ============================================
   TABLEAUX PROFESSIONNELS
   ============================================ */
.table-pro {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-pro thead th {
    background: var(--em-gray-50);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--em-gray-600);
    padding: 14px 16px;
    border-bottom: 2px solid var(--em-gray-200);
    white-space: nowrap;
}

.table-pro tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--em-gray-100);
    color: var(--em-gray-700);
    vertical-align: middle;
}

.table-pro tbody tr {
    transition: background var(--em-transition-fast);
}

.table-pro tbody tr:hover {
    background: var(--em-gray-50);
}

.table-pro tbody tr:last-child td {
    border-bottom: none;
}

/* État vide du tableau */
.table-empty {
    text-align: center;
    padding: 48px 24px;
}

.table-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: var(--em-gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--em-gray-400);
}

.table-empty-title {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--em-gray-700);
    margin-bottom: 8px;
}

.table-empty-message {
    color: var(--em-gray-500);
    font-size: 0.9375rem;
}

/* ============================================
   SKELETON LOADING
   ============================================ */
    .skeleton {
        background: var(--em-gray-200);
        border-radius: var(--em-radius-sm);
        opacity: 0.7;
        animation: skeleton-pulse 1.5s ease-in-out infinite;
    }

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}

.skeleton-text {
    height: 1em;
    width: 100%;
}

.skeleton-text-sm {
    height: 0.875em;
    width: 60%;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
}

.skeleton-table-row {
    display: grid;
    grid-template-columns: 0.5fr 2fr 1fr 1fr;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--em-gray-100);
}

/* ============================================
   FORMULAIRES PROFESSIONNELS
   ============================================ */
.form-group-pro {
    margin-bottom: 20px;
}

.form-label-pro {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--em-gray-700);
    margin-bottom: 8px;
}

.form-control-pro {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9375rem;
    border: 2px solid var(--em-gray-300);
    border-radius: var(--em-radius);
    background: white;
    transition: border-color var(--em-transition-fast), box-shadow var(--em-transition-fast);
}

.form-control-pro:focus {
    outline: none;
    border-color: var(--em-primary);
    box-shadow: 0 0 0 4px rgba(var(--em-primary-rgb), 0.1);
}

.form-control-pro::placeholder {
    color: var(--em-gray-400);
}

/* Select stylisé */
.form-select-pro {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* ============================================
   BADGES ET TAGS
   ============================================ */
.badge-pro {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--em-radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-pro-primary { background: var(--em-primary-light); color: var(--em-primary); }
.badge-pro-success { background: var(--em-success-light); color: var(--em-success); }
.badge-pro-warning { background: var(--em-warning-light); color: #b45309; }
.badge-pro-danger { background: var(--em-danger-light); color: var(--em-danger); }
.badge-pro-info { background: var(--em-info-light); color: #0891b2; }

.badge-pro-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================
   ANIMATIONS UTILITAIRES
   ============================================ */
.fade-in {
    animation: fadeIn var(--em-transition-normal) forwards;
}

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

.slide-in-right {
    animation: slideInRight var(--em-transition-normal) forwards;
}

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

.scale-in {
    animation: scaleIn var(--em-transition-normal) forwards;
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Staggered animation pour listes */
.stagger-item {
    opacity: 0;
    animation: fadeIn var(--em-transition-normal) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 50ms; }
.stagger-item:nth-child(3) { animation-delay: 100ms; }
.stagger-item:nth-child(4) { animation-delay: 150ms; }
.stagger-item:nth-child(5) { animation-delay: 200ms; }
.stagger-item:nth-child(6) { animation-delay: 250ms; }

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .toast-container {
        left: 16px;
        right: 16px;
        max-width: none;
    }
    
    .toast-notification {
        transform: translateY(-120%);
    }
    
    .toast-notification.show {
        transform: translateY(0);
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card-value {
        font-size: 1.5rem;
    }
    
    .stat-card-icon {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }
}

/* ============================================
   UTILITAIRES
   ============================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-lift {
    transition: transform var(--em-transition-fast), box-shadow var(--em-transition-fast);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--em-shadow-md);
}

.cursor-pointer {
    cursor: pointer;
}

/* Scrollbar personnalisée */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--em-gray-100);
    border-radius: var(--em-radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--em-gray-300);
    border-radius: var(--em-radius-full);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--em-gray-400);
}

