/* assets/css/style.css — SIPP · adapté au système CRETH (PATH asbl)
   Navy #2B2C73 + Orange coral #EC7A4B · Nunito · WCAG AAA */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

:root {
    /* Marque */
    --creth-navy-900: #1F2058;
    --creth-navy-800: #2B2C73;   /* navy principal */
    --creth-navy-700: #3A3B8C;
    --creth-navy-100: #E8E8F2;

    --creth-orange-700: #C25A2E;
    --creth-orange-600: #D26939;
    --creth-orange-500: #EC7A4B; /* coral principal */
    --creth-orange-300: #F4A685;
    --creth-orange-200: #FBD4C2;

    --creth-red:      #D32C47;   /* erreur (sparingly) */
    --creth-success:  #2F7D4E;

    /* Neutres chauds (jamais blanc pur) */
    --neutral-50:  #FAF8F5;      /* fond page */
    --neutral-100: #F3EFE9;
    --neutral-200: #E7E1D7;
    --neutral-300: #D2CABD;
    --neutral-500: #8A7E6E;
    --neutral-700: #4E4538;
    --neutral-900: #1F1A12;

    /* Tokens sémantiques */
    --bg-page:     var(--neutral-50);
    --bg-surface:  #FFFFFF;
    --fg-1:        var(--neutral-900);
    --fg-2:        var(--neutral-700);
    --fg-muted:    var(--neutral-500);
    --fg-on-navy:  #FFFFFF;
    --fg-link:     var(--creth-orange-600);
    --fg-link-hover: var(--creth-orange-700);

    --border-subtle:  var(--neutral-200);
    --border-default: var(--neutral-300);
    --border-focus:   var(--creth-orange-500);

    /* Rayons */
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   24px;
    --radius-pill: 9999px;

    /* Ombres (navy-teintées, jamais noir pur) */
    --shadow-xs: 0 1px 2px rgba(43, 44, 115, .06);
    --shadow-sm: 0 2px 8px rgba(43, 44, 115, .08);
    --shadow-md: 0 8px 24px rgba(43, 44, 115, .12);
    --shadow-lg: 0 16px 40px rgba(43, 44, 115, .16);

    /* Easing */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--fg-1);
    min-height: 100vh;
    font-size: 18px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--fg-link); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
a:hover { color: var(--fg-link-hover); }

/* Focus accessible — anneau orange double */
*:focus { outline: none; }
*:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--creth-orange-200), 0 0 0 5px var(--creth-orange-600);
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── NAVBAR ── */
.navbar {
    background: var(--bg-surface);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid var(--border-subtle);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .85rem;
    text-decoration: none;
    color: var(--creth-navy-800);
}
.navbar-brand:hover { color: var(--creth-navy-800); }

.navbar-brand .logo-icon {
    width: 40px; height: 40px;
    background: var(--creth-navy-800);
    color: var(--fg-on-navy);
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
}
.navbar-brand .logo-icon svg { width: 22px; height: 22px; }

.navbar-brand .brand-text {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: .01em;
    color: var(--creth-navy-800);
    display: block;
    line-height: 1.1;
}

.navbar-brand .brand-sub {
    font-size: .72rem;
    color: var(--fg-muted);
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    display: block;
    line-height: 1.4;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.navbar-user .user-info { text-align: right; }
.navbar-user .user-name {
    color: var(--fg-1);
    font-weight: 700;
    font-size: .95rem;
    display: block;
    line-height: 1.2;
}
.navbar-user .user-role {
    color: var(--creth-orange-600);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
}

.btn-logout {
    background: transparent;
    color: var(--creth-navy-800);
    border: 1.5px solid var(--border-default);
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s var(--ease-out), color .2s var(--ease-out), border-color .2s var(--ease-out);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.btn-logout:hover {
    background: var(--creth-navy-100);
    border-color: var(--creth-navy-800);
    color: var(--creth-navy-800);
}
.btn-logout svg { width: 16px; height: 16px; }

/* ── LAYOUT ── */
.container { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem; }
.page-wrapper { padding: 3rem 0 5rem; }

.page-header { margin-bottom: 2.5rem; }
.page-header h1 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 2.2rem;
    color: var(--creth-navy-800);
    line-height: 1.15;
    letter-spacing: -.01em;
}
.page-header p { color: var(--fg-2); margin-top: .5rem; font-size: 1.05rem; }

/* ── CARDS ── */
.card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
    transition: box-shadow .2s var(--ease-out);
}

