/**
 * Devis Électrique Pro - Styles Bootstrap par défaut
 * Version 1.0.0
 * 
 * Bootstrap 5 par défaut sans surcouche ArchitectUI
 * @sync 2024-01-15
 */

/* ============================================================================
   VARIABLES CSS BOOTSTRAP
   ============================================================================ */

   :root {
    /* Couleurs Bootstrap par défaut */
    --bs-primary: #0d6efd;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    
    /* Couleurs personnalisées pour l'électricité */
    --electric-blue: #3b82f6;
    --electric-orange: #f59e0b;
    --electric-green: #10b981;
    
    /* Espacement */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border radius */
    --border-radius: 0.375rem;
    --border-radius-sm: 0.25rem;
    --border-radius-lg: 0.5rem;
    
    /* Transitions */
    --transition: 0.15s ease-in-out;
}

/* ============================================================================
   LAYOUT PRINCIPAL
   ============================================================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background-color: var(--bs-light);
    color: var(--bs-dark);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Contenu principal - mobile par défaut */
:root { --app-navbar-height: 56px; }
main {
    position: relative;
    width: 100%;
    margin-left: 0;
    min-height: 100vh;
    padding-top: var(--app-navbar-height);
    background-color: #f8f9fa;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Desktop styles */
#appSidebarDesktop,
.sidebar {
    box-shadow: 0 0.46875rem 2.1875rem rgba(4, 9, 20, 0.03), 0 0.9375rem 1.40625rem rgba(4, 9, 20, 0.03), 0 0.25rem 0.53125rem rgba(4, 9, 20, 0.05), 0 0.125rem 0.1875rem rgba(4, 9, 20, 0.03);
}

/* Sidebar sticky sous la navbar globale */
.sidebar {
    width: 320px;
    border-right: 1px solid #dee2e6;
    position: sticky;
    top: var(--app-navbar-height);
    height: calc(100vh - var(--app-navbar-height));
    flex-direction: column;
}
.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Scrollbar personnalisée pour la navigation de la sidebar */
#appSidebarDesktop nav::-webkit-scrollbar {
    width: 6px;
}

#appSidebarDesktop nav::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#appSidebarDesktop nav::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#appSidebarDesktop nav::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Scrollbar personnalisée pour le contenu principal */
main::-webkit-scrollbar {
    width: 8px;
}

main::-webkit-scrollbar-track {
    background: #f1f1f1;
}

main::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

main::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Navigation links */
#appSidebarDesktop .nav-link {
    color: var(--bs-secondary-color) !important;
    transition: all var(--transition);
}

#appSidebarDesktop .nav-link:hover {
    color: var(--bs-primary) !important;
    background-color: rgba(13, 110, 253, 0.1);
}

#appSidebarDesktop .nav-link.active {
    color: var(--bs-primary) !important;
    background-color: rgba(13, 110, 253, 0.1);
    font-weight: 600;
}

/* ============================================================================
   NAVBAR
   ============================================================================ */

