/**
 * TECHHUB-CONSTRUCT - Styles Responsive Ultra-Flexibles
 * Design fluide et adaptatif pour TOUS les types d'écrans
 * 
 * @package TechHub-Construct
 * @version 2.0
 * @since   Janvier 2026
 * 
 * PHILOSOPHIE:
 * - Mobile-first approach
 * - Unités flexibles (rem, em, %, vw, vh)
 * - Containers fluides avec max-width
 * - Typography responsive (clamp)
 * - Grilles CSS et Flexbox
 */

/* ═══════════════════════════════════════════════════════════════════════
   VARIABLES CSS POUR BREAKPOINTS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */
:root {
    /* Breakpoints fluides */
    --breakpoint-xs: 20rem;      /* 320px */
    --breakpoint-sm: 36rem;      /* 576px */
    --breakpoint-md: 48rem;      /* 768px */
    --breakpoint-lg: 62rem;      /* 992px */
    --breakpoint-xl: 75rem;      /* 1200px */
    --breakpoint-xxl: 87.5rem;   /* 1400px */
    --breakpoint-xxxl: 100rem;   /* 1600px */
    
    /* Espacements fluides */
    --spacing-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --spacing-sm: clamp(0.5rem, 1vw, 1rem);
    --spacing-md: clamp(1rem, 2vw, 1.5rem);
    --spacing-lg: clamp(1.5rem, 3vw, 2.5rem);
    --spacing-xl: clamp(2rem, 4vw, 4rem);
    
    /* Typography fluide */
    --font-size-xs: clamp(0.75rem, 0.8vw, 0.875rem);
    --font-size-sm: clamp(0.875rem, 0.9vw, 1rem);
    --font-size-base: clamp(1rem, 1vw, 1.125rem);
    --font-size-lg: clamp(1.125rem, 1.2vw, 1.25rem);
    --font-size-xl: clamp(1.25rem, 1.5vw, 1.5rem);
    --font-size-2xl: clamp(1.5rem, 2vw, 2rem);
    --font-size-3xl: clamp(2rem, 2.5vw, 2.5rem);
    --font-size-4xl: clamp(2.5rem, 3vw, 3.5rem);
    
    /* Largeurs de containers fluides */
    --container-xs: 100%;
    --container-sm: min(95%, 540px);
    --container-md: min(95%, 720px);
    --container-lg: min(95%, 960px);
    --container-xl: min(95%, 1140px);
    --container-xxl: min(95%, 1320px);
    --container-xxxl: min(95%, 1600px);
}

/* ═══════════════════════════════════════════════════════════════════════
   BASE FLUIDE - TOUS LES ÉCRANS
   ═══════════════════════════════════════════════════════════════════════ */

/* HTML et Body fluides */
html {
    font-size: 100%; /* 16px base */
    scroll-behavior: smooth;
}

body {
    font-size: var(--font-size-base);
    line-height: 1.6;
    overflow-x: hidden; /* empêche le scroll horizontal au niveau body (sticky sidebar) */
    min-height: 100vh;
}

/* Containers fluides */
.container,
.container-fluid {
    width: 100%;
    padding-right: var(--spacing-md);
    padding-left: var(--spacing-md);
    margin-right: auto;
    margin-left: auto;
}

.container {
    max-width: var(--container-xxl);
}

/* Grille fluide */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: calc(var(--spacing-md) * -0.5);
    margin-left: calc(var(--spacing-md) * -0.5);
}

[class*="col-"] {
    padding-right: calc(var(--spacing-md) * 0.5);
    padding-left: calc(var(--spacing-md) * 0.5);
}

/* ═══════════════════════════════════════════════════════════════════════
   TYPOGRAPHY RESPONSIVE ET FLUIDE
   ═══════════════════════════════════════════════════════════════════════ */