/* ── FILTERS BAR ── */
.filters-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
    align-items: center;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 260px;
}
.search-wrap .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-muted);
    pointer-events: none;
    display: flex;
}
.search-wrap .search-icon svg { width: 18px; height: 18px; }

.search-wrap input {
    width: 100%;
    padding: .85rem 1rem .85rem 2.75rem;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-surface);
    transition: border-color .2s var(--ease-out);
    outline: none;
    color: var(--fg-1);
}
.search-wrap input:focus {
    border-color: var(--border-focus);
}

select.filter-select {
    padding: .85rem 1rem;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-surface);
    cursor: pointer;
    outline: none;
    transition: border-color .2s var(--ease-out);
    color: var(--fg-1);
}
select.filter-select:focus { border-color: var(--border-focus); }

/* ── DOCS GRID ── */
.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.doc-card {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: box-shadow .25s var(--ease-out);
    animation: fadeUp .35s var(--ease-out) both;
}
.doc-card:hover { box-shadow: var(--shadow-md); }

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

.doc-card-header {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
}

.doc-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    background: var(--creth-navy-100);
    color: var(--creth-navy-800);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.doc-icon svg { width: 22px; height: 22px; }

.doc-title {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.3;
    color: var(--creth-navy-800);
}

.doc-desc {
    font-size: .95rem;
    color: var(--fg-2);
    flex: 1;
    line-height: 1.6;
}

.doc-meta {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    border-radius: var(--radius-pill);
    font-size: .8rem;
    font-weight: 700;
    background: var(--creth-navy-100);
    color: var(--creth-navy-800);
}

