/**
 * OptiFlowPro Theme - Bootstrap 5 Adaptation
 * Compatible avec Bootstrap 5.0.2
 */

:root {
    --optiflow-primary: #10b981;
    --optiflow-secondary: #14b8a6;
    --optiflow-dark: #0f172a;
    --optiflow-gray: #1e293b;
    --optiflow-light-gray: #f8fafc;
    --optiflow-border: #e2e8f0;
    --optiflow-success: #10b981;
    --optiflow-warning: #f59e0b;
    --optiflow-danger: #ef4444;
    --optiflow-info: #3b82f6;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #1e293b;
}

/* ============================================
   STYLE GLOBAL POUR TOUTES LES PAGES
   Adaptation pour navbar fixe
   ============================================ */

/* Navbar fixe - hauteur standard */
.navbar.fixed-top {
    height: 80px;
    z-index: 1030;
}

/* Compensation pour toutes les pages avec navbar */
body.page-with-navbar {
    padding-top: 80px !important;
}

/* Conteneur principal pour toutes les pages */
.page-content-wrapper {
    min-height: calc(100vh - 80px);
    padding-top: 1rem;
}

.page-content-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Conteneur principal avec fond clair pour tous les modules */
.sage-page-container {
    background: var(--optiflow-light-gray) !important;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 1200px) {
    .page-content-container {
        max-width: 100%;
        padding: 0 1.5rem;
    }
    
    .sage-page-container {
        padding: 1.5rem;
        border-radius: 8px;
    }
}

@media (max-width: 768px) {
    .sage-page-container {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    .page-content-container {
        padding: 0 1rem;
    }
    
    body.page-with-navbar {
        padding-top: 70px !important;
    }
    
    .navbar.fixed-top {
        height: 70px;
    }
    
    /* Tables responsive sur mobile */
    .table-responsive {
        border: none;
    }
    
    .table-responsive .table {
        font-size: 0.875rem;
    }
    
    /* Modals responsive */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
}

/* ============================================
   MODALS - S'assurer qu'ils s'affichent au-dessus de la navbar
   ============================================ */

.modal {
    z-index: 1050 !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

.bg-gradient-light {
    background: linear-gradient(to bottom right, #f8fafc, #f1f5f9, #f8fafc) !important;
}

.bg-dark-gradient {
    background: linear-gradient(to right, #0f172a, #1e293b, #0f172a) !important;
}

.main-content {
    min-height: calc(100vh - 200px);
}

/* ============================================
   CONTENEUR MODULES CENTRÉ
   ============================================ */

.modules-container-wrapper {
    width: 100%;
    padding: 2rem 0;
}

.modules-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 3rem;
}

/* Centrer les modules de la dernière ligne s'il y en a 1, 2 ou 3 */
/* Les styles pour centrer la dernière ligne sont appliqués via JavaScript avec setProperty important */

/* Masquer visuellement les modules de la dernière ligne jusqu'à ce que le centrage soit appliqué */
#modulesGrid > div.last-row-pending {
    visibility: hidden;
}

#modulesGrid > div.last-row-pending.centered {
    visibility: visible;
}

@media (max-width: 1400px) {
    .modules-container {
        max-width: 1200px;
        padding: 0 2.5rem;
    }
}

@media (max-width: 1200px) {
    .modules-container {
        max-width: 100%;
        padding: 0 2rem;
    }
}

@media (max-width: 768px) {
    .modules-container-wrapper {
        padding: 1.5rem 0;
    }
    
    .modules-container {
        padding: 0 1.5rem;
        max-width: 100%;
    }
    
    /* Grille en une seule colonne sur mobile */
    #modulesGrid.row {
        margin-left: 0;
        margin-right: 0;
        justify-content: center;
    }
    
    #modulesGrid.row > div {
        padding-left: 0;
        padding-right: 0;
        max-width: 100%;
        width: 100%;
    }
    
    /* Espacement entre les cartes sur mobile */
    .module-card {
        margin-bottom: 1.5rem;
    }
    
    .module-card:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 576px) {
    .modules-container-wrapper {
        padding: 1rem 0;
    }
    
    .modules-container {
        padding: 0 1rem;
    }
    
    /* Espacement entre les cartes sur très petit écran */
    .module-card {
        margin-bottom: 1rem;
    }
    
    /* Assurer que les cartes prennent toute la largeur disponible */
    #modulesGrid.row > div {
        width: 100%;
        max-width: 100%;
    }
}

