@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

:root {
    --c-bg: #f0f2f8;
    --c-surface: #ffffff;
    --c-surface-2: #f7f8fc;
    --c-border: rgba(18, 36, 80, 0.09);
    --c-text: #0f1f4b;
    --c-text-2: #4a567a;
    --c-text-3: #8892b0;
    --c-navy: #122554;
    --c-navy-dark: #0a1630;
    --c-blue: #2c54c4;
    --c-blue-light: #edf1ff;

    /* Service colors */
    --c-bspp: #c8293a;
    --c-bspp-light: #fff0f1;
    --c-bspp-mid: #f8d0d4;
    --c-sssm: #1e4fc2;
    --c-sssm-light: #edf1ff;
    --c-sssm-mid: #c5d2f8;
    --c-samu: #0e8a5f;
    --c-samu-light: #e8f7f2;
    --c-samu-mid: #b4e8d6;
    --c-smur: #7c3fd4;
    --c-smur-light: #f3eeff;
    --c-smur-mid: #d8c4f8;

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --shadow-xs: 0 1px 3px rgba(12, 20, 60, 0.06);
    --shadow-sm: 0 4px 12px rgba(12, 20, 60, 0.08);
    --shadow-md: 0 8px 24px rgba(12, 20, 60, 0.10);
    --shadow-lg: 0 20px 50px rgba(12, 20, 60, 0.14);
    --shadow-xl: 0 32px 80px rgba(12, 20, 60, 0.18);

    --font: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'DM Mono', monospace;

    --accent: var(--c-blue);
    --accent-light: var(--c-blue-light);
}

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

html { height: 100%; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--c-bg);
    color: var(--c-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
    background: var(--c-navy-dark);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0,0,0,0.25);
}
.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    height: 64px;
}
.brand a {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand a::before {
    content: '+';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--c-blue);
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 900;
}
.user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.7);
}
.user strong { color: #fff; font-weight: 600; }
.button-logout {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.8);
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.18s;
    cursor: pointer;
}
.button-logout:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* ─── NAV ────────────────────────────────────────────────────── */
.site-nav {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    overflow-x: auto;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav .container { padding: 0 24px; }
.site-nav ul {
    list-style: none;
    display: flex;
    gap: 2px;
    padding: 10px 0;
    white-space: nowrap;
}
.site-nav .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--c-text-2);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.16s;
    position: relative;
}
.site-nav .nav-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.site-nav .nav-link.active {
    background: var(--c-blue-light);
    color: var(--c-blue);
}
.site-nav .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--c-blue);
    border-radius: 2px 2px 0 0;
}

/* ─── LAYOUT ─────────────────────────────────────────────────── */
.container { width: min(1200px, calc(100% - 48px)); margin: 0 auto; }
.page-body { padding: 32px 0 60px; flex: 1; }

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--c-navy);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}
h1::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.4em;
    background: var(--c-blue);
    border-radius: 2px;
    flex-shrink: 0;
}
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; color: var(--c-navy); }
h3 { font-size: 0.95rem; font-weight: 700; color: var(--c-text-2); text-transform: uppercase; letter-spacing: 0.05em; }

/* ─── PANEL ──────────────────────────────────────────────────── */
.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.panel-section {
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 22px;
    margin-bottom: 20px;
}
.panel-section h3 {
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--c-border);
}

/* ─── GRID CARDS ─────────────────────────────────────────────── */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    box-shadow: var(--shadow-xs);
    transition: transform 0.18s, box-shadow 0.18s;
    position: relative;
    overflow: hidden;
}
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--c-blue), #6fa3ff);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card strong {
    display: block;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--c-navy);
    line-height: 1;
    margin-bottom: 6px;
}
.card span { font-size: 0.88rem; color: var(--c-text-2); font-weight: 500; }
.card-action { text-decoration: none; cursor: pointer; }
.card-action strong { font-size: 1rem; margin-bottom: 4px; }
.card-action:hover { border-color: var(--c-blue); }

/* ─── TABLE ──────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
    padding: 11px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--c-text-3);
    border-bottom: 2px solid var(--c-border);
    background: var(--c-surface-2);
}
.table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-border);
    font-size: 0.91rem;
    vertical-align: middle;
}
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td a {
    color: var(--c-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 5px 10px;
    border-radius: 6px;
    transition: background 0.15s;
    margin-right: 4px;
}
.table td a:hover { background: var(--c-blue-light); }
.table td a.danger { color: var(--c-bspp); }
.table td a.danger:hover { background: var(--c-bspp-light); }

/* ─── BUTTONS ────────────────────────────────────────────────── */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.button:hover { transform: translateY(-1px); }
.button-primary {
    background: var(--c-blue);
    color: #fff;
    box-shadow: 0 4px 14px rgba(44, 84, 196, 0.30);
}
.button-primary:hover {
    background: #2448ad;
    box-shadow: 0 6px 20px rgba(44, 84, 196, 0.40);
}
.button-secondary {
    background: var(--c-surface-2);
    color: var(--c-text-2);
    border: 1px solid var(--c-border);
}
.button-secondary:hover { background: #eaedf5; color: var(--c-text); }
.button-danger {
    background: var(--c-bspp-light);
    color: var(--c-bspp);
    border: 1px solid var(--c-bspp-mid);
}
.button-danger:hover { background: var(--c-bspp); color: #fff; }
.button-outline {
    background: transparent;
    border: 1.5px solid var(--c-border);
    color: var(--c-text-2);
}
.button-outline:hover { border-color: var(--c-blue); color: var(--c-blue); }
.button-sm { padding: 6px 12px; font-size: 0.8rem; }
.button-lg { padding: 13px 28px; font-size: 0.95rem; }

/* ─── FORMS ──────────────────────────────────────────────────── */
label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--c-text-2);
    letter-spacing: 0.01em;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.91rem;
    color: var(--c-text);
    background: var(--c-surface);
    margin-bottom: 18px;
    transition: border-color 0.16s, box-shadow 0.16s;
    appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(44, 84, 196, 0.12);
}
textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.form-group { margin-bottom: 4px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 20px;
}
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 20px;
}
.grid-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 20px;
}