.doc-date {
    font-size: .85rem;
    color: var(--fg-muted);
    margin-left: auto;
    font-weight: 600;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: var(--creth-orange-500);
    color: #FFFFFF;
    padding: .65rem 1.4rem;
    border-radius: var(--radius-pill);
    font-size: .95rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s var(--ease-out);
    width: fit-content;
    margin-top: auto;
}
.btn-download:hover { background: var(--creth-orange-600); color: #FFFFFF; }
.btn-download:active { background: var(--creth-orange-700); }
.btn-download svg { width: 18px; height: 18px; }

/* ── STATS BANNER ── */
.stats-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-surface);
    color: var(--fg-1);
    border-radius: var(--radius-md);
    padding: 1.5rem 1.6rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    box-shadow: var(--shadow-sm);
}
.stat-card:nth-child(1) { background: var(--creth-navy-800); color: var(--fg-on-navy); }
.stat-card:nth-child(2) { background: var(--creth-orange-500); color: #FFFFFF; }
.stat-card:nth-child(3) { background: var(--bg-surface); color: var(--creth-navy-800); }
.stat-card:nth-child(4) { background: var(--bg-surface); color: var(--creth-navy-800); }

.stat-icon { display: flex; }
.stat-icon svg { width: 32px; height: 32px; }
.stat-num { font-weight: 800; font-size: 2rem; line-height: 1; letter-spacing: -.02em; }
.stat-label {
    font-size: .78rem;
    opacity: .85;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1.4rem;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background .2s var(--ease-out), color .2s var(--ease-out), border-color .2s var(--ease-out);
    line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--creth-orange-500);
    color: #FFFFFF;
}
.btn-primary:hover  { background: var(--creth-orange-600); color: #FFFFFF; }
.btn-primary:active { background: var(--creth-orange-700); }

.btn-secondary {
    background: transparent;
    color: var(--creth-navy-800);
    border: 1.5px solid var(--border-default);
}
.btn-secondary:hover {
    background: var(--creth-navy-100);
    border-color: var(--creth-navy-800);
    color: var(--creth-navy-800);
}

.btn-danger {
    background: var(--creth-red);
    color: #FFFFFF;
}
.btn-danger:hover { background: #B22439; color: #FFFFFF; }

.btn-success {
    background: var(--creth-success);
    color: #FFFFFF;
}

.btn-sm {
    padding: .4rem .9rem;
    font-size: .85rem;
    border-radius: var(--radius-pill);
}

/* ── FORMS ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: .92rem;
    font-weight: 700;
    margin-bottom: .45rem;
    color: var(--creth-navy-800);
}
.form-group label small { font-weight: 400; color: var(--fg-muted); }

.form-control {
    width: 100%;
    padding: .8rem 1rem;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color .2s var(--ease-out);
    background: var(--bg-surface);
    color: var(--fg-1);
    line-height: 1.5;
}
.form-control:focus { border-color: var(--border-focus); }
.form-control::placeholder { color: var(--fg-muted); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── ALERTS ── */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: .98rem;
    margin-bottom: 1.25rem;
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    line-height: 1.5;
}
.alert-success { background: #EAF4ED; color: #1F5A37; }
.alert-error   { background: #FBE9EC; color: #8A1B2D; }
.alert-info    { background: var(--creth-navy-100); color: var(--creth-navy-800); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .98rem; }
th {
    text-align: left;
    padding: .9rem 1rem;
    background: var(--neutral-100);
    color: var(--creth-navy-800);
    font-weight: 700;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    border-bottom: 1px solid var(--border-subtle);
}
td {
    padding: .95rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--fg-1);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--neutral-100); }
td code {
    font-family: 'JetBrains Mono', monospace, ui-monospace;
    background: var(--creth-navy-100);
    color: var(--creth-navy-800);
    padding: .15rem .5rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 600;
}

/* ── ADMIN SIDEBAR ── */
.admin-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}
.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem 0;
    position: sticky;
    top: 88px;
    box-shadow: var(--shadow-sm);
}
.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .85rem 1.5rem;
    color: var(--fg-2);
    text-decoration: none;
    font-size: .98rem;
    font-weight: 600;
    transition: background .15s var(--ease-out), color .15s var(--ease-out);
    border-left: 3px solid transparent;
}
.admin-sidebar a svg { width: 20px; height: 20px; }
.admin-sidebar a:hover {
    background: var(--neutral-100);
    color: var(--creth-navy-800);
}
.admin-sidebar a.active {
    background: var(--creth-navy-100);
    color: var(--creth-navy-800);
    border-left-color: var(--creth-orange-500);
}
.admin-content { flex: 1; min-width: 0; }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--creth-navy-800);
    background: linear-gradient(135deg, var(--creth-navy-900) 0%, var(--creth-navy-800) 100%);
    padding: 2rem;
}
.login-box {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.75rem 2.75rem;
    width: 100%;
    max-width: 440px;
}
.login-logo { text-align: center; margin-bottom: 2.25rem; }
.login-logo .icon {
    width: 64px; height: 64px;
    background: var(--creth-orange-500);
    color: #FFFFFF;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.login-logo .icon svg { width: 32px; height: 32px; }
.login-logo h1 {
    font-weight: 800;
    font-size: 1.75rem;
    color: var(--creth-navy-800);
    letter-spacing: -.01em;
}
.login-logo p {
    color: var(--fg-2);
    font-size: .98rem;
    margin-top: .35rem;
    line-height: 1.5;
}

.btn-login {
    width: 100%;
    background: var(--creth-orange-500);
    color: #FFFFFF;
    padding: .95rem;
    border: none;
    border-radius: var(--radius-pill);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s var(--ease-out);
    margin-top: .75rem;
}
.btn-login:hover  { background: var(--creth-orange-600); }
.btn-login:active { background: var(--creth-orange-700); }

.form-check { margin-top: .25rem; margin-bottom: .5rem; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .95rem;
    color: var(--fg-2);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--creth-orange-500);
}

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--fg-2);
}
.empty-state .empty-icon { display: inline-flex; margin-bottom: 1rem; color: var(--fg-muted); }
.empty-state .empty-icon svg { width: 56px; height: 56px; stroke-width: 1.5; }
.empty-state p { font-size: 1.05rem; }

/* ── MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 32, 88, .55);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
}
.modal h3 {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--creth-navy-800);
    margin-bottom: 1.25rem;
    letter-spacing: -.01em;
}

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
    body { font-size: 17px; }
    .page-header h1 { font-size: 1.85rem; }
}
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; height: 64px; }
    .admin-layout { flex-direction: column; gap: 1rem; }
    .admin-sidebar { width: 100%; position: static; }
    .docs-grid { grid-template-columns: 1fr; }
    .stats-banner { grid-template-columns: 1fr 1fr; }
    .login-box { padding: 2rem 1.5rem; }
}
