/* ==============================================================
   IMPACT SERVICE CÔTE D'IVOIRE — Design system applicatif
   Palette drapeau : vert #009E60 · orange #F77F00
   ============================================================== */
:root {
    --isci-green: #009E60;
    --isci-green-dark: #007A4B;
    --isci-green-deep: #04442C;
    --isci-orange: #F77F00;
    --isci-orange-soft: #FFB25C;
    --sidebar-width: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
    --border: #e8edf3;
    --bg: #f2f5f9;
    --ink: #1f2937;
    --muted: #8a94a6;
    --speed: .22s;
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { scrollbar-width: thin; scrollbar-color: #c7d2dd transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #c7d2dF; border-radius: 8px; }

html { scroll-behavior: smooth; }
body {
    background: var(--bg-body, #f2f5f9);
    background:
        radial-gradient(1100px 500px at 100% -10%, rgba(0, 158, 96, .06), transparent 60%),
        radial-gradient(900px 420px at -10% 110%, rgba(247, 127, 0, .05), transparent 60%),
        #f2f5f9;
    font-family: var(--font);
    font-size: .925rem;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------- Structure ---------- */
.app-shell { min-height: 100vh; }
.main { margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.content { flex: 1; padding: 1.4rem 1.6rem; max-width: 1500px; }
.app-footer {
    padding: .8rem 1.4rem; color: var(--muted); font-size: .78rem;
    border-top: 1px solid var(--border); background: rgba(255,255,255,.6);
}

/* ---------- Navigation latérale ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width);
    background:
        radial-gradient(300px 220px at -20% 0%, rgba(247,127,0,.14), transparent 60%),
        linear-gradient(185deg, #0b5b3b 0%, var(--isci-green-dark) 46%, var(--isci-green-deep, #03432C) 100%);
    color: #e9fbf2; display: flex; flex-direction: column; z-index: 1040;
    box-shadow: 4px 0 24px rgba(3, 55, 37, .18);
    transition: transform var(--speed) ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .7rem; padding: 1.05rem 1.05rem .95rem;
    border-bottom: 1px solid rgba(255,255,255,.14);
}
.brand-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; box-shadow: var(--shadow-sm); }
.brand-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 10px; background: var(--isci-orange);
    color: #fff; font-weight: 700; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(247,127,0,.35);
}
.brand-name { display: block; font-size: .95rem; letter-spacing: .5px; line-height: 1.15; }
.brand-sub { display: block; opacity: .72; font-size: .64rem; letter-spacing: 1.6px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .55rem .6rem .9rem; }
.nav-group-title {
    font-size: .62rem; text-transform: uppercase; letter-spacing: 1.4px;
    color: rgba(234,255,243,.5); padding: .8rem .7rem .3rem; font-weight: 700;
}
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: .6rem;
    color: #d9f4e7; text-decoration: none; padding: .55rem .7rem;
    border-radius: var(--radius-sm); margin-bottom: .15rem; font-size: .88rem;
    transition: background var(--speed), color var(--speed), transform var(--speed);
}
.nav-item i { font-size: 1rem; width: 1.2rem; text-align: center; opacity: .85; }
.nav-item::before {
    content: ""; position: absolute; left: -0.6rem; top: 50%; translate: 0 -50%;
    width: 3px; height: 0; border-radius: 3px; background: var(--isci-orange);
    transition: height var(--speed) ease;
}
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; transform: translateX(2px); }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav-item.active::before { height: 60%; }
.nav-item.active i { color: var(--isci-orange); opacity: 1; }
.nav-item.disabled { opacity: .45; cursor: not-allowed; }
.nav-item .soon {
    font-size: .6rem; text-transform: uppercase; letter-spacing: .8px;
    border: 1px solid currentColor; border-radius: 20px; padding: 0 .45rem; opacity: .8;
}
.sidebar-footer { padding: .7rem 1.1rem; font-size: .7rem; opacity: .65; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    background: rgba(255,255,255,.86); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: .8rem; padding: .6rem 1.3rem;
    transition: box-shadow var(--speed) ease;
}
.topbar.scrolled { box-shadow: var(--shadow-sm); }
.topbar-title { font-weight: 700; font-size: 1.02rem; flex: 1; letter-spacing: .2px; }
.topbar-chip {
    font-size: .74rem; color: #52616f; background: #eef2f7;
    border: 1px solid #e2e8f0; padding: .22rem .6rem; border-radius: 20px; white-space: nowrap;
}
.burger { display: none; background: none; border: 0; font-size: 1.35rem; line-height: 1; color: var(--ink); }
.user-btn { display: flex; align-items: center; gap: .55rem; background: transparent; border-radius: 30px; padding: .25rem .65rem .25rem .3rem; transition: background var(--speed); }
.user-btn:hover { background: #eef2f6; }
.user-btn::after { margin-left: .1rem; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--isci-green), var(--isci-green-dark));
    color: #fff; font-weight: 700; box-shadow: 0 2px 6px rgba(0,158,96,.35);
}
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.dropdown-item:active { background: var(--isci-green); }

/* ---------- Entrée de page : animations douces ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.content > * { animation: pageIn .32s ease both; }
.content > .row > .card,
.content > .card { animation: riseIn .4s ease both; }
.content > .row > *:nth-child(1) { animation-delay: .02s; }
.content > .row > *:nth-child(2) { animation-delay: .07s; }
.content > .row > *:nth-child(3) { animation-delay: .12s; }
.content > .row > *:nth-child(4) { animation-delay: .17s; }
.content > .row > *:nth-child(4) ~ * { animation-delay: .2s; }

/* ---------- Cartes ---------- */
.card {
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); transition: box-shadow var(--speed) ease, transform var(--speed) ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }

/* ---------- Cartes statistiques ---------- */
.stat-card { position: relative; border-left: 4px solid var(--isci-green); overflow: hidden; }
.stat-card::after {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, var(--isci-green), transparent); opacity: .35;
}
.stat-card .stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); font-weight: 700; }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 800; letter-spacing: .3px; }
.stat-card.stat-money { border-left-color: var(--isci-orange); }
.stat-card.stat-money::after { background: linear-gradient(90deg, var(--isci-orange), transparent); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ---------- Boutons ---------- */
.btn { border-radius: var(--radius-sm); font-weight: 600; transition: all var(--speed) ease; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--isci-green); border-color: var(--isci-green); }
.btn-primary:hover, .btn-primary:focus { background: var(--isci-green-dark); border-color: var(--isci-green-dark); box-shadow: 0 4px 14px rgba(0,158,96,.28); }
.btn-outline-primary { color: var(--isci-green-dark); border-color: var(--isci-green); }
.btn-outline-primary:hover { background: var(--isci-green); border-color: var(--isci-green); }
.btn-success { background: #0d9459; border-color: #0d9459; }
.btn-outline-success:hover { background: #0d9459; }
.btn-sm { --bs-btn-padding-y: .28rem; }

.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 1rem; height: 1rem; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #d7dee8; }
.form-control:focus, .form-select:focus { border-color: var(--isci-green); box-shadow: 0 0 0 .18rem rgba(0,158,96,.14); }
.form-label { font-weight: 600; font-size: .82rem; color: #45526b; }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: #f4faf7; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .7px; color: #6b7a90;
    border-bottom: 2px solid #e6ebf2 !important; background: #fbfcfe;
}
.table tbody tr { transition: background .15s ease; }
.table-sm td, .table-sm th { padding: .42rem .5rem; }

/* ---------- Pagination ---------- */
.pagination { --bs-pagination-color: var(--isci-green-dark); --bs-pagination-active-bg: var(--isci-green); --bs-pagination-border-color: var(--border); }
.pagination .page-link { border-radius: var(--radius-sm) !important; margin: 0 .12rem; border: 1px solid #dfe6ee !important; }

/* ---------- Alertes / flash ---------- */
.alert { border-radius: var(--radius); border: 0; box-shadow: var(--shadow-sm); animation: slideDown .35s ease both; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: #e7f8ef; color: #0b6e46; border-left: 4px solid var(--isci-green); }
.alert-danger  { background: #fdeeee; color: #a02828; border-left: 4px solid #dc3545; }
.alert-info    { background: #e8f4fd; color: #12557e; border-left: 4px solid #0d6efd; }
.alert-secondary { background: #f1f3f6; color: #55606e; border-left: 4px solid #adb9c7; }
.alert-warning { background: #fff6e8; color: #9a6200; border-left: 4px solid var(--isci-orange); }

/* ---------- Badges ---------- */
.badge { font-weight: 600; letter-spacing: .3px; border-radius: 20px; padding: .34em .7em; }

/* ---------- Barres de progression animées ---------- */
.progress { background: #edf1f6; border-radius: 20px; }
.progress-bar { transition: width .8s cubic-bezier(.22,.68,.42,1); }

/* ---------- Authentification ---------- */
.auth-body {
    background:
        radial-gradient(700px 380px at 85% -10%, rgba(247,127,0,.25), transparent 60%),
        linear-gradient(135deg, #06492f 0%, var(--isci-green-dark) 55%, var(--isci-green) 100%);
    min-height: 100vh;
}
.auth-wrapper { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 440px; border: 0; animation: riseIn .5s ease both; box-shadow: var(--shadow-lg) !important; }
.auth-logo { width: 72px; height: 72px; object-fit: contain; border-radius: 14px; background: #fff; padding: 5px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }

/* ---------- Divers ---------- */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
a { text-decoration-color: rgba(0,158,96,.35); }
.text-success { color: #0d9459 !important; }
.dropdown-menu { animation: slideDown .18s ease both; }
.nav-link, .btn { -webkit-tap-highlight-color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .burger { display: inline-block; }
    .sidebar-backdrop.show {
        display: block; position: fixed; inset: 0;
        background: rgba(6, 40, 28, .5); backdrop-filter: blur(2px); z-index: 1035;
    }
    .content { padding: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    html { scroll-behavior: auto; }
}

/* ---------- Impression (reçus, rapports) ---------- */
@media print {
    .sidebar, .topbar, .app-footer, .btn, .burger, .no-print, .sidebar-backdrop { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff !important; }
    .card { border: 1px solid #cfd6de; box-shadow: none !important; break-inside: avoid; }
    .content > * { animation: none !important; }
}
