/* Sentinelle — 2/3 : composants (boutons, formulaires, cartes, badges, tableaux, alertes). */

/* ---- boutons ---- */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 34px; padding: 6px 14px; border-radius: var(--r);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; line-height: 1.3; white-space: nowrap; cursor: pointer;
    text-decoration: none; box-shadow: var(--shadow-sm);
    transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}
button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:active, .btn:active { transform: translateY(.5px); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.primary, .btn.primary {
    background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent);
}
.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm, button.sm { min-height: 28px; padding: 3px 10px; font-size: .8rem; border-radius: var(--r-sm); }
.btn .icon, button .icon { width: 15px; height: 15px; }
button.link {
    min-height: 0; padding: 0; border: 0; background: none; box-shadow: none;
    color: var(--accent-text); font-weight: 500;
}
button.link:hover { background: none; text-decoration: underline; }
button.link.danger, .danger-link { color: var(--danger); }
.inline { display: inline; margin: 0; }
form.rescan.is-running button { pointer-events: none; }
.spinner {
    width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor;
    border-right-color: transparent; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- formulaires ---- */
label { display: block; margin: 0 0 var(--s4); font-size: .85rem; font-weight: 500; color: var(--text); }
label > .muted { display: block; font-weight: 400; font-size: .78rem; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
label.check, label.small { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 500; margin: 0 0 var(--s3); }
label.check > .muted { display: inline; margin: 0; }
input, textarea, select {
    display: block; width: 100%; margin-top: 6px; padding: 7px 10px; min-height: 36px;
    font: inherit; font-size: .9rem; color: var(--text); background: var(--surface);
    border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-sm);
    transition: border-color .12s ease, box-shadow .12s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: .85; }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] {
    display: inline-block; width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0;
    accent-color: var(--accent); box-shadow: none; flex: none;
}
input[type=file] { padding: 6px; }
select {
    appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
input[type=search] {
    padding-left: 34px;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 11px center / 15px;
}
.form { margin-top: 0; }
.card.form { padding: var(--s6) var(--s6) var(--s5); }
.card.form, .card:has(> .form) { max-width: 980px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s5); }
.err { display: block; margin-top: 4px; color: var(--danger); font-size: .78rem; font-weight: 500; }
.req { color: var(--danger); font-weight: 700; }
.form-actions {
    display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap;
    margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border);
}
fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s4) var(--s5) var(--s1); margin: var(--s2) 0 var(--s4); background: var(--surface-2); }
fieldset legend { padding: 0 var(--s2); font-size: .8rem; font-weight: 600; color: var(--text-2); }
fieldset > p.muted { margin-bottom: var(--s4); }
fieldset label:not(.check) { font-weight: 500; }

/* ---- cartes ---- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
    padding: var(--s5) var(--s6); box-shadow: var(--shadow-sm); min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card + .card { margin-top: var(--s4); }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
    padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: .98rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--s5); }
.panel > .table-wrap { border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: none; }
.panel-body { padding: var(--s5); }

/* ---- badges, pastilles, compteurs ---- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
    font-size: .76rem; font-weight: 600; white-space: nowrap; line-height: 1.5;
    color: color-mix(in srgb, var(--c) 64%, var(--text));
    background: color-mix(in srgb, var(--c) 13%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.badge.big { font-size: .86rem; padding: 4px 12px 4px 10px; }
.pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
    font-size: .74rem; font-weight: 500; line-height: 1.6; white-space: nowrap;
    color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border);
}
.pill strong { font-weight: 700; }
.pill.srv { font-family: var(--mono); font-size: .72rem; }
.pill.on, .pill.ack { --t: var(--success); }
.pill.warn { --t: var(--warning); }
.pill.bad { --t: var(--danger); }
.pill.on, .pill.ack, .pill.warn, .pill.bad {
    color: var(--t); background: color-mix(in srgb, var(--t) 11%, var(--surface));
    border-color: color-mix(in srgb, var(--t) 30%, transparent);
}
.chip {
    display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px;
    padding: 0 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2);
    font-size: .74rem; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* ---- tableaux ---- */
