/* Importer une police moderne et lisible depuis Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- Variables de Couleur et Style Racine --- */
:root {
    --primary-blue: #1e3a8a; /* Indigo 900 - Pour les titres, sidebar */
    --secondary-blue: #3b82f6; /* Blue 500 - Pour les boutons, liens */
    --accent-green: #10b981; /* Emerald 500 - Pour la croissance, succès */
    --bg-light: #f8fafc; /* Slate 50 - Pour les fonds de page */
    --card-bg: #ffffff;
    --text-primary: #1e293b; /* Slate 800 */
    --text-secondary: #64748b; /* Slate 500 */
    --border-color: #e2e8f0; /* Slate 200 */
}

/* --- Styles Globaux et Typographie --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* Empêcher le débordement des images */
img {
    max-width: 100%;
    height: auto;
}

/* Empêcher le débordement du texte */
pre, code {
    overflow-x: auto;
    word-wrap: break-word;
}

/* Gradients subtils */
.gradient-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #3730a3 100%);
}
.gradient-card {
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
}

/* Ombres élégantes */
.shadow-elegant {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.shadow-hover {
    transition: box-shadow 0.3s ease-in-out;
}
.shadow-hover:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Animations fluides */
.transition-all {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Personnalisation des Composants --- */

/* Sidebar */
.sidebar-custom {
    background: var(--primary-blue);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
}

/* Assurer que la sidebar occupe toute la hauteur sur desktop */
@media (min-width: 1024px) {
    .sidebar-custom {
        height: 100vh;
    }
}
.sidebar-custom .nav-link {
    color: rgba(255, 255, 255, 0.8);
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
}
.sidebar-custom .nav-link:hover, .sidebar-custom .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: translateX(4px);
}

/* Logo de la sidebar */
.sidebar-custom img {
    max-height: 2rem;
    width: auto;
}

@media (max-width: 768px) {
    .sidebar-custom {
        max-height: 100vh;
    }
    
    .sidebar-custom img {
        max-height: 1.75rem;
    }
}

/* Cartes Statistiques */
.stat-card {
    @apply bg-white rounded-2xl shadow-elegant p-6 flex flex-col justify-between relative overflow-hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary-blue), var(--accent-green));
}
.stat-card .stat-value {
    @apply text-3xl font-bold;
}
.stat-card .stat-label {
    @apply text-sm font-medium text-gray-500 uppercase tracking-wider;
}

/* Tableaux Modernes */
.modern-table {
    @apply bg-white rounded-2xl shadow-elegant overflow-hidden;
}
.modern-table thead {
    @apply bg-gray-50 border-b border-gray-200;
}
.modern-table thead th {
    @apply px-6 py-4 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider;
}
.modern-table tbody tr {
    @apply border-b border-gray-100 hover:bg-gray-50 transition-colors duration-150;
}
.modern-table tbody td {
    @apply px-6 py-4 whitespace-nowrap text-sm text-gray-700;
}

/* Boutons Premium */
.btn-primary {
    @apply bg-gradient-to-r from-blue-500 to-blue-600 text-white font-semibold py-2 px-4 rounded-lg shadow-md hover:from-blue-600 hover:to-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-300 transform hover:scale-105;
}
.btn-success {
    @apply bg-gradient-to-r from-emerald-500 to-emerald-600 text-white font-semibold py-2 px-4 rounded-lg shadow-md hover:from-emerald-600 hover:to-emerald-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-emerald-500 transition-all duration-300 transform hover:scale-105;
}

/* Formulaires */
.form-input {
    @apply w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-200;
}

/* Badges et Status */
.badge {
    @apply inline-flex items-center rounded-full px-3 py-1 text-xs font-semibold;
}
.badge-success {
    @apply bg-emerald-100 text-emerald-700;
}
.badge-warning {
    @apply bg-amber-100 text-amber-700;
}
.badge-danger {
    @apply bg-rose-100 text-rose-700;
}
.badge-info {
    @apply bg-blue-100 text-blue-700;
}
.badge-secondary {
    @apply bg-gray-100 text-gray-700;
}