.user-info-card {
    transition: all 0.3s ease;
    border: 1px solid var(--optiflow-border) !important;
}

.user-info-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

.user-avatar-circle {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   CARTES DE MODULES - STYLE OPTIFLOWPRO
   ============================================ */

/* Conteneur de la colonne - ajouter un padding-top pour compenser le mouvement du hover */
#modulesGrid.row > div {
    padding-top: 8px;
    transition: padding-top 0.3s ease-in-out;
    /* S'assurer que le conteneur a une position relative pour le z-index */
    position: relative;
}

.module-card {
    cursor: pointer;
    /* Utiliser transform pour le mouvement - le padding du parent compense */
    transition: transform 0.3s ease-in-out;
    /* Isolation pour que le hover n'affecte que cette carte */
    isolation: isolate;
    /* Créer un nouveau contexte de stacking pour isoler les effets */
    position: relative;
    z-index: 0;
}

/* Seulement la carte survolée bouge - le padding du parent compense le mouvement */
.module-card:hover {
    transform: translateY(-8px);
    z-index: 1;
}

/* Réduire le padding-top du conteneur parent quand la carte est survolée pour compenser */
/* Utilisation de :has() - supporté dans les navigateurs modernes */
#modulesGrid.row > div:has(.module-card:hover) {
    padding-top: 0;
}

/* Fallback pour les navigateurs qui ne supportent pas :has() - utiliser JavaScript si nécessaire */

/* Carte principale */
.hover-card {
    /* Transitions spécifiques uniquement - pas "all" pour éviter les effets sur les autres cartes */
    transition: border 0.3s ease-in-out, box-shadow 0.3s ease-in-out !important;
    background: white;
    border-radius: 14px !important;
    border: 1px solid var(--optiflow-border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Isolation pour que le hover n'affecte que cette carte */
    will-change: border, box-shadow;
}

/* Supprimer le hover direct sur hover-card - seul .module-card:hover doit déclencher les effets */

/* Style actif : uniquement au survol (style "Prise de commandes") */
.module-card:hover .hover-card {
    border: 2px solid #10b981 !important;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.1) !important;
}

/* Style normal : modules non survolés (style "Synthèse clients") */
.module-card .hover-card {
    border: 1px solid var(--optiflow-border);
    /* Transition spécifique uniquement - pas "all" */
    transition: border 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    /* Transition spécifique uniquement - pas "all" */
    transition: border 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}

/* Conteneur icône avec effet glow — taille réduite pour grille accueil plus dense */
.module-icon-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    width: 102px;
    height: 102px;
}

/* Conteneur d'icône avec fond sombre (carré bleu foncé) */
.module-icon-container {
    position: relative;
    width: 82px;
    height: 82px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    /* Transition spécifique uniquement - pas "all" */
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    z-index: 1;
}

