/* ─── Palette ─────────────────────────────────────────────────────────────────
   Palette volontairement courte : un accent bleu, une couleur de marque
   (orange, liseré de l'en-tête), du vert/rouge réservé à l'état du calcul,
   et des gris pour tout le reste. */
:root {
    --ink:        #1f2937;   /* texte principal */
    --muted:      #6b7280;   /* libellés secondaires */
    --line:       #e5e7eb;   /* bordures */
    --line-soft:  #f0f1f4;   /* séparateurs internes */
    --bg:         #f5f6f8;   /* fond de page */
    --surface:    #ffffff;   /* cartes, barre latérale */
    --surface-2:  #f9fafb;   /* en-têtes de tableau, bandeaux */
    --accent:     #2563eb;   /* focus, boutons secondaires */
    --accent-bg:  #eff4ff;
    --brand:      #ee7d1f;   /* orange MSolution / IUT */
    --ok:         #15803d;
    --bad:        #b91c1c;
    --bad-bg:     #fef2f2;
    --radius:     8px;
}

/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    background: var(--bg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
header {
    background: var(--surface);
    border-bottom: 3px solid var(--brand);
    padding: 0 20px;
    height: 68px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    z-index: 10;
}

.header-logo {
    height: 44px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex-shrink: 0;
}

.header-brand .header-logo { height: 40px; }

.bug-report {
    font-size: 10.5px;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
}

.bug-report:hover { color: var(--accent); text-decoration: underline; }
.bug-short { display: none; }

.header-logo-iut {
    height: 52px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    margin-left: auto;
}

.header-titles {
    display: flex;
    align-items: center;
    padding-left: 20px;
    border-left: 1px solid var(--line);
    height: 36px;
}

header .sub {
    font-size: 18px;
    font-weight: 500;
    color: var(--ink);
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    width: fit-content;
    min-width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd0d8 transparent;
}

.section-block {
    border-bottom: 1px solid var(--line-soft);
    padding: 14px 18px 16px;
}

/* Sauvegardes : en bas de la barre latérale */
.save-block {
    border-bottom: none;
    margin-top: auto;
    border-top: 1px solid var(--line-soft);
}

.section-block h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 10px;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.param-row label { min-width: 90px; color: var(--muted); }
.param-row input, .param-row select { flex: 1; }

select, input[type=number], input[type=text] {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
select:hover, input:hover { border-color: #9ca3af; }

.full-w { width: 100%; }

/* ─── Support & load lists ────────────────────────────────────────────────── */
.item-list { list-style: none; margin-bottom: 8px; }
.item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-soft);
    flex-wrap: wrap;
}
.item-label { font-weight: 600; min-width: 16px; }
.inp-small { width: 130px; }
.inp-num { width: 72px; }
.lbl-inline { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ─── Composite pieces ────────────────────────────────────────────────────── */
.composite-pieces { margin-bottom: 8px; }
.piece-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.piece-sign { width: 44px; }
.piece-shape { width: 60px; }
.piece-coord { width: 72px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.btn-small, .btn-secondary {
    background: var(--surface);
    color: var(--accent);
    border: 1px solid #c7d2fe;
    font-weight: 500;
}
.btn-small { margin-top: 4px; }
.btn-small:hover, .btn-secondary:hover { background: var(--accent-bg); border-color: var(--accent); }

.btn-danger { color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.slot-manage { margin-top: -6px; margin-bottom: 16px; }

.btn-icon {
    background: transparent;
    color: #9ca3af;
    border: 1px solid transparent;
    padding: 3px 7px;
}
.btn-icon:hover { background: var(--bad-bg); color: var(--bad); }

/* ─── Barre de calcul ─────────────────────────────────────────────────────── */
.compute-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Message d'état statique (isostatique / hypo / hyper) */
.status {
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 500;
    border: 1px solid transparent;
}
.status-ok  { background: #f0fdf4; color: var(--ok);  border-color: #bbf7d0; }
.status-bad { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }

/* ─── Error ───────────────────────────────────────────────────────────────── */
#error-msg {
    background: var(--bad-bg);
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: var(--bad);
    padding: 6px 12px;
    display: none;
}

/* ─── Main panel ──────────────────────────────────────────────────────────── */
.main-panel {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #cbd0d8 transparent;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1px solid var(--line-soft);
}
.card-body { padding: 10px 0; }
.card-body-pad { padding: 10px 12px; }

/* ─── SVG containers ──────────────────────────────────────────────────────── */
.svg-wrap { width: 100%; }
.svg-wrap svg { width: 100%; height: auto; display: block; }
.schema-wrap svg { min-height: 160px; }

/* ─── Section info bar ────────────────────────────────────────────────────── */
#section-info {
    font-size: 13px;
    color: var(--muted);
    padding: 8px 14px;
    background: var(--surface-2);
    border-top: 1px solid var(--line-soft);
    min-height: 24px;
    font-variant-numeric: tabular-nums;
    white-space: pre-line;
}
#section-info:empty { display: none; }

/* ─── Section preview ─────────────────────────────────────────────────────── */
.section-preview-wrap {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.section-preview-wrap svg { width: 160px; height: 160px; flex-shrink: 0; }

/* ─── Tables ──────────────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    background: var(--surface-2);
    padding: 8px 12px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
th:first-child { text-align: center; }
td {
    padding: 7px 12px;
    text-align: right;
    border-bottom: 1px solid var(--line-soft);
    font-variant-numeric: tabular-nums;
}
td:first-child { text-align: center; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ─── Navier panel ────────────────────────────────────────────────────────── */
.navier-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
}
.navier-inputs label { color: var(--muted); }
.navier-inputs input { width: 90px; }
.navier-info {
    color: var(--muted);
    padding: 8px 16px;
    background: var(--surface-2);
    border-top: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
}
.navier-info span { margin-right: 18px; }
.navier-info strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ─── Rangée toujours visible (schéma + section) ─────────────────────────── */
.always-row {
    display: flex;
    gap: 16px;
    align-items: stretch;
    flex-wrap: wrap;
}
.always-schema { flex: 1; min-width: 280px; }
.always-section { flex: 0 0 220px; min-width: 180px; }

/* ─── Results container ───────────────────────────────────────────────────── */
#results { flex-direction: column; gap: 16px; }

/* ─── Slots de sauvegarde ─────────────────────────────────────────────────── */
.slot-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.slot-actions .btn-small { flex: 1; text-align: center; }

.slot-list { list-style: none; margin-bottom: 14px; }

/* Bloc Sauvegardes repliable (replié par défaut) */
.save-block summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.save-block summary::-webkit-details-marker { display: none; }
.save-block summary::before {
    content: '▸';
    font-size: 16px;
    line-height: 1;
    color: var(--muted);
    transition: transform 0.15s;
}
.save-block[open] summary::before { transform: rotate(90deg); }
.save-block summary h2 { margin-bottom: 0; }
.save-block[open] summary { margin-bottom: 10px; }
.save-block summary:hover h2 { color: var(--accent); }

/* Sous-parties « mémoire de cet ordinateur » / « fichier .json » */
.save-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-top: 4px;
}
.save-hint {
    width: 0; min-width: 100%;   /* suit la largeur de la barre sans l'élargir */
    font-size: 12px;
    color: var(--muted);
    margin: 2px 0 8px;
}

.slot-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.slot-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.slot-name::placeholder { color: #9ca3af; font-style: italic; }

.btn-slot {
    flex-shrink: 0;
    padding: 4px 7px;
    font-size: 14px;
    line-height: 1;
    border: 1px solid var(--line);
    background: var(--surface);
}
.btn-slot:hover:not(:disabled) { background: var(--accent-bg); }
.btn-slot:disabled { opacity: 0.3; cursor: default; }
.btn-slot-del { color: #9ca3af; }
.btn-slot-del:hover:not(:disabled) { background: var(--bad-bg); color: var(--bad); }

/* ─── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
    /* Un seul défilement : toute la page défile, plus de zones imbriquées */
    body { height: auto; overflow: visible; }
    .app-body, .main-panel { overflow: visible; }
    header { height: 56px; padding: 0 12px; }
    .header-logo, .header-brand .header-logo { height: 30px; }
    .bug-report { font-size: 9px; }
    .bug-long { display: none; }
    .bug-short { display: inline; }
    .header-logo-iut { height: 40px; }
    .header-titles { display: none; }
    .app-body { flex-direction: column; }
    .sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--line); overflow: visible; }
    .always-section { flex: 1 1 100%; }
    .main-panel { padding: 12px; }
}