/* Boutons */
.btn-secondary {
    @apply inline-flex items-center gap-2 rounded-full border border-gray-200 bg-white px-4 py-2 text-sm font-medium text-gray-600 transition hover:bg-gray-50 hover:border-gray-300;
}
.btn-danger {
    @apply inline-flex items-center gap-2 rounded-full border border-rose-200 bg-rose-50 px-4 py-2 text-sm font-semibold text-rose-600 transition hover:bg-rose-100;
}

/* Form elements */
.form-select {
    @apply w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 focus:border-indigo-500 focus:bg-white focus:outline-none;
}
.form-textarea {
    @apply w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-700 focus:border-indigo-500 focus:bg-white focus:outline-none resize-none;
}

.modern-select {
    @apply w-full rounded-2xl border-2 border-gray-200 bg-white/80 px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition focus:border-indigo-500 focus:ring-4 focus:ring-indigo-100 focus:bg-white outline-none pr-10;
    appearance: none;
    background-image: none;
}

.modern-select:disabled {
    @apply cursor-not-allowed bg-gray-100 text-gray-400 border-gray-200;
}

/* Alerts */
.alert-error {
    @apply rounded-xl bg-red-50 border border-red-200 p-4 text-sm text-red-600;
}

/* Animations personnalisées */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-fade-in-up {
    animation: fade-in-up 0.3s ease-out;
}

/* Animation pour les spinners */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Scrollbar personnalisée pour les modaux */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Améliorations visuelles */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

.backdrop-blur-md {
    backdrop-filter: blur(12px);
}

/* --- Responsive Design --- */

/* Ajustements pour tablettes */
@media (max-width: 1024px) {
    .stat-card .stat-value {
        font-size: 1.75rem;
    }
    
    .modern-table thead th,
    .modern-table tbody td {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Ajustements pour mobile */
@media (max-width: 768px) {
    /* Empêcher le défilement horizontal */
    body {
        overflow-x: hidden;
    }
    
    /* Ajuster les tailles de police */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.125rem;
    }
    
    /* Cartes statistiques plus compactes */
    .stat-card {
        padding: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.75rem;
    }
    
    /* Tableaux responsive */
    .modern-table {
        font-size: 0.875rem;
    }
    
    .modern-table thead th,
    .modern-table tbody td {
        padding: 0.5rem 0.75rem;
        font-size: 0.813rem;
    }
    
    /* Boutons plus petits sur mobile */
    .btn-primary,
    .btn-success,
    .btn-secondary,
    .btn-danger {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Formulaires plus compacts */
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Modaux en plein écran sur mobile */
    .fixed.inset-0 > div[class*="max-w"] {
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        max-height: 100vh !important;
    }
}

/* Ajustements pour très petits écrans */
@media (max-width: 640px) {
    /* Forcer l'affichage en colonne pour les grilles */
    .grid {
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Tables en mode scroll horizontal sur très petits écrans */
    .modern-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .modern-table table {
        min-width: 600px;
    }
    
    /* Ajuster le padding global */
    .p-6 {
        padding: 1rem;
    }
    
    /* Modales et containers sur mobile */
    .modal-content,
    .card,
    .panel {
        margin: 0.5rem;
        max-width: calc(100vw - 1rem);
    }
    
    /* Flex containers responsive */
    .flex {
        flex-wrap: wrap;
    }
    
    /* Ajuster les gap sur mobile */
    .gap-6 {
        gap: 1rem;
    }
    
    .gap-4 {
        gap: 0.75rem;
    }
}

/* Améliorations pour les grands écrans */
@media (min-width: 1920px) {
    /* Empêcher les éléments de devenir trop larges */
    .stat-card,
    .modern-table,
    .form-input,
    .form-select,
    .form-textarea {
        max-width: 100%;
    }
}