/* Yugen DS — Ressources — v2
   Dashboard sombre moderne (Fira Sans), sidebar admin, icônes SVG,
   accents rouge/or Yugen DS conservés mais posés avec plus de retenue. */

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

:root {
    --bg: #0B1120;
    --bg-elevated: #0F172A;
    --card: #131C30;
    --card-hover: #17223A;
    --muted: #1B2740;
    --border: #253048;
    --border-soft: #1C2740;
    --text: #EEF2F8;
    --text-muted: #8B96AC;
    --text-faint: #5B6579;

    --brand: #C0392B;
    --brand-hover: #A5311F;
    --gold: #E9B949;

    --good-bg: #103324;
    --good-text: #4ADE80;
    --good-border: #1C4A34;
    --missing-bg: #331414;
    --missing-text: #F87171;
    --missing-border: #4A1C1C;
    --pending-bg: #1B2131;
    --pending-text: #93A0B8;
    --pending-border: #29334A;

    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 24px; --space-6: 32px; --space-7: 48px;

    --radius-sm: 7px;
    --radius: 12px;
    --radius-lg: 18px;
    --sidebar-w: 232px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }

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

body {
    margin: 0;
    font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.2em; }

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 14px; }
p { margin: 0; }

::selection { background: var(--gold); color: #1B1200; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ============================= AUTH (login / setup) ============================= */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    background:
        radial-gradient(ellipse 900px 500px at 15% -10%, rgba(192, 57, 43, .18), transparent 60%),
        radial-gradient(ellipse 700px 500px at 100% 110%, rgba(233, 185, 73, .10), transparent 60%),
        var(--bg);
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--space-5);
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--gold);
}
.auth-brand .icon { width: 22px; height: 22px; }

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: var(--space-6) var(--space-5);
}

.auth-card h1 { text-align: center; }
.auth-card .subtitle { display: block; text-align: center; margin-bottom: var(--space-5); color: var(--text-muted); font-size: 0.9rem; }

/* ============================= PUBLIC SHELL ============================= */

.public-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(11, 17, 32, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}

.public-topbar .row {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    flex: none;
}
.brand .brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), #7B241C);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
}
.brand .brand-mark .icon { width: 17px; height: 17px; }

.public-topbar nav { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.nav-link {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem; font-weight: 500;
    color: var(--text-muted);
    transition: color 150ms var(--ease), background 150ms var(--ease);
    cursor: pointer;
    border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--muted); }
.nav-link.primary { background: var(--brand); color: #fff; }
.nav-link.primary:hover { background: var(--brand-hover); }

.public-main { max-width: 1180px; margin: 0 auto; padding: var(--space-6) 24px 72px; }

.hero {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: var(--space-5); flex-wrap: wrap;
    margin-bottom: var(--space-6);
}
.hero .subtitle { color: var(--text-muted); margin-top: 6px; font-size: 0.95rem; }

.search-box {
    position: relative;
    min-width: 260px;
}
.search-box .icon {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-faint); width: 17px; height: 17px;
}
.search-box input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 0.9rem;
}
.search-box input:focus { border-color: var(--gold); }

/* ============================= ADMIN SHELL (sidebar) ============================= */

.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px 16px;
    font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand .brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #7B241C); display: flex; align-items: center; justify-content: center; color: var(--gold); flex: none; }
.sidebar-brand .brand-mark .icon { width: 17px; height: 17px; }
.sidebar-brand span { font-size: 0.95rem; line-height: 1.25; }

.sidebar-nav { padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.sidebar-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem; font-weight: 500;
    transition: background 150ms var(--ease), color 150ms var(--ease);
    cursor: pointer;
}
.sidebar-link .icon { color: var(--text-faint); transition: color 150ms var(--ease); }
.sidebar-link:hover { background: var(--muted); color: var(--text); }
.sidebar-link:hover .icon { color: var(--text); }
.sidebar-link.active { background: rgba(233, 185, 73, .12); color: var(--gold); }
.sidebar-link.active .icon { color: var(--gold); }

.sidebar-section-label {
    padding: 14px 12px 4px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; color: var(--text-faint);
}

