/* ============================================================
   Yggdrastage — Feuille de style
   Layout : sidebar desktop / topbar mobile, fond clair, cartes arrondies.
   ============================================================ */

:root {
    --c-bg: #f4f5f8;
    --c-surface: #ffffff;
    --c-border: #e2e5ec;
    --c-text: #1f2330;
    --c-muted: #6b7280;
    --c-primary: #4f46e5;
    --c-primary-dark: #3c34c4;
    --c-success: #16a34a;
    --c-warn: #d97706;
    --c-danger: #dc2626;
    --c-sidebar: #1a1d2b;
    --c-sidebar-text: #e6e7ee;
    --c-sidebar-active: #4f46e5;
    --radius: 12px;
    --shadow: 0 2px 6px rgba(20, 24, 45, .05);
    --shadow-lg: 0 10px 30px rgba(20, 24, 45, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .75rem 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--c-muted); font-size: .9em; }

/* ---------- Layout ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--c-sidebar);
    color: var(--c-sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1rem .75rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.25rem;
    padding: .25rem .5rem;
}
.brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--c-primary);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
}
.brand-name { font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    color: var(--c-sidebar-text);
    padding: .55rem .75rem;
    border-radius: 8px;
    font-size: .95rem;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: var(--c-sidebar-active); color: #fff; }
.nav-badge {
    background: var(--c-warn);
    color: #fff;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .75rem;
    margin-left: .35rem;
    font-weight: 600;
}

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { font-size: .85rem; margin-bottom: .75rem; }
.user-chip .muted { color: rgba(255,255,255,.55); }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
}
.page-title { margin: 0; font-size: 1.25rem; font-weight: 600; }
.burger {
    display: none;
    border: 0; background: transparent; font-size: 1.5rem; cursor: pointer;
}

.content { padding: 1.25rem 1.5rem; }
.appfoot { padding: 1rem 1.5rem; }

/* ---------- Cartes ---------- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.card h2 { margin-top: 0; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.stat-card {
    background: var(--c-surface);
    border-radius: var(--radius);
    border: 1px solid var(--c-border);
    padding: 1rem;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { color: var(--c-muted); font-size: .85rem; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block;
    background: var(--c-surface);
    color: var(--c-text);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: .5rem .9rem;
    cursor: pointer;
    font-size: .95rem;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #eef0f5; text-decoration: none; }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warn { background: var(--c-warn); color: #fff; border-color: var(--c-warn); }
.btn-outline { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.btn-outline:hover { background: rgba(255,255,255,.07); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: .25rem .55rem; font-size: .85rem; }

.actions-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions-row .grow { flex: 1; }

/* ---------- Formulaires ---------- */
.form { display: grid; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--c-muted); }
.form input, .form select, .form textarea {
    font: inherit;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: .55rem .7rem;
    width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: 2px solid var(--c-primary); outline-offset: 1px;
    border-color: var(--c-primary);
}
.form textarea { resize: vertical; min-height: 80px; }
.form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form .row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .8rem; }
.form fieldset { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 1rem; margin: 0; }
.form legend { padding: 0 .5rem; font-weight: 600; }

.checkbox-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.checkbox-row label { flex-direction: row; align-items: center; gap: .35rem; color: var(--c-text); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    background: var(--c-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table.data th, table.data td {
    text-align: left;
    padding: .7rem .85rem;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}
table.data th { background: #fafbfd; font-size: .85rem; text-transform: uppercase; color: var(--c-muted); letter-spacing: .03em; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafbfd; }

.tag {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    background: #eef0f5;
    color: var(--c-text);
}
.tag-stagiaire   { background: #ede9fe; color: #5b21b6; }
.tag-salarie     { background: #dbeafe; color: #1d4ed8; }
.tag-benevole    { background: #dcfce7; color: #166534; }
.tag-prestataire { background: #fef3c7; color: #92400e; }
.tag-autre       { background: #e5e7eb; color: #374151; }
.tag-actif       { background: #dcfce7; color: #166534; }
.tag-termine     { background: #fde68a; color: #92400e; }
.tag-archive     { background: #e5e7eb; color: #374151; }

/* ---------- Flash messages ---------- */
.flash-stack { padding: 0 1.5rem; }
.flash {
    padding: .7rem 1rem;
    border-radius: 8px;
    margin: .25rem 0;
    border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ---------- Calendrier ---------- */
.calendar {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.calendar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; border-bottom: 1px solid var(--c-border);
}
.calendar-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
}
.calendar-grid .dow {
    background: #fafbfd;
    color: var(--c-muted);
    padding: .4rem .5rem;
    font-size: .8rem;
    text-transform: uppercase;
    text-align: center;
    border-bottom: 1px solid var(--c-border);
}
.calendar-grid .cell {
    border-right: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
    min-height: 110px;
    padding: .35rem .45rem;
    font-size: .82rem;
    background: var(--c-surface);
}
.calendar-grid .cell.other { background: #fafbfd; color: var(--c-muted); }
.calendar-grid .cell .day-num { font-weight: 600; margin-bottom: .25rem; display: block; }
.calendar-grid .cell .ev {
    background: #ede9fe;
    color: #4c1d95;
    padding: 1px 6px;
    border-radius: 4px;
    display: block;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Installeur ---------- */
.install-body {
    background: linear-gradient(135deg, #4f46e5 0%, #1a1d2b 100%);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}
.install-card {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 540px;
}

/* ---------- Login ---------- */
.login-body {
    background: linear-gradient(135deg, #4f46e5 0%, #1a1d2b 100%);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}
.login-card {
    background: var(--c-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-card .brand-mark { margin: 0 auto .5rem; }
.login-card .form { text-align: left; margin-top: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        width: 240px;
        z-index: 1000;
        transition: left .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { left: 0; }
    .burger { display: inline-block; }
    .content { padding: 1rem; }
    .form .row-2, .form .row-3 { grid-template-columns: 1fr; }
}
