/* ============================================================
   CAFPM — Global CSS
   Design tokens, utilities, et responsive layout complet
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
    --transition-fast:    150ms;
    --transition-normal:  250ms;
    --spring-easing:      cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --smooth-easing:      cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width:      288px;
    --topbar-height:      64px;
    --radius-card:        16px;
    --radius-btn:         12px;
}

/* ── Motion utilities ─────────────────────────────────────── */
.spring-transform {
    transition-property: transform, box-shadow, background-color;
    transition-duration: var(--transition-normal);
    transition-timing-function: var(--spring-easing);
}

.fade-in-up {
    animation: fadeInUp 0.5s var(--smooth-easing) forwards;
    opacity: 0;
    transform: translateY(16px);
}
@keyframes fadeInUp {
    to { opacity: 1; transform: translateY(0); }
}

/* ── Glass panel ──────────────────────────────────────────── */
.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.06);
}

/* ── Tables responsives ───────────────────────────────────── */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-card);
}
.table-wrapper table {
    min-width: 600px;
    width: 100%;
    border-collapse: collapse;
}
@media (max-width: 640px) {
    .table-wrapper table {
        font-size: 12px;
    }
    .table-wrapper th,
    .table-wrapper td {
        padding: 6px 8px !important;
        white-space: nowrap;
    }
}

/* ── Sidebar mobile overlay ───────────────────────────────── */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    z-index: 40;
    transition: opacity var(--transition-normal) var(--smooth-easing);
}
#sidebar-overlay.active { display: block; }

/* ── Mobile sidebar slide-in ─────────────────────────────── */
@media (max-width: 767px) {
    aside.main-sidebar {
        position: fixed !important;
        left: 0; top: 0; bottom: 0;
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform 300ms var(--spring-easing);
        z-index: 50;
        display: flex !important;   /* toujours présent, juste hors écran */
    }
    aside.main-sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.15);
    }
    /* Le contenu principal prend toute la largeur sur mobile */
    main.main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ── Topbar mobile ────────────────────────────────────────── */
#mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-height);
    padding: 0 1rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}
@media (max-width: 767px) {
    #mobile-topbar { display: flex; }
}

/* ── Bouton hamburger ─────────────────────────────────────── */
.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px; height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.hamburger-btn:hover { background: #f1f5f9; }
.hamburger-btn span {
    display: block;
    width: 22px; height: 2px;
    border-radius: 2px;
    background: #475569;
    transition: all 250ms var(--spring-easing);
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Cards responsive grid ────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
}

/* ── Forms responsive ─────────────────────────────────────── */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .form-grid-2 { grid-template-columns: 1fr; }
}
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}
@media (max-width: 768px) {
    .form-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Input polishing ──────────────────────────────────────── */
.input-minimal {
    width: 100%;
    border-radius: 0.5rem;
    border: 1.5px solid #e2e8f0;
    background-color: rgba(255,255,255,0.8);
    padding: 0.625rem 0.875rem;
    font-size: 14px;
    transition: all var(--transition-fast) var(--smooth-easing);
}
.input-minimal:focus {
    outline: none;
    border-color: #FCD900;
    box-shadow: 0 0 0 3px rgba(252, 217, 0, 0.2);
    background-color: #fff;
}

/* ── Modals responsive ────────────────────────────────────── */
@media (max-width: 640px) {
    .modal-box {
        margin: 0.75rem;
        max-height: calc(100vh - 1.5rem);
        border-radius: 20px;
        overflow-y: auto;
    }
    .modal-grid-2 { grid-template-columns: 1fr !important; }
}

/* ── Tabs mobile scroll ───────────────────────────────────── */
.tab-scroll {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.tab-scroll::-webkit-scrollbar { display: none; }

/* ── Utility typography ───────────────────────────────────── */
p, .text-max-65 { max-width: 65ch; }

/* ── Touch-friendly tap targets ───────────────────────────── */
@media (max-width: 767px) {
    button, .sidebar-link, a {
        min-height: 44px;
    }
    .sidebar-link {
        padding: 14px 18px;
        font-size: 15px;
    }
}

/* ── Safe area for notched phones ─────────────────────────── */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* ── Texte en noir (2026-09-08) ───────────────────────────── */
body { color: #000000; }
.text-slate-300, .text-slate-400, .text-slate-500, .text-slate-600, .text-slate-700, .text-slate-800, .text-slate-900,
.text-gray-300, .text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700, .text-gray-800, .text-gray-900,
.text-zinc-300, .text-zinc-400, .text-zinc-500, .text-zinc-600, .text-zinc-700, .text-zinc-800, .text-zinc-900 {
    color: #000000 !important;
}

/* ── Toaster notifications ────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
@media (max-width: 480px) {
    #toast-container {
        left: 1rem; right: 1rem; bottom: 1rem;
    }
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    pointer-events: all;
    animation: toastIn 0.3s var(--spring-easing);
    backdrop-filter: blur(8px);
}
.toast-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.toast-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info    { background: #f5f5f4; color: #3F3E3B; border: 1px solid #e7e5e4; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