.sidebar-footer {
    border-top: 1px solid var(--border-soft);
    padding: var(--space-3);
    display: flex; flex-direction: column; gap: 2px;
}

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.sidebar-user .avatar {
    width: 30px; height: 30px; border-radius: 999px; flex: none;
    background: var(--muted); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: var(--gold);
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who .name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who .role { color: var(--text-faint); font-size: 0.75rem; }

.admin-main { flex: 1; min-width: 0; }

.admin-topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: var(--space-3);
    padding: 16px 28px;
    background: rgba(11, 17, 32, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text-faint); }
.breadcrumb .icon { width: 13px; height: 13px; }
.breadcrumb a:hover { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); font-weight: 500; }

.sidebar-toggle {
    display: none;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px; color: var(--text-muted); cursor: pointer;
}

.admin-content { padding: var(--space-6) 28px 72px; max-width: 1180px; }

/* ============================= SHARED: page header, buttons, cards ============================= */

.page-header {
    display: flex; justify-content: space-between; align-items: flex-end;
    flex-wrap: wrap; gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; font-size: 0.9rem; }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 0.87rem; font-weight: 500;
    cursor: pointer;
    transition: background 150ms var(--ease), border-color 150ms var(--ease), transform 100ms var(--ease);
}
.btn:hover { background: var(--card-hover); border-color: #33415C; }
.btn:active { transform: scale(.98); }
.btn .icon { width: 15px; height: 15px; }

.btn-primary { background: var(--brand); border-color: var(--brand-hover); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }

.btn-danger { background: transparent; border-color: var(--missing-border); color: var(--missing-text); }
.btn-danger:hover { background: var(--missing-bg); }

.btn-sm { padding: 6px 11px; font-size: 0.8rem; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.card-pad { padding: var(--space-5); }

/* Stat cards (admin dashboard) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    display: flex; flex-direction: column; gap: 10px;
}
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.stat-card .stat-icon .icon { width: 16px; height: 16px; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat-card.good .stat-icon { background: var(--good-bg); color: var(--good-text); }
.stat-card.missing .stat-icon { background: var(--missing-bg); color: var(--missing-text); }
.stat-card.pending .stat-icon { background: var(--pending-bg); color: var(--pending-text); }
.stat-card.total .stat-icon { background: rgba(233, 185, 73, .14); color: var(--gold); }

.section-title {
    display: flex; align-items: center; gap: var(--space-3);
    font-size: 1rem; font-weight: 600; margin: 0 0 var(--space-4);
}
.section-title .count { margin-left: auto; font-weight: 400; font-size: 0.82rem; color: var(--text-faint); }

/* Category groups (public + admin resource list) */
.category-block { margin-bottom: var(--space-6); }
.category-head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: var(--space-4);
}
.category-head .cat-icon {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--muted); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.category-head h2 { margin: 0; }
.category-head .count { margin-left: auto; font-size: 0.82rem; color: var(--text-faint); }

.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: var(--space-4);
}

.resource-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column;
    transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.resource-card:hover { border-color: #33415C; transform: translateY(-2px); }

.resource-thumb {
    aspect-ratio: 16/10; background: var(--muted);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-faint);
}
.resource-thumb img { width: 100%; height: 100%; object-fit: cover; }
.resource-thumb .icon { width: 26px; height: 26px; opacity: .5; }

.resource-body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 8px; }
.resource-name { font-weight: 600; font-size: 0.95rem; }
.resource-qty { color: var(--text-muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.resource-qty b { color: var(--text); font-weight: 600; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    align-self: flex-start;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    border: 1px solid transparent;
}
.badge .icon { width: 13px; height: 13px; }
.badge-good { background: var(--good-bg); color: var(--good-text); border-color: var(--good-border); }
.badge-missing { background: var(--missing-bg); color: var(--missing-text); border-color: var(--missing-border); }
.badge-pending { background: var(--pending-bg); color: var(--pending-text); border-color: var(--pending-border); }

.role-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
    background: var(--muted); border: 1px solid var(--border); color: var(--text-muted);
}
.role-badge.admin { color: var(--gold); border-color: rgba(233,185,73,.35); background: rgba(233,185,73,.08); }
.pill-muted { color: var(--text-faint); font-size: 0.78rem; }

/* ============================= TABLES ============================= */

.table-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 0.88rem; vertical-align: middle; }
th { color: var(--text-faint); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-elevated); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.015); }
.table-actions { display: flex; gap: 6px; }
.table-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--muted); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.table-thumb .icon { width: 16px; height: 16px; }