/* Container icône actif : uniquement au survol */
.module-card:hover .module-icon-container {
    transform: scale(1.05);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Effet de halo (glow) vert émeraude - subtil en arrière-plan */
.module-icon-glow {
    position: absolute;
    inset: -15px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(15px);
    opacity: 0;
    /* Transition spécifique uniquement sur opacity */
    transition: opacity 0.3s ease-in-out;
    z-index: 0;
    /* Isolation pour que le hover n'affecte que cette carte */
    pointer-events: none;
}

/* Glow actif : uniquement au survol */
.module-card:hover .module-icon-glow {
    opacity: 0.6;
}

/* Icône du module - blanche/clair dans le conteneur sombre */
.module-icon {
    position: relative;
    width: 52px;
    height: 52px;
    object-fit: contain;
    filter: brightness(1.2) contrast(1.1);
    transition: transform 0.3s ease-in-out;
    z-index: 2;
}

/* Icône active : uniquement au survol */
.module-card:hover .module-icon {
    transform: scale(1.1);
}

/* Titre de la carte */
.module-card .card-title {
    color: #1e293b; /* Style normal (noir) */
    transition: color 0.3s ease-in-out;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.25;
    margin-bottom: 0.45rem;
}

/* Style actif : uniquement au survol (titre vert) */
.module-card:hover .card-title {
    color: #10b981 !important; /* Vert émeraude comme "Prise de commandes" */
}

/* Description */
.module-card .card-text {
    color: #64748b;
    font-size: 0.8125rem;
    line-height: 1.45;
}

/* Flèche indicateur */
.module-card .card-footer {
    background: transparent;
    border: none;
    padding-bottom: 1rem;
}

.module-card .card-footer i {
    transition: transform 0.3s ease-in-out;
    color: var(--optiflow-success);
}

.module-card:hover .card-footer i {
    transform: translateX(5px);
}

.shadow-lg {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
}

.rounded-3 {
    border-radius: 0.75rem !important;
}

.text-success {
    color: var(--optiflow-success) !important;
}

.text-danger {
    color: var(--optiflow-danger) !important;
}

.text-warning {
    color: var(--optiflow-warning) !important;
}

.text-info {
    color: var(--optiflow-info) !important;
}

.bg-success {
    background-color: var(--optiflow-success) !important;
}

.btn-success {
    background-color: var(--optiflow-success);
    border-color: var(--optiflow-success);
}

.btn-success:hover {
    background-color: #059669;
    border-color: #059669;
}

.border-success {
    border-color: var(--optiflow-success) !important;
}

.alert {
    border-radius: 0.75rem;
}

.alert-warning {
    background-color: #fef3c7;
    border-color: #fbbf24;
    color: #92400e;
}

.alert-danger {
    background-color: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.alert-success {
    background-color: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.alert-info {
    background-color: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
}

.spinner-border-success {
    color: var(--optiflow-success) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--optiflow-primary);
    box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
}

.btn {
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card {
    border-radius: 1rem;
    border: 1px solid var(--optiflow-border);
}

.card-header {
    background-color: var(--optiflow-light-gray);
    border-bottom: 1px solid var(--optiflow-border);
    border-radius: 1rem 1rem 0 0 !important;
}

.table {
    border-radius: 0.75rem;
    overflow: hidden;
}

.table thead {
    background-color: var(--optiflow-light-gray);
}

.table-hover tbody tr:hover {
    background-color: #f1f5f9;
}

.badge {
    border-radius: 0.5rem;
    padding: 0.5em 0.75em;
    font-weight: 500;
}

.badge-success {
    background-color: var(--optiflow-success);
}

.badge-warning {
    background-color: var(--optiflow-warning);
}

.badge-danger {
    background-color: var(--optiflow-danger);
}

.badge-info {
    background-color: var(--optiflow-info);
}

.modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    background: linear-gradient(to right, var(--optiflow-primary), var(--optiflow-secondary));
    color: white;
    border-radius: 1rem 1rem 0 0;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.breadcrumb {
    background-color: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.breadcrumb-item.active {
    color: var(--optiflow-primary);
}

/* ============================================
   RESPONSIVE - CARTES DE MODULES
   ============================================ */

@media (max-width: 768px) {
    .user-info-card {
        margin-bottom: 1rem;
    }

    /* Cartes de modules en mode mobile - style comme sur la photo */
    .module-card {
        margin-bottom: 1rem;
    }

    .module-icon-wrapper {
        width: 120px;
        height: 120px;
        margin-bottom: 1.15rem;
    }

    .module-icon-container {
        width: 98px;
        height: 98px;
        border-radius: 14px;
    }

    .module-icon {
        width: 68px;
        height: 68px;
    }

    .module-card .card-body {
        padding: 1.25rem 1rem !important;
        text-align: center;
    }
    
    .module-card .card-title {
        font-size: 1.05rem;
        font-weight: 700;
        margin-bottom: 0.55rem;
        color: #1e293b;
    }
    
    .module-card .card-text {
        font-size: 0.875rem;
        color: #64748b;
        line-height: 1.5;
        margin-bottom: 0;
    }
    
    .module-card .card-footer {
        display: none; /* Masquer la flèche sur mobile */
    }
    
    /* Bordure normale sur mobile par défaut */
    .module-card .hover-card {
        border: 1px solid var(--optiflow-border) !important;
        transition: border 0.3s ease-in-out, box-shadow 0.3s ease-in-out !important;
    }
    
    /* Style actif au survol sur mobile - bordure verte */
    .module-card:hover .hover-card,
    .module-card:active .hover-card {
        border: 2px solid #10b981 !important;
        box-shadow: 0 4px 6px rgba(16, 185, 129, 0.1) !important;
    }
    
    /* Pas de transform translateY au hover sur mobile (mais garder les autres effets) */
    .module-card:hover {
        transform: none !important;
    }
    
    /* Titre vert au survol sur mobile */
    .module-card:hover .card-title,
    .module-card:active .card-title {
        color: #10b981 !important;
    }
    
    /* Glow visible au survol sur mobile */
    .module-card:hover .module-icon-glow,
    .module-card:active .module-icon-glow {
        opacity: 0.6 !important;
    }
    
    /* Container icône au survol sur mobile */
    .module-card:hover .module-icon-container,
    .module-card:active .module-icon-container {
        transform: scale(1.05) !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* Icône au survol sur mobile */
    .module-card:hover .module-icon,
    .module-card:active .module-icon {
        transform: scale(1.1) !important;
    }
    
    /* Assurer que les transitions fonctionnent */
    .module-card .card-title {
        transition: color 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon-glow {
        transition: opacity 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon-container {
        transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon {
        transition: transform 0.3s ease-in-out !important;
    }
}

@media (max-width: 576px) {
    .module-icon-wrapper {
        width: 108px;
        height: 108px;
        margin-bottom: 1rem;
    }

    .module-icon-container {
        width: 90px;
        height: 90px;
        border-radius: 13px;
    }

    .module-icon {
        width: 60px;
        height: 60px;
    }

    .module-card .card-body {
        padding: 1.15rem 0.85rem !important;
    }
    
    .module-card .card-title {
        font-size: 1rem;
    }

    .module-card .card-text {
        font-size: 0.8125rem;
        display: block; /* Afficher la description sur mobile */
    }
    
    /* Effets hover sur très petit écran */
    .module-card:hover .hover-card,
    .module-card:active .hover-card {
        border: 2px solid #10b981 !important;
        box-shadow: 0 4px 6px rgba(16, 185, 129, 0.1) !important;
    }
    
    .module-card:hover .card-title,
    .module-card:active .card-title {
        color: #10b981 !important;
    }
    
    .module-card:hover .module-icon-glow,
    .module-card:active .module-icon-glow {
        opacity: 0.6 !important;
    }
    
    .module-card:hover .module-icon-container,
    .module-card:active .module-icon-container {
        transform: scale(1.05) !important;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    .module-card:hover .module-icon,
    .module-card:active .module-icon {
        transform: scale(1.1) !important;
    }
    
    /* Assurer que les transitions fonctionnent sur très petit écran */
    .module-card .hover-card {
        transition: border 0.3s ease-in-out, box-shadow 0.3s ease-in-out !important;
    }
    
    .module-card .card-title {
        transition: color 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon-glow {
        transition: opacity 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon-container {
        transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out !important;
    }
    
    .module-card .module-icon {
        transition: transform 0.3s ease-in-out !important;
    }
}

@media (max-width: 576px) {
    .brand-title {
        font-size: 1.25rem;
    }

    .brand-subtitle {
        font-size: 0.7rem;
    }

    .logo-img {
        width: 2.5rem;
        height: 2.5rem;
    }
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-in;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--optiflow-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.page-header {
    background: linear-gradient(135deg, var(--optiflow-primary) 0%, var(--optiflow-secondary) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.page-header h1 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-header p {
    opacity: 0.9;
    margin-bottom: 0;
}

.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-5px);
}

.stat-card .stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--optiflow-dark);
}

.stat-card .stat-label {
    color: #64748b;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   ÉTATS DE CHARGEMENT (SKELETON)
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 0.5rem;
}

.skeleton-icon {
    width: 80px;
    height: 80px;
    border-radius: 1rem;
    margin: 0 auto 1rem;
}

.skeleton-title {
    width: 60%;
    height: 24px;
    margin: 0 auto 0.5rem;
}

.skeleton-text {
    width: 80%;
    height: 16px;
    margin: 0 auto;
}

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

/* Skeleton pour les cartes de modules */
.module-card-skeleton {
    animation: fadeIn 0.5s ease-in;
}

.module-card-skeleton .card {
    border: 1px solid var(--optiflow-border);
    border-radius: 16px;
    background: white;
}

.module-card-skeleton .card-body {
    padding: 2rem;
    text-align: center;
}