.navbar {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Header principal avec box-shadow personnalisée */
header.bg-light {
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 0.46875rem 2.1875rem rgba(4, 9, 20, 0.03), 0 0.9375rem 1.40625rem rgba(4, 9, 20, 0.03), 0 0.25rem 0.53125rem rgba(4, 9, 20, 0.05), 0 0.125rem 0.1875rem rgba(4, 9, 20, 0.03);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

.navbar-brand i {
    color: var(--electric-blue);
    margin-right: 0.5rem;
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: var(--border-radius);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: var(--bs-light);
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
    font-weight: 600;
}

/* ============================================================================
   BOUTONS
   ============================================================================ */

.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--electric-blue);
    border-color: var(--electric-blue);
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

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

.btn-warning {
    background-color: var(--electric-orange);
    border-color: var(--electric-orange);
}

/* ============================================================================
   FORMULAIRES
   ============================================================================ */

.form-control {
    border-radius: var(--border-radius);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    border-color: var(--electric-blue);
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-label {
    font-weight: 500;
    color: var(--bs-dark);
}

/* ============================================================================
   TABLEAUX
   ============================================================================ */

.table {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table thead th {
    background-color: var(--bs-light);
    border-bottom: 2px solid var(--bs-secondary);
    font-weight: 600;
    color: var(--bs-dark);
}

.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.025);
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    font-weight: 500;
    border-radius: var(--border-radius-sm);
}

/* ============================================================================
   ALERTS
   ============================================================================ */

.alert {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
}

.alert-primary {
    background-color: rgba(13, 110, 253, 0.1);
    color: #084298;
}

.alert-success {
    background-color: rgba(25, 135, 84, 0.1);
    color: #0a3622;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #664d03;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #58151c;
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal-content {
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.125);
}

/* ============================================================================
   DROPDOWNS
   ============================================================================ */

.dropdown-menu {
    border-radius: var(--border-radius);
    border: 1px solid rgba(0, 0, 0, 0.125);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-item {
    transition: background-color var(--transition);
}

.dropdown-item:hover {
    background-color: var(--bs-light);
}

/* ============================================================================
   PROGRESS
   ============================================================================ */

.progress {
    border-radius: var(--border-radius);
    background-color: rgba(0, 0, 0, 0.1);
}

.progress-bar {
    border-radius: var(--border-radius);
    transition: width var(--transition);
}

/* ============================================================================
   UTILITAIRES
   ============================================================================ */

.text-primary {
    color: var(--electric-blue) !important;
}

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

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

.bg-primary {
    background-color: var(--electric-blue) !important;
}

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

.bg-warning {
    background-color: var(--electric-orange) !important;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}


/* ============================================================================
   MODALES - Correction z-index Bootstrap
   ============================================================================ */

/* Correction du problème de z-index des modales Bootstrap */
.modal {
    z-index: 1060 !important;
}

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

/* S'assurer que les modales sont au-dessus de tout */
.modal-dialog {
    z-index: 1061 !important;
}

/* Correction spécifique pour les modales dans le contenu principal */
main .modal {
    z-index: 1060 !important;
}

main .modal-dialog {
    z-index: 1061 !important;
}

/* Forcer le backdrop à être en dessous de la modal */
.modal-backdrop.show {
    z-index: 1055 !important;
}

/* S'assurer que la modal est toujours visible */
.modal.show {
    z-index: 1060 !important;
}

/* Correction pour les modales imbriquées */
.modal.fade .modal-dialog {
    z-index: 1061 !important;
}

/* Script pour déplacer les modales au niveau du body */
.modal-body-moved {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 1060 !important;
}

/* ============================================================================
   LAYOUT RESPONSIVE
   ============================================================================ */

/* Contenu principal - largeur responsive */
/* (mobile par défaut -> 100%) */

/* Container-xxl - suppression des marges automatiques */
.container-xxl {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Page content - largeur complète */
.page-content {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 991.98px) {
    /* Contenu principal sur mobile */
    main {
        margin-left: 0 !important;
        width: 100% !important;
        min-height: 100vh;
    }
}

@media (min-width: 992px) {
    /* Décalage du contenu pour sidebar desktop */
    main {
        width: calc(100% - 320px);
        margin-left: 0 !important;
        padding-top: var(--app-navbar-height);
        min-height: calc(100vh - 0px);
    }
}

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
}

/* ============================================================================
   IMPRESSION
   ============================================================================ */

@media print {
    .navbar,
    .btn,
    .modal {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    body {
        background-color: white;
    }
}

/* ============================================================================
   TOASTS D'ERREUR DIFFÉRENCIÉS
   ============================================================================ */

/* Utilise les classes Bootstrap standard : bg-warning, bg-danger, bg-success, bg-info */

/* Styles pour les actions dans les toasts */
.toast .btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Styles pour les toasts d'erreur persistants - Utilise Bootstrap standard */

/* Responsive pour mobile */
@media (max-width: 768px) {
    .toast {
        margin: 0.5rem;
        font-size: 0.9rem;
    }
    
    .toast .btn-sm {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

/* ============================================================================
   TOAST CONTAINER - Z-index pour visibilité au-dessus des modals
   ============================================================================ */

/* Z-index pour toasts - doit être au-dessus des modals Bootstrap */
.toast-container {
    z-index: 1060 !important;
}

.toast-container .toast {
    z-index: 1061 !important;
}