/* ============================= FORMS ============================= */

.form-grid { display: grid; gap: var(--space-4); max-width: 480px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field input[type="file"], .field select, .field textarea {
    width: 100%; padding: 10px 13px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.92rem;
    transition: border-color 150ms var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--gold); outline: none; }
.field .hint { color: var(--text-faint); font-size: 0.78rem; margin-top: 5px; }
.form-actions { display: flex; gap: 10px; margin-top: 2px; }
.checkbox-row { display: flex; align-items: center; gap: 7px; font-weight: 400; font-size: 0.85rem; color: var(--text-muted); }
.checkbox-row input { width: auto; }

.image-upload-row { display: flex; gap: var(--space-4); align-items: flex-start; flex-wrap: wrap; }
.image-upload-preview {
    width: 84px; height: 84px; border-radius: var(--radius-sm); flex: none;
    background: var(--bg-elevated); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    color: var(--text-faint);
}
.image-upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-upload-preview .icon { width: 26px; height: 26px; opacity: .5; }

.user-avatar {
    width: 28px; height: 28px; border-radius: 999px; flex: none;
    background: var(--muted); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; color: var(--gold);
}

/* Ligne de saisie de quantité, dans une cellule de tableau (catalogue) */
.qty-inline-form { display: flex; align-items: center; gap: 5px; }
.qty-inline-form input[type="number"] {
    width: 58px; padding: 6px 7px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.85rem;
}
.qty-inline-form input[type="number"]:focus { border-color: var(--gold); outline: none; }
.qty-inline-form .qty-sep { color: var(--text-faint); font-size: 0.85rem; }

/* Formulaire compact d'ajout d'un nouvel objet au catalogue, en bas de section */
.quick-add-form {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
}
.quick-add-form input[type="text"] {
    flex: 1; min-width: 180px; padding: 9px 12px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.88rem;
}
.quick-add-form input[type="text"]:focus { border-color: var(--gold); outline: none; }
.quick-add-form input[type="file"] { font-size: 0.78rem; color: var(--text-faint); max-width: 200px; }

/* Lignes d'ingrédients dans le formulaire de recette d'un craftable */
.recipe-rows { display: flex; flex-direction: column; gap: 8px; }
.recipe-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recipe-row select {
    flex: 1; min-width: 200px; padding: 9px 12px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.86rem;
}
.recipe-row select:focus { border-color: var(--gold); outline: none; }
.recipe-row input[type="number"] {
    width: 72px; padding: 9px 10px;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.86rem;
}
.recipe-row input[type="number"]:focus { border-color: var(--gold); outline: none; }

/* ============================= ALERTS / EMPTY STATE ============================= */

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 15px; border-radius: var(--radius-sm);
    margin-bottom: var(--space-4); font-size: 0.88rem; border: 1px solid transparent;
}
.alert .icon { width: 17px; height: 17px; margin-top: 1px; flex: none; }
.alert-error { background: var(--missing-bg); color: var(--missing-text); border-color: var(--missing-border); }
.alert-success { background: var(--good-bg); color: var(--good-text); border-color: var(--good-border); }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .icon { width: 34px; height: 34px; color: var(--text-faint); margin: 0 auto 14px; }
.empty-state p { margin-bottom: 14px; }

/* ============================= RESPONSIVE ============================= */

@media (max-width: 900px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 40;
        transform: translateX(-100%);
        transition: transform 220ms var(--ease);
        box-shadow: var(--shadow);
    }
    #sidebar-toggle:checked ~ .sidebar { transform: translateX(0); }
    #sidebar-toggle:checked ~ .sidebar-scrim { opacity: 1; pointer-events: auto; }
    .sidebar-scrim {
        position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30;
        opacity: 0; pointer-events: none; transition: opacity 220ms var(--ease);
    }
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .admin-content { padding: var(--space-5) 18px 56px; }
    .admin-topbar { padding: 14px 18px; }
}

@media (max-width: 640px) {
    .page-header { flex-direction: column; align-items: stretch; }
    .public-main { padding: var(--space-5) 16px 56px; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tbody tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 10px; padding: 4px; }
    .table-card { background: transparent; border: none; }
    td { border: none; padding: 7px 12px; }
    td::before { content: attr(data-label); display: block; font-size: 0.68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
}