h1, .h1 {
    font-size: var(--font-size-4xl);
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h2, .h2 {
    font-size: var(--font-size-3xl);
    line-height: 1.3;
    margin-bottom: var(--spacing-md);
}

h3, .h3 {
    font-size: var(--font-size-2xl);
    line-height: 1.4;
    margin-bottom: var(--spacing-sm);
}

h4, .h4 {
    font-size: var(--font-size-xl);
    line-height: 1.4;
    margin-bottom: var(--spacing-sm);
}

h5, .h5 {
    font-size: var(--font-size-lg);
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
}

h6, .h6 {
    font-size: var(--font-size-base);
    line-height: 1.5;
    margin-bottom: var(--spacing-sm);
}

p {
    font-size: var(--font-size-base);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

/* Textes utilitaires fluides */
.lead {
    font-size: var(--font-size-lg);
}

.small, small {
    font-size: var(--font-size-sm);
}

/* ═══════════════════════════════════════════════════════════════════════
   SECTIONS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

.section {
    padding: var(--spacing-xl) 0;
}

.hero-section {
    min-height: clamp(300px, 50vh, 600px);
    padding: var(--spacing-xl) 0;
    display: flex;
    align-items: center;
}

.section-title {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.section-subtitle {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   NAVBAR RESPONSIVE ET FLUIDE
   ═══════════════════════════════════════════════════════════════════════ */

.navbar {
    padding: var(--spacing-sm) 0;
}

.navbar-brand {
    font-size: var(--font-size-xl);
}

.navbar-brand img {
    height: clamp(40px, 5vw, 60px);
    width: auto;
}

.navbar-nav .nav-link {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
}

.navbar-toggler {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-lg);
}

/* Navbar collapsé (mobile) */
@media (max-width: 991px) {
    .navbar-collapse {
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .navbar-nav {
        padding: var(--spacing-md) 0;
    }
    
    .navbar-nav .nav-link {
        padding: var(--spacing-sm) 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR RESPONSIVE ET FLUIDE (Pour pages admin)
   ═══════════════════════════════════════════════════════════════════════ */

/* Wrapper pour pages avec sidebar */
.sidebar-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: clamp(200px, 20vw, 280px);
    min-height: 100vh;
    height: auto; /* Hauteur auto pour s'adapter au contenu */
    position: sticky; /* Sticky au lieu de fixed */
    top: 0; /* Colle en haut lors du scroll */
    left: 0;
    align-self: flex-start; /* Important pour sticky */
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100vh; /* Limite la hauteur à l'écran */
    transition: all 0.3s ease;
    flex-shrink: 0; /* Empêche la sidebar de rétrécir */
}

.sidebar-header {
    padding: var(--spacing-md);
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
}

.sidebar .nav-link {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    transition: all 0.3s ease;
}

.sidebar-footer {
    padding: var(--spacing-md);
    margin-top: auto; /* Pousse le footer en bas */
    position: sticky;
    bottom: 0;
    background: inherit;
    z-index: 10;
}

/* Contenu principal avec sidebar */
.main-content {
    flex: 1;
    min-width: 0;          /* empêche le flex child de dépasser */
    min-height: 100vh;
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
    overflow-x: auto;      /* scroll horizontal quand le contenu déborde */
    overflow-y: visible;
}

/* Scrollbar horizontale fine et discrète */
.main-content::-webkit-scrollbar {
    height: 6px;
}
.main-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.main-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}
.main-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Tablettes : Sidebar devient un menu burger */
@media (max-width: 991px) {
    .sidebar-layout {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed; /* Fixed sur mobile pour overlay */
        transform: translateX(-100%);
        z-index: 1050;
        width: clamp(250px, 80vw, 300px);
        height: 100vh;
        max-height: 100vh;
    }
    
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .main-content {
        width: 100%;
        margin-left: 0;
    }
    
    /* Overlay pour fermer la sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

/* Mobiles : Sidebar en plein écran */
@media (max-width: 575px) {
    .sidebar {
        width: 100vw;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   CARDS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

.card {
    margin-bottom: var(--spacing-md);
    border-radius: clamp(0.25rem, 0.5vw, 0.5rem);
}

.card-body {
    padding: var(--spacing-md);
}

.card-header {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
}

.card-footer {
    padding: var(--spacing-sm) var(--spacing-md);
}

/* Dashboard Cards */
.dashboard-card {
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dashboard-icon {
    width: clamp(50px, 5vw, 70px);
    height: clamp(50px, 5vw, 70px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ═══════════════════════════════════════════════════════════════════════
   PRODUITS - GRILLE FLUIDE ET RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

.product-card {
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15);
}

.product-card img {
    width: 100%;
    height: clamp(150px, 20vw, 250px);
    object-fit: cover;
    border-radius: 0.5rem 0.5rem 0 0;
}

.product-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-secondary, #FF8C00);
}

/* Grille de produits responsive */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(250px, 30vw, 300px), 1fr));
    gap: var(--spacing-md);
}

/* ═══════════════════════════════════════════════════════════════════════
   TABLEAUX FLUIDES ET RESPONSIVES
   ═══════════════════════════════════════════════════════════════════════ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    font-size: var(--font-size-sm);
    width: 100%;
}

.table thead th {
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: var(--spacing-sm) var(--spacing-md);
    white-space: nowrap;
}

.table tbody td {
    padding: var(--spacing-sm) var(--spacing-md);
    vertical-align: middle;
}

/* Tableau en mode carte pour mobiles */
@media (max-width: 767px) {
    .table-desktop {
        display: none;
    }
    
    .table-mobile-card {
        display: block;
    }
    
    .table-mobile-card .card {
        margin-bottom: var(--spacing-md);
        padding: var(--spacing-md);
    }
}

@media (min-width: 768px) {
    .table-mobile-card {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   BOUTONS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

.btn {
    padding: clamp(0.5rem, 1vw, 0.75rem) clamp(1rem, 2vw, 1.5rem);
    font-size: var(--font-size-base);
    border-radius: clamp(0.25rem, 0.5vw, 0.375rem);
    transition: all 0.3s ease;
}

.btn-sm {
    padding: clamp(0.375rem, 0.5vw, 0.5rem) clamp(0.75rem, 1vw, 1rem);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: clamp(0.75rem, 1.5vw, 1rem) clamp(1.5rem, 3vw, 2rem);
    font-size: var(--font-size-lg);
}

/* Groupe de boutons en colonne sur mobile */
@media (max-width: 575px) {
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: var(--spacing-xs);
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   FORMULAIRES FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

.form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.form-control,
.form-select {
    padding: clamp(0.5rem, 1vw, 0.75rem) clamp(0.75rem, 1.5vw, 1rem);
    font-size: var(--font-size-base);
    border-radius: clamp(0.25rem, 0.5vw, 0.375rem);
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 clamp(2px, 0.25vw, 4px) rgba(135, 206, 235, 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════
   MODALS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

.modal-dialog {
    max-width: min(95vw, 600px);
    margin: var(--spacing-md) auto;
}

.modal-header,
.modal-footer {
    padding: var(--spacing-md) var(--spacing-lg);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-title {
    font-size: var(--font-size-xl);
}

/* Modal plein écran sur mobile */
@media (max-width: 575px) {
    .modal-dialog {
        margin: 0;
        max-width: 100vw;
        height: 100vh;
    }
    
    .modal-content {
        height: 100vh;
        border-radius: 0;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   BREADCRUMB FLUIDE
   ═══════════════════════════════════════════════════════════════════════ */

.breadcrumb {
    font-size: var(--font-size-sm);
    padding: var(--spacing-sm) 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    padding: 0 var(--spacing-xs);
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGINATION FLUIDE
   ═══════════════════════════════════════════════════════════════════════ */

.pagination {
    font-size: var(--font-size-sm);
}

.page-link {
    padding: clamp(0.375rem, 0.5vw, 0.5rem) clamp(0.75rem, 1vw, 1rem);
}

/* ═══════════════════════════════════════════════════════════════════════
   FOOTER FLUIDE
   ═══════════════════════════════════════════════════════════════════════ */

.footer {
    padding: var(--spacing-xl) 0;
    font-size: var(--font-size-sm);
}

.footer h5 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-md);
}

/* ═══════════════════════════════════════════════════════════════════════
   UTILITAIRES RESPONSIVE FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

/* Espacements fluides */
.p-fluid {
    padding: var(--spacing-md);
}

.py-fluid {
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
}

.px-fluid {
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

.m-fluid {
    margin: var(--spacing-md);
}

.my-fluid {
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.mx-fluid {
    margin-left: var(--spacing-md);
    margin-right: var(--spacing-md);
}

/* Gaps fluides pour flexbox/grid */
.gap-fluid {
    gap: var(--spacing-md);
}

/* ═══════════════════════════════════════════════════════════════════════
   BREAKPOINTS SPÉCIFIQUES - ÉCRANS D'ORDINATEUR
   ═══════════════════════════════════════════════════════════════════════ */

/* Petits laptops (1024px - 1280px) */
@media (min-width: 1024px) and (max-width: 1280px) {
    :root {
        --font-size-base: 1rem;
        --spacing-md: 1.25rem;
    }
    
    .container {
        max-width: var(--container-xl);
    }
    
    .sidebar {
        width: 220px;
    }
    
}

/* Laptops moyens (1280px - 1440px) */
@media (min-width: 1280px) and (max-width: 1440px) {
    :root {
        --font-size-base: 1rem;
        --spacing-md: 1.5rem;
    }
    
    .container {
        max-width: var(--container-xl);
    }
    
    .sidebar {
        width: 250px;
    }
    
}

/* Grands écrans (1440px - 1920px) */
@media (min-width: 1440px) and (max-width: 1920px) {
    :root {
        --font-size-base: 1.0625rem;
        --spacing-md: 1.75rem;
    }
    
    .container {
        max-width: var(--container-xxl);
    }
    
    .sidebar {
        width: 280px;
    }
    
}

/* Très grands écrans (> 1920px) */
@media (min-width: 1920px) {
    :root {
        --font-size-base: 1.125rem;
        --spacing-md: 2rem;
    }
    
    .container {
        max-width: var(--container-xxxl);
    }
    
    .sidebar {
        width: 300px;
    }
    
    .hero-section h1 {
        font-size: clamp(3rem, 4vw, 4.5rem);
    }
}

/* Ultra larges écrans (> 2560px - 4K) */
@media (min-width: 2560px) {
    :root {
        --font-size-base: 1.25rem;
        --spacing-md: 2.5rem;
    }
    
    .container {
        max-width: 2000px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ACCESSIBILITÉ ET PRÉFÉRENCES UTILISATEUR
   ═══════════════════════════════════════════════════════════════════════ */

/* Réduction des animations */
@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 élevé */
@media (prefers-contrast: high) {
    .card,
    .btn,
    .form-control,
    .table {
        border-width: 2px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   IMPRESSION
   ═══════════════════════════════════════════════════════════════════════ */

@media print {
    /* Masquer éléments UI */
    .navbar,
    .sidebar,
    .footer,
    .btn,
    .breadcrumb,
    .no-print {
        display: none !important;
    }
    
    /* Optimiser pour impression */
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    .container {
        width: 100%;
        max-width: none;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
    
    .card,
    .table {
        page-break-inside: avoid;
        border: 1px solid #000;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
    
    a[href^="#"]:after,
    a[href^="javascript:"]:after {
        content: "";
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ÉCRANS HAUTE RÉSOLUTION (Retina, 4K)
   ═══════════════════════════════════════════════════════════════════════ */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .dashboard-icon,
    .product-card img {
        image-rendering: auto;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ORIENTATION ET ASPECT RATIO
   ═══════════════════════════════════════════════════════════════════════ */

/* Écrans très larges (ultra-wide) */
@media (min-aspect-ratio: 21/9) {
    .container {
        max-width: 85vw;
    }
}

/* Écrans très hauts (verticaux) */
@media (max-aspect-ratio: 9/16) {
    .hero-section {
        min-height: 40vh;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS FLUIDES
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

/* ═══════════════════════════════════════════════════════════════════════
   SCROLL HORIZONTAL — PAGES LARGES
   ═══════════════════════════════════════════════════════════════════════ */

/* Tables sans .table-responsive : wrap automatique dans un conteneur scrollable.
   NE PAS changer display:block sur <table> — casse l'algorithme de layout de table. */

/* Scrollbar fine et discrète sur tous les conteneurs scrollables */
.table-responsive::-webkit-scrollbar,
.card-body::-webkit-scrollbar {
    height: 5px;
    width: 5px;
}
.table-responsive::-webkit-scrollbar-track,
.card-body::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb,
.card-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}
.table-responsive::-webkit-scrollbar-thumb:hover,
.card-body::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Indicateur visuel de défilement horizontal sur mobile */
@media (max-width: 991px) {
    .table-responsive {
        /* ombre droite pour indiquer qu'il y a du contenu à droite */
        background:
            linear-gradient(to right, white 30%, rgba(255,255,255,0)),
            linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
            radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.12), rgba(0,0,0,0)),
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.12), rgba(0,0,0,0)) 0 100%;
        background-repeat: no-repeat;
        background-color: white;
        background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
        background-position: 0 0, 100%, 0 0, 100%;
        background-attachment: local, local, scroll, scroll;
    }
}

/* Empêche la sidebar de provoquer un scroll horizontal de page sur mobile */
@media (max-width: 991px) {
    body {
        overflow-x: hidden;
    }
    .sidebar-layout {
        overflow-x: hidden;
    }
    /* Main content peut quand même scroller horizontalement sur mobile */
    .main-content {
        overflow-x: auto;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   FIN DU FICHIER
   ═══════════════════════════════════════════════════════════════════════ */