/* ═══════════════════════════════════════════
   SGESU — Modern Design System v2.0
   ═══════════════════════════════════════════ */

/* ─── Tailwind v4 theme tokens (shared by all layouts) ─── */
@theme {
    --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;

    --color-esu-50:  #eff6ff;
    --color-esu-100: #dbeafe;
    --color-esu-200: #bfdbfe;
    --color-esu-300: #93c5fd;
    --color-esu-400: #60a5fa;
    --color-esu-500: #3b82f6;
    --color-esu-600: #2563eb;
    --color-esu-700: #1d4ed8;
    --color-esu-800: #1e40af;
    --color-esu-900: #1e3a8a;
}

/* Guaranteed brand typography regardless of @theme processing */
body {
    font-family: var(--font-sans, 'Plus Jakarta Sans', system-ui, sans-serif);
}

:root {
    /* ─── Brand scale (single institutional blue) ─── */
    --esu-50:  #eff6ff;
    --esu-100: #dbeafe;
    --esu-200: #bfdbfe;
    --esu-300: #93c5fd;
    --esu-400: #60a5fa;
    --esu-500: #3b82f6;
    --esu-600: #2563eb;
    --esu-700: #1d4ed8;
    --esu-800: #1e40af;
    --esu-900: #1e3a8a;

    /* ─── Focus ring ─── */
    --ring: rgba(37, 99, 235, 0.18);
    --ring-border: #2563eb;

    /* ─── Radii (standardized scale) ─── */
    --radius-btn: 0.625rem;
    --radius-card: 1rem;
    --radius-modal: 1rem;

    /* ─── Elevation ─── */
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-card-hover: 0 12px 32px rgba(15, 23, 42, 0.10);
    --shadow-sm-ring: 0 0 0 3px var(--ring);
}

html { scroll-behavior: smooth; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--esu-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--esu-500); }

/* ─── Global focus-visible baseline ─── */
:focus-visible {
    outline: 2px solid var(--ring-border);
    outline-offset: 2px;
}

/* ─── Navigation ─── */
#navigation-globale {
    transition: transform 0.3s ease, box-shadow 0.3s ease, backdrop-filter 0.3s ease;
}

#dropdown-profil {
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.2s;
}

#dropdown-profil.open {
    opacity: 1 !important;
    visibility: visible !important;
    transform: scale(1) !important;
}