.table-wrap {
    overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
    background: var(--surface-2);
    font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3); white-space: nowrap; padding-top: 9px; padding-bottom: 9px;
}
thead th:first-child { border-top-left-radius: var(--r-lg); }
thead th:last-child { border-top-right-radius: var(--r-lg); }
tbody tr { transition: background-color .1s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.off td { opacity: .55; }
td.when { white-space: nowrap; color: var(--text-3); font-variant-numeric: tabular-nums; }
.site-link { font-weight: 600; color: var(--text); overflow-wrap: break-word; }
.site-link:hover { color: var(--accent-text); }
.site-ext { color: var(--text-3); margin-left: 4px; display: inline-flex; padding: 2px; border-radius: 4px; }
.site-ext:hover, .site-ext:focus-visible { color: var(--accent-text); }
.site-ext .icon { width: 14px; height: 14px; }
.site-name { flex: 1 1 0; min-width: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions > * { margin-left: var(--s3); }
td.actions > :first-child { margin-left: 0; }
td.actions a { font-weight: 500; }
tr[hidden] { display: none !important; }

/* ---- alertes, vide, détails ---- */
.flash {
    display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s4);
    border-radius: var(--r); border: 1px solid; white-space: pre-line; font-weight: 500; box-shadow: var(--shadow-sm);
    --t: var(--success); color: var(--text);
    background: color-mix(in srgb, var(--t) 9%, var(--surface)); border-color: color-mix(in srgb, var(--t) 32%, transparent);
}
.flash .icon { color: var(--t); margin-top: 2px; }
.flash-error { --t: var(--danger); }
.notice-warn {
    --t: var(--warning); padding: var(--s4) var(--s5); margin: var(--s4) 0; border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--t) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--t) 30%, transparent); border-left: 3px solid var(--t);
    font-size: .88rem; color: var(--text-2);
}
.notice-warn strong:first-child { color: var(--text); }
.empty {
    padding: var(--s8) var(--s5); text-align: center; color: var(--text-3);
    background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
}
.table-wrap > .empty { border: 0; border-top: 1px solid var(--border); border-radius: 0; margin: 0; }
details > summary { cursor: pointer; color: var(--accent-text); font-weight: 500; width: fit-content; }
details > summary::marker { color: var(--text-3); }
pre.detail {
    white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border);
    padding: var(--s3) var(--s4); border-radius: var(--r); font: .78rem/1.55 var(--mono); color: var(--text-2); overflow-x: auto;
}
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); margin: var(--s3) 0 0; font-size: .88rem; }
dl.kv dt { color: var(--text-3); font-weight: 500; font-size: .8rem; padding-top: 1px; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---- barre de progression ---- */
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .35s ease; }

/* ---- responsive : formulaires & tableaux repliés en cartes ---- */
@media (max-width: 720px) {
    .grid2 { grid-template-columns: 1fr; }
    .card, .card.form { padding: var(--s4); }
}
@media (max-width: 640px) {
    .table-wrap { overflow-x: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
    .panel > .table-wrap { padding: var(--s3); }
    thead { display: none; }
    table, tbody, tr, td { display: block; width: auto; }
    tbody tr {
        background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
        margin-bottom: var(--s3); box-shadow: var(--shadow-sm); overflow: hidden;
    }
    tbody tr:hover { background: var(--surface); }
    td { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); padding: 9px var(--s4); min-width: 0; }
    tbody tr td:last-child { border-bottom: 0; }
    td::before {
        content: attr(data-label); flex: 0 0 84px; color: var(--text-3);
        font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding-top: 3px;
    }
    td[data-label=""]::before, td:not([data-label])::before { display: none; }
    td[data-label]:empty { display: none; }
    td > *, .site-link { min-width: 0; overflow-wrap: anywhere; }
    .pill { white-space: normal; }
    td.actions { justify-content: flex-end; background: var(--surface-2); text-align: left; }
    td.actions > * { margin-left: 0; }
}

/* ---- prompt de correction (fiche site, page serveur) ---- */
.prompt-box .card-head { align-items: flex-start; }
.prompt-box .card-head p { margin: 2px 0 0; max-width: 70ch; }
.prompt-body { padding: var(--s3) var(--s5) var(--s4); }
.prompt-body pre {
    margin: var(--s3) 0 0; max-height: 26rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
    padding: var(--s3) var(--s4); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
    font: .78rem/1.55 var(--mono); color: var(--text-2);
}

/* ---- modale (prompt de correction) ---- */
dialog.modal {
    width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
    border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-lg);
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgba(10, 12, 16, .5); }
.modal-head, .modal-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1rem; }
.modal-head p { margin: 2px 0 0; }
.modal-body { padding: var(--s4) var(--s5) var(--s2); overflow: auto; }
.modal-body textarea { margin: 0 0 var(--s3); min-height: 45vh; font: .78rem/1.55 var(--mono); background: var(--surface-2); }
.modal-foot { justify-content: flex-end; align-items: center; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---- actions du bloc prompt (copier + ouvrir dans Claude) ---- */
.prompt-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