/* ─── ALERTS ─────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-info    { background: var(--c-sssm-light); color: #1a3d9e; border-color: var(--c-sssm-mid); }
.alert-success { background: var(--c-samu-light); color: #0a5e3f; border-color: var(--c-samu-mid); }
.alert-warning { background: #fff8e1; color: #7a5800; border-color: #ffe082; }
.alert-danger  { background: var(--c-bspp-light); color: #8b1a24; border-color: var(--c-bspp-mid); }

/* ─── BADGES / SERVICE ───────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.badge-bspp { background: var(--c-bspp-light); color: var(--c-bspp); border: 1px solid var(--c-bspp-mid); }
.badge-sssm { background: var(--c-sssm-light); color: var(--c-sssm); border: 1px solid var(--c-sssm-mid); }
.badge-samu { background: var(--c-samu-light); color: var(--c-samu); border: 1px solid var(--c-samu-mid); }
.badge-smur { background: var(--c-smur-light); color: var(--c-smur); border: 1px solid var(--c-smur-mid); }

/* ─── ABCDE BILAN FORM ───────────────────────────────────────── */
.abcde-section {
    border-radius: var(--radius-md);
    padding: 20px 22px;
    margin-bottom: 16px;
    border: 1.5px solid;
    position: relative;
    overflow: hidden;
}
.abcde-section::before {
    content: attr(data-letter);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 6rem;
    font-weight: 900;
    opacity: 0.06;
    line-height: 1;
    pointer-events: none;
    font-family: var(--font-mono);
}
.abcde-section h3 {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.abcde-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 900;
    font-family: var(--font-mono);
    flex-shrink: 0;
}
.abcde-A { background: #fff3e0; border-color: #ffe0b2; color: #bf360c; }
.abcde-A .abcde-letter { background: #bf360c; color: #fff; }
.abcde-B { background: #e3f2fd; border-color: #bbdefb; color: #0d47a1; }
.abcde-B .abcde-letter { background: #1565c0; color: #fff; }
.abcde-C { background: #fce4ec; border-color: #f8bbd0; color: #880e4f; }
.abcde-C .abcde-letter { background: #c62828; color: #fff; }
.abcde-D { background: #f3e5f5; border-color: #e1bee7; color: #4a148c; }
.abcde-D .abcde-letter { background: #6a1b9a; color: #fff; }
.abcde-E { background: #e8f5e9; border-color: #c8e6c9; color: #1b5e20; }
.abcde-E .abcde-letter { background: #2e7d32; color: #fff; }

/* ─── LOGIN ──────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0a1630 0%, #122554 50%, #1a3580 100%);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '+';
    position: fixed;
    top: -100px;
    right: -100px;
    font-size: 500px;
    font-weight: 900;
    color: rgba(255,255,255,0.02);
    pointer-events: none;
    line-height: 1;
}
.login-panel {
    width: min(440px, 94vw);
    background: #fff;
    padding: 40px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}
.login-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--c-bspp), var(--c-sssm), var(--c-samu), var(--c-smur));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--c-navy);
    border-radius: 14px;
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    margin: 0 auto 20px;
}
.login-panel h1 {
    text-align: center;
    font-size: 1.4rem;
    margin-bottom: 8px;
    justify-content: center;
}
.login-panel h1::before { display: none; }
.login-subtitle {
    text-align: center;
    color: var(--c-text-3);
    font-size: 0.88rem;
    margin-bottom: 28px;
}
.login-panel .button-primary { width: 100%; justify-content: center; padding: 13px; }

/* ─── FOOTER ─────────────────────────────────────────────────── */
.footer {
    margin-top: auto;
    text-align: center;
    padding: 18px 0;
    color: var(--c-text-3);
    font-size: 0.82rem;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
}

/* ─── ACTIONS BAR ────────────────────────────────────────────── */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

/* ─── STATUS PILL ────────────────────────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}
.status-ouvert   { background: var(--c-samu-light); color: var(--c-samu); }
.status-clos     { background: #f3f4f6; color: #6b7280; }
.status-en_attente { background: #fff8e1; color: #92400e; }
.status-archivé  { background: #f1f5f9; color: #475569; }

/* ─── PRINT / PDF ────────────────────────────────────────────── */
@media print {
    .topbar, .site-nav, .footer,
    .toolbar, .no-print { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .page-body { padding: 0; }
    .panel { box-shadow: none; border-color: #e0e0e0; page-break-inside: avoid; }
    .abcde-section { page-break-inside: avoid; }
    .print-page { page-break-after: always; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 640px) {
    h1 { font-size: 1.35rem; }
    .panel { padding: 18px; }
    .panel-header { flex-direction: column; align-items: flex-start; }
    .grid-cards { grid-template-columns: 1fr 1fr; }
    .table td, .table th { padding: 10px 10px; }
}
