/* Styles personnalisés pour BTP Sénégal */
html, body {
    height: 100%;
}
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
#main-footer {
    margin-top: auto;
}

.hero {
    background-size: cover;
    background-position: center;
}

#year {
    display: inline;
}

/* =====================================================
   CHAMPS DE FORMULAIRE - FOND BLANC FORCÉ GLOBAL
   ===================================================== */

/* Règle universelle pour TOUS les champs du site */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
select,
textarea {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #1f2937 !important;
    border: 2px solid #d1d5db !important;
    font-size: 1rem;
    font-family: 'Roboto', Arial, sans-serif;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

/* Placeholders visibles */
input::placeholder,
textarea::placeholder {
    color: #9ca3af !important;
    opacity: 1 !important;
}

/* Focus state */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]):focus,
select:focus,
textarea:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    outline: none !important;
    background-color: #ffffff !important;
}

/* Hover state */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]):hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: #9ca3af !important;
}

/* Select dropdown arrow */
select {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 1.25rem !important;
    padding-right: 2.5rem !important;
    background-color: #ffffff !important;
}

/* Options dans select */
select option {
    background-color: #ffffff !important;
    color: #1f2937 !important;
    padding: 0.5rem !important;
}

/* Disabled state */
input:disabled,
select:disabled,
textarea:disabled {
    background-color: #f3f4f6 !important;
    color: #9ca3af !important;
    cursor: not-allowed !important;
    opacity: 0.7 !important;
}

/* Checkbox et Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 1.25rem !important;
    height: 1.25rem !important;
    accent-color: #2563eb !important;
    cursor: pointer !important;
}

/* Range slider */
input[type="range"] {
    accent-color: #2563eb !important;
}

/* Labels */
label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

/* Champs requis */
label.required::after,
.required-field::after {
    content: " *";
    color: #ef4444;
}

/* Messages d'erreur */
.field-error {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: -0.25rem;
    margin-bottom: 0.5rem;
}

/* Champ en erreur */
input.error,
select.error,
textarea.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

/* Champ valide */
input.valid,
select.valid,
textarea.valid {
    border-color: #10b981;
}

/* ========================================
   STYLES ADMIN - OVERRIDE TAILWIND
   ======================================== */

