/* ==========================================================================
   Styles Généraux — Application Web AMF (Électricité & Énergies)
   ========================================================================== */

:root {
    --amf-primary: #0f3460;
    --amf-secondary: #e94560;
    --amf-accent: #f5a623;
    --amf-dark: #16213e;
    --amf-light: #f8f9fa;
    --amf-text: #2c3e50;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--amf-text);
    background-color: #f4f6f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Accessibilité Clavier & Focus Visuel (WCAG 2.1 AA)
   ========================================================================== */

:focus-visible {
    outline: 3px solid var(--amf-accent) !important;
    outline-offset: 2px !important;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 10px;
    background: var(--amf-accent);
    color: #000000;
    padding: 10px 18px;
    font-weight: 700;
    z-index: 9999;
    text-decoration: none;
    border-radius: 4px;
    transition: top 0.2s ease-in-out;
}

.skip-link:focus {
    top: 10px;
}

/* ==========================================================================
   En-tête et Navigation Responsive & Anti-Superposition
   ========================================================================== */
.navbar-amf {
    background-color: var(--amf-dark);
    border-bottom: 3px solid var(--amf-accent);
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    z-index: 1040;
}

.navbar-amf .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    margin-right: 1.25rem;
}

.navbar-amf .navbar-brand .navbar-logo,
.navbar-amf .navbar-brand img {
    width: 48px !important;
    height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
    display: inline-block;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.footer-logo {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
    display: inline-block;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.auth-logo {
    width: 64px !important;
    height: 64px !important;
    max-width: 64px !important;
    max-height: 64px !important;
    object-fit: contain !important;
    display: inline-block;
}

.navbar-amf .navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.navbar-amf .nav-item {
    position: relative;
}

.navbar-amf .nav-link {
    color: rgba(255, 255, 255, 0.88) !important;
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.45rem 0.65rem !important;
    border-radius: 0.35rem;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

.navbar-amf .nav-link:hover,
.navbar-amf .nav-link:focus,
.navbar-amf .nav-link.active {
    color: var(--amf-accent) !important;
    background-color: rgba(255, 255, 255, 0.08);
}

/* Bouton burger mobile épuré sans encerclé ni bordure */
.navbar-amf .navbar-toggler {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0.25rem 0.4rem !important;
}

.navbar-amf .navbar-toggler:focus,
.navbar-amf .navbar-toggler:active {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.navbar-amf .navbar-toggler-icon {
    width: 1.6em;
    height: 1.6em;
}

/* Menus déroulants modernes (Dropdowns) */
.navbar-amf .dropdown-menu {
    border: none;
    border-radius: 0.6rem;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.28);
    padding: 0.5rem 0;
    margin-top: 0.25rem;
    background-color: #ffffff;
    min-width: 250px;
    z-index: 1050;
}

/* Sur grand écran (Desktop) : ouverture au survol ET au clic */
@media (min-width: 992px) {
    .navbar-amf .nav-item.dropdown:hover > .dropdown-menu,
    .navbar-amf .dropdown:hover > .dropdown-menu {
        display: block;
        animation: amfFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

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

.navbar-amf .dropdown-item {
    padding: 0.55rem 1.15rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: #1e293b;
    transition: all 0.15s ease-in-out;
    white-space: normal;
}

.navbar-amf .dropdown-item:hover,
.navbar-amf .dropdown-item:focus {
    background-color: #f1f5f9;
    color: var(--amf-primary);
}

.navbar-amf .dropdown-item.active {
    background-color: var(--amf-primary);
    color: #ffffff !important;
}

.navbar-amf .dropdown-item.active .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

.navbar-amf .dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 0.4rem 1.15rem 0.25rem;
}

/* Zone actions à droite */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ==========================================================================
   Hero Section & Contenus avec Cover Réel et Transparence Optimisée
   ========================================================================== */
.hero-amf {
    position: relative;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.6) 50%, rgba(15, 23, 42, 0.2) 100%),
                url('/images/hero-electrician.jpg') center right / cover no-repeat;
    color: #ffffff;
    padding: 5.5rem 0;
    min-height: 460px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

@media (max-width: 991.98px) {
    .hero-amf {
        background: linear-gradient(180deg, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.65) 100%),
                    url('/images/hero-electrician.jpg') center center / cover no-repeat;
        padding: 3.5rem 0;
        min-height: auto;
    }
}

.hero-amf .container {
    position: relative;
    z-index: 2;
}

.hero-amf h1 {
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.hero-amf .lead {
    font-size: 1.12rem;
    font-weight: 400;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Boutons & Éléments Interactifs
   ========================================================================== */
.btn-amf-primary {
    background-color: var(--amf-accent);
    color: #1a1a1a;
    font-weight: 600;
    border: none;
}

.btn-amf-primary:hover {
    background-color: #e09418;
    color: #000000;
}

.btn-amf-outline {
    border: 2px solid #ffffff;
    color: #ffffff;
    font-weight: 600;
}

.btn-amf-outline:hover {
    background-color: #ffffff;
    color: var(--amf-dark);
}

/* ==========================================================================
   Cartes & Composants Modernes & Remarquables
   ========================================================================== */
.card-amf {
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 1rem !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.04) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.28s ease !important;
    background-color: #ffffff;
    position: relative;
    overflow: hidden;
}

.card-amf:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12) !important;
    border-color: rgba(245, 166, 35, 0.45) !important;
}

/* Carte de Prestation Technique : Bordure Dorée / Énergie */
.card-service-amf {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid rgba(245, 166, 35, 0.28) !important;
    border-top: 4px solid var(--amf-accent) !important;
}

.card-service-amf:hover {
    border-color: var(--amf-accent) !important;
    box-shadow: 0 18px 40px rgba(245, 166, 35, 0.16) !important;
}

.card-service-icon {
    width: 58px;
    height: 58px;
    border-radius: 0.85rem;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1.5px solid rgba(245, 166, 35, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.2);
    transition: transform 0.25s ease, background 0.25s ease;
    flex-shrink: 0;
}

.card-amf:hover .card-service-icon {
    transform: scale(1.08) rotate(3deg);
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

/* Carte Produit Matériel : Bordure Bleu Électrique / Industrie */
.card-product-amf {
    border: 1px solid rgba(37, 99, 235, 0.22) !important;
    border-top: 4px solid #2563eb !important;
}

.card-product-amf:hover {
    border-color: #2563eb !important;
    box-shadow: 0 18px 40px rgba(37, 99, 235, 0.15) !important;
}

.card-product-img-wrapper {
    position: relative;
    overflow: hidden;
    background-color: #f8fafc;
    border-bottom: 1px solid rgba(37, 99, 235, 0.1);
}

.card-product-img-wrapper img {
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-amf:hover .card-product-img-wrapper img {
    transform: scale(1.06);
}

/* Carte Réalisation / Chantier : Bordure Émeraude / Travaux */
.card-project-amf {
    border: 1px solid rgba(13, 148, 136, 0.25) !important;
    border-top: 4px solid #0d9488 !important;
}

.card-project-amf:hover {
    border-color: #0d9488 !important;
    box-shadow: 0 18px 40px rgba(13, 148, 136, 0.16) !important;
}

.card-project-img-wrapper {
    position: relative;
    overflow: hidden;
}

.card-project-img-wrapper img {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-amf:hover .card-project-img-wrapper img {
    transform: scale(1.08);
}

/* Carte Marque / Partenaire : Bordure Ambre / Certifiée */
.card-partner-amf {
    border: 1.5px solid rgba(245, 166, 35, 0.3) !important;
    border-bottom: 4px solid var(--amf-accent) !important;
    border-radius: 0.85rem;
    background: #ffffff;
    padding: 1.5rem 1rem;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.card-partner-amf:hover {
    transform: translateY(-5px);
    box-shadow: 0 14px 28px rgba(245, 166, 35, 0.18);
    border-color: var(--amf-accent) !important;
    background: #ffffff;
}

/* Cartes de garanties / points forts : Bordure Gauche Dorée */
.card-feature-amf {
    border-radius: 0.85rem;
    border: 1px solid rgba(245, 166, 35, 0.25) !important;
    border-left: 5px solid var(--amf-accent) !important;
    background: #ffffff;
    padding: 1.25rem 1rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    transition: all 0.25s ease;
}

.card-feature-amf:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(245, 166, 35, 0.15);
    border-color: var(--amf-accent) !important;
    border-left-color: #d97706 !important;
}

/* Badges */
.badge-amf-pill {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 50rem;
}

/* Pied de page */
.footer-amf {
    background-color: var(--amf-dark);
    color: #d1d5db;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-amf a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-amf a:hover {
    color: var(--amf-accent);
}

/* ==========================================================================
   Optimisations Images & Core Web Vitals (CLS / LCP)
   ========================================================================== */
img {
    max-width: 100%;
    height: auto;
    content-visibility: auto;
}

.img-product-card {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background-color: #ffffff;
}

/* ==========================================================================
   Styles d'Impression (Devis / Documents)
   ========================================================================== */
@media print {
    .navbar-amf, .footer-amf, .btn, .skip-link, .amf-page-loader {
        display: none !important;
    }
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
}

/* ==========================================================================
   Loader Intelligent AMF (Progress Bar & Overlay Déclenchée sur Latence)
   ========================================================================== */
.amf-page-loader {
    pointer-events: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

/* Barre de progression supérieure */
.amf-page-loader .amf-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3.5px;
    width: 0%;
    background: linear-gradient(90deg, #f5a623, #ffc107, #ff6b6b, #f5a623);
    background-size: 200% 100%;
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.9), 0 0 5px rgba(245, 166, 35, 0.7);
    z-index: 100000;
}

/* Overlay sombre semi-transparent si le chargement persiste */
.amf-page-loader .amf-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* État actif : déclenché automatiquement si la page tarde (> 250ms) */
.amf-page-loader.is-active {
    visibility: visible;
    opacity: 1;
}

.amf-page-loader.is-active .amf-progress-bar {
    animation: amfProgressAnim 2.2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

/* Si le chargement tarde encore plus (> 750ms), l'overlay central devient visible */
.amf-page-loader.is-deep-active .amf-loader-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.amf-loader-content {
    background: rgba(22, 33, 62, 0.95);
    padding: 1.75rem 2.25rem;
    border-radius: 1.2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
    animation: amfPulseLoader 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes amfProgressAnim {
    0% {
        width: 0%;
        left: 0;
    }
    50% {
        width: 75%;
        left: 0;
    }
    100% {
        width: 100%;
        left: 0;
    }
}

@keyframes amfPulseLoader {
    to {
        transform: scale(1);
    }
}