/* ─── Dropdown search & scrollable lists ─── */
.dropdown-items-list {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.dropdown-items-list::-webkit-scrollbar { width: 4px; }
.dropdown-items-list::-webkit-scrollbar-track { background: transparent; }
.dropdown-items-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.dropdown-items-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

.dropdown-items-list [data-search-text].hidden {
    display: none !important;
}

.dropdown-aucun-resultat.hidden {
    display: none !important;
}

/* ─── Modal System ─── */
.modale-portail .modale-contenu,
.modale-crud .modale-contenu {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.modale-portail.modale-open .modale-contenu,
.modale-crud.modale-open .modale-contenu {
    transform: scale(1) !important;
    opacity: 1 !important;
}

.modale-overlay {
    transition: opacity 0.3s ease;
}

/* ─── Hero Section ─── */
.hero-home {
    position: relative;
    background-color: #0a1020;
    background-image: url('../images/batiment_sgesu.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    isolation: isolate;
}

.hero-home::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(56, 189, 248, 0.18) 0%, rgba(56, 189, 248, 0) 50%),
        radial-gradient(circle at 85% 10%, rgba(96, 165, 250, 0.16) 0%, rgba(96, 165, 250, 0) 45%);
    z-index: 0;
    pointer-events: none;
}

.hero-home__veil {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(110deg, rgba(4, 10, 26, 0.9) 0%, rgba(7, 17, 39, 0.76) 45%, rgba(8, 19, 44, 0.62) 100%),
        linear-gradient(180deg, rgba(8, 18, 42, 0.2) 0%, rgba(4, 8, 20, 0.58) 100%);
    z-index: 1;
    pointer-events: none;
}

.hero-home__content {
    position: relative;
    z-index: 2;
    background: linear-gradient(160deg, rgba(7, 19, 45, 0.56) 0%, rgba(8, 20, 46, 0.42) 100%);
    border: 1px solid rgba(148, 197, 255, 0.22);
    border-radius: 1.4rem;
    padding: clamp(1.5rem, 2.2vw, 2.5rem);
    box-shadow: 0 18px 42px rgba(2, 8, 24, 0.45);
    backdrop-filter: blur(2px);
}

@media (max-width: 640px) {
    .hero-home {
        background-position: 58% center;
    }

    .hero-home__content {
        border-radius: 1rem;
        padding: 1.25rem;
    }
}

/* ─── Cards ─── */
.card-hover {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.modules-card {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}
.modules-card:hover {
    transform: translateY(-3px);
}

/* ─── Progress Bars ─── */
.progress-bar {
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Sidebar ─── */
.sidebar-nav button {
    transition: all 0.2s ease;
}

/* Tab panel animation */
.onglet-panel {
    animation: fadeSlideIn 0.3s ease;
}

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

/* ─── Toast Notifications ─── */
.toast-enter {
    animation: toastSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast-exit {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%) scale(0.9); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to { opacity: 0; transform: translateX(100%) scale(0.9); }
}

/* ─── Form Elements ─── */
input, select, textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--ring-border) !important;
    box-shadow: var(--shadow-sm-ring) !important;
    outline: none !important;
}

/* ─── Buttons ─── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border-radius: var(--radius-btn);
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: var(--esu-700);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
    transition: all 0.2s ease;
}
.btn-primary:hover {
    background: var(--esu-800);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border-radius: var(--radius-btn);
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* ─── DataTables ─── */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--ring-border);
    box-shadow: var(--shadow-sm-ring);
    outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.375rem !important;
    padding: 0.375rem 0.75rem !important;
    transition: all 0.15s ease !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--esu-700) !important;
    border-color: var(--esu-700) !important;
    color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #e2e8f0 !important;
    border-color: #cbd5e1 !important;
}

table.dataTable { margin-top: 0 !important; }

.dataTables_wrapper .dataTables_info {
    padding-top: 0.75rem;
    font-size: 0.8125rem;
    color: #64748b;
}

/* ─── Skeleton Loading ─── */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 0.5rem;
}

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

/* ─── Hamburger toggle animation ─── */
#bouton-menu-mobile .hamburger-icon {
    transition: transform 0.3s ease;
}

#bouton-menu-mobile[aria-expanded="true"] {
    background-color: #f1f5f9;
}

#bouton-menu-mobile[aria-expanded="true"] .hamburger-ligne:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
    transition: transform 0.3s ease;
}
#bouton-menu-mobile[aria-expanded="true"] .hamburger-ligne:nth-child(2) {
    opacity: 0;
    transition: opacity 0.15s ease;
}
#bouton-menu-mobile[aria-expanded="true"] .hamburger-ligne:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
    transition: transform 0.3s ease;
}

/* ─── Responsive ─── */
@media (max-width: 767px) {
    #navigation-globale + main,
    #navigation-globale ~ main {
        padding-top: 5rem;
    }

    body.menu-mobile-ouvert {
        overflow: hidden;
    }
}

@media (min-width: 640px) {
    .inv-field { display: flex; align-items: center; gap: 1rem; }
    .inv-field > label { width: 20rem; flex-shrink: 0; margin-bottom: 0; }
    .inv-field > input,
    .inv-field > select,
    .inv-field > textarea { flex: 1 1 auto; width: 100%; }
}

/* ─── Reduced motion ─── */
@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;
    }
}

/* ─── Print: Carte de service ─── */
@media print {
    body * { visibility: hidden !important; }
    #carte-service-preview,
    #carte-service-preview * { visibility: visible !important; }
    #carte-service-preview {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        border: none;
        box-shadow: none;
    }
}