/* Force absolu pour ADMIN et MODALS */
#admin-main input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
#admin-main select,
#admin-main textarea,
.module-section input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
.module-section select,
.module-section textarea,
[id*="modal"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
[id*="modal"] select,
[id*="modal"] textarea,
.fixed input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
.fixed select,
.fixed textarea {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #1f2937 !important;
    -webkit-text-fill-color: #1f2937 !important;
}

/* Tailwind bg-white override */
.bg-white input,
.bg-white select,
.bg-white textarea,
.bg-gray-50 input,
.bg-gray-50 select,
.bg-gray-50 textarea,
.bg-gray-100 input,
.bg-gray-100 select,
.bg-gray-100 textarea,
.glass-card input,
.glass-card select,
.glass-card textarea,
.rounded-xl input,
.rounded-xl select,
.rounded-xl textarea,
.rounded-2xl input,
.rounded-2xl select,
.rounded-2xl textarea {
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #1f2937 !important;
}

/* Override pour classes Tailwind spécifiques */
[class*="border-gray-"] {
    background-color: #ffffff !important;
}

/* Pages publiques - formulaire contact, etc */
form input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
form select,
form textarea {
    background-color: #ffffff !important;
    color: #1f2937 !important;
}

/* Style des groupes de formulaire */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group .help-text {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

/* Boutons de formulaire */
.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

/* =====================================================
   ACCESSIBILITÉ - NAVIGATION AU CLAVIER
   ===================================================== */

/* Screen reader only - classe utilitaire */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Rend visible au focus */
.sr-only.focus\:not-sr-only:focus,
a.focus\:not-sr-only:focus {
    position: absolute;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Focus visible amélioré pour la navigation clavier */
.keyboard-navigation *:focus {
    outline: 3px solid #facc15 !important;
    outline-offset: 2px !important;
}

/* Focus states plus visibles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #facc15;
    outline-offset: 2px;
}

/* Animation réduite pour les utilisateurs qui la préfèrent */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Contraste amélioré pour le mode sombre si supporté */
@media (prefers-contrast: high) {
    a, button {
        text-decoration: underline;
    }
    
    .text-gray-500,
    .text-gray-600 {
        color: #374151 !important;
    }
}

/* =====================================================
   PERFORMANCE - LAZY LOADING & OPTIMIZATIONS
   ===================================================== */

/* Images en lazy loading */
img.lazy {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

img.lazy-loaded,
img.lazy[src] {
    opacity: 1;
}

/* Placeholder skeleton pour images */
.img-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Content visibility pour sections hors écran */
.section-deferred {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* GPU acceleration pour animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimisation du rendering */
.optimize-render {
    contain: layout style paint;
}

/* Réduire les reflows */
img {
    aspect-ratio: attr(width) / attr(height);
}

/* =====================================================
   LOADING STATES & SPINNERS
   ===================================================== */

/* Spinner de chargement */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

/* Overlay de chargement */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

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

/* Bouton avec état de chargement */
.btn-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =====================================================
   SMOOTH TRANSITIONS
   ===================================================== */

/* Transition douce pour les liens */
a, button {
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

/* Hover scale effect optimisé */
.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

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

/* Stagger animation pour listes */
.stagger-item {
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   MODULE FINANCES - Onglets & Styles
   ======================================== */
.finance-tab {
    color: #374151;
    border-bottom: 3px solid transparent;
    background: transparent;
    font-weight: 600;
}

.finance-tab:hover {
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.08);
}

.finance-tab.active {
    color: #1e40af;
    background: white;
    border-bottom-color: #2563eb;
    font-weight: 700;
}

.finance-tab-content {
    animation: fadeIn 0.3s ease;
}

/* Barres de progression catégories */
.finance-progress-bar {
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
    overflow: hidden;
}

.finance-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Transaction items */
.transaction-item {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.transaction-item:hover {
    transform: translateX(4px);
    background: #f9fafb;
}

.transaction-item.recette {
    border-left-color: #22c55e;
}

.transaction-item.depense {
    border-left-color: #ef4444;
}

/* Indicateurs santé financière */
.health-indicator {
    transition: transform 0.3s ease;
}

.health-indicator:hover {
    transform: scale(1.05);
}

/* ========================================
   MODULE SÉCURITÉ - Onglets & Styles
   ======================================== */
.security-tab {
    color: #374151;
    border-bottom: 3px solid transparent;
    background: transparent;
    font-weight: 600;
}

.security-tab:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.05);
}

.security-tab.active {
    color: #b91c1c;
    background: white;
    border-bottom-color: #dc2626;
    font-weight: 700;
}

.security-tab-content {
    animation: fadeIn 0.3s ease;
}

/* ========================================
   MODULE PARAMÈTRES - Onglets & Styles
   ======================================== */
.settings-tab {
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.settings-tab:hover {
    background: #eff6ff;
    color: #2563eb;
}

.settings-tab.active {
    background: #eff6ff;
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

.settings-tab-content {
    animation: fadeIn 0.3s ease;
}

/* Aperçu du footer */
#settings-footer-preview {
    border: 2px dashed rgba(255, 255, 255, 0.3);
    font-size: 0.875rem;
    min-height: 150px;
}

/* Champs couleur */
input[type="color"] {
    cursor: pointer;
    padding: 2px;
    border-radius: 0.5rem;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 0.375rem;
}

/* Log items */
.log-item {
    transition: all 0.2s ease;
}

.log-item:hover {
    background: #f9fafb;
}

.log-item.login {
    border-left: 3px solid #22c55e;
}

.log-item.logout {
    border-left: 3px solid #3b82f6;
}

.log-item.failed {
    border-left: 3px solid #ef4444;
}

.log-item.action {
    border-left: 3px solid #f59e0b;
}