/* ============================================================
   Variables
   ============================================================ */
:root {
    --color-primary: #6c2bd9;
    --color-primary-hover: #5a22b8;
    --color-danger: #dc3545;
    --color-success: #198754;
    --color-text: #1a1a2e;
    --color-text-muted: #6c757d;
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-border: #dee2e6;
    --radius: 8px;
    --shadow: 0 2px 8px rgb(0 0 0 / 0.08);
    --font: system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Navigation
   ============================================================ */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

.nav__brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-primary);
    text-decoration: none;
}

.nav__links { display: flex; align-items: center; gap: 1rem; }

.nav__user { color: var(--color-text-muted); font-size: 0.875rem; }

.nav__link { color: var(--color-text); font-size: 0.9rem; }

.nav__link--primary {
    background: var(--color-primary);
    color: #fff;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.nav__link--primary:hover { background: var(--color-primary-hover); text-decoration: none; }

/* ============================================================
   Main
   ============================================================ */
.main {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash--success { background: #d1e7dd; color: #0a3622; }
.flash--danger  { background: #f8d7da; color: #58151c; }
.flash--warning { background: #fff3cd; color: #664d03; }
.flash--info    { background: #cff4fc; color: #055160; }

/* ============================================================
   Auth card (login / register)
   ============================================================ */
.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    max-width: 420px;
    margin: 2rem auto;
}

.auth-card__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--color-text);
}

.auth-card__footer {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-align: center;
}

/* ============================================================
   Forms
   ============================================================ */
.form { display: flex; flex-direction: column; gap: 1rem; }

.form__group { display: flex; flex-direction: column; gap: 0.3rem; }
/* L'attribut hidden doit l'emporter sur le display:flex ci-dessus (sinon le groupe reste visible). */
.form__group[hidden] { display: none; }

.form__group--checkbox { flex-direction: row; align-items: center; gap: 0.5rem; }

/* Largeur / hauteur côte à côte (choix de résolution) */
.form__row { display: flex; gap: 0.75rem; }
.form__col { flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }

.form__label { font-size: 0.875rem; font-weight: 600; color: var(--color-text); }

/* Case à cocher + libellé sur une même ligne (l'aide reste en dessous). */
.form__check { display: flex; align-items: center; gap: 0.5rem; }
.form__checkbox { width: 1rem; height: 1rem; margin: 0; cursor: pointer; accent-color: var(--color-primary); }
.form__label--check { font-weight: 500; cursor: pointer; }

.form__input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}

.form__input:focus { outline: none; border-color: var(--color-primary); }

/* Champ avec suffixe accolé (ex. € sur un montant) */
.input-group { display: flex; align-items: stretch; }

.input-group .form__input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group__suffix {
    display: inline-flex;
    align-items: center;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border);
    border-left: none;
    border-top-right-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.form__checkbox-label { font-size: 0.875rem; cursor: pointer; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font);
}

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

/* Actions de création/navigation dans les en-têtes de page */
.btn--action { background: #0d6efd; color: #fff; }
.btn--action:hover { background: #0b5ed7; text-decoration: none; }

.btn--full { width: 100%; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard__title { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.dashboard__subtitle { color: var(--color-text-muted); }
.dashboard__actions { display: flex; gap: 0.75rem; margin: 1.5rem 0; flex-wrap: wrap; }

/* ============================================================
   Page layout
   ============================================================ */
.page__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page__title  { font-size: 1.5rem; font-weight: 700; }
.page__actions { margin-top: 2rem; display: flex; gap: 0.75rem; }
.page__header-actions { display: flex; gap: 0.75rem; align-items: center; }
.page--narrow  { max-width: 720px; }
.text--muted   { color: var(--color-text-muted); font-size: 0.875rem; }

/* ============================================================
   Sections
   ============================================================ */
.section { margin-top: 2rem; }
.section__title { font-size: 1.125rem; font-weight: 600; margin-bottom: 1rem; color: var(--color-text); }

/* ============================================================
   Table
   ============================================================ */
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th { background: var(--color-bg); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); padding: 0.625rem 1rem; text-align: left; }
.table td { padding: 0.75rem 1rem; border-top: 1px solid var(--color-border); font-size: 0.9rem; vertical-align: middle; }
.table tr:hover td { background: #f4f4f8; }

/* ============================================================
   Badge
   ============================================================ */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge--pending   { background: #fff3cd; color: #664d03; }
.badge--running   { background: #cff4fc; color: #055160; }
.badge--assigned  { background: #d1ecf1; color: #0c5460; }
.badge--done      { background: #d1e7dd; color: #0a3622; }
.badge--failed    { background: #f8d7da; color: #58151c; }
.badge--cancelled { background: #e2e3e5; color: #383d41; }
.badge--timeout   { background: #fde8d8; color: #7c3a0a; }
.badge--offline   { background: #e2e3e5; color: #383d41; }
.badge--available { background: #d1e7dd; color: #0a3622; }
.badge--paused    { background: #fff3cd; color: #664d03; }
.badge--busy      { background: #cff4fc; color: #055160; }
.badge--stopping  { background: #fff3cd; color: #664d03; }

/* ============================================================
   Detail grid (show pages)
   ============================================================ */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.detail-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.detail-card__title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--color-text); }

/* ============================================================
   Definition list
   ============================================================ */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; font-size: 0.875rem; }
.dl dt { color: var(--color-text-muted); font-weight: 500; white-space: nowrap; }
.dl dd { color: var(--color-text); }
.dl__note { color: var(--color-text-muted); font-size: 0.85em; }

/* ============================================================
   Stats grid (provider dashboard)
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; text-align: center; box-shadow: var(--shadow); }
.stat-card__value { display: block; font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-card__label { display: block; font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* ============================================================
   Feature list (become-provider page)
   ============================================================ */
.feature-list { margin: 1rem 0 1.5rem; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9rem; }

/* ============================================================
   Misc
   ============================================================ */
.empty-state { color: var(--color-text-muted); font-style: italic; padding: 1.5rem 0; }
.code-block { background: #1e1e2e; color: #cdd6f4; padding: 1rem; border-radius: var(--radius); font-size: 0.85rem; overflow-x: auto; white-space: pre-wrap; }
/* Bouton accolé à droite d'un .input-group (ex. « Copier » sur le champ jeton) */
.input-group__btn {
    border: 1px solid var(--color-border);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 0 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font);
}
/* Fin séparateur à l'intérieur d'une carte */
.card__divider { border: none; border-top: 1px solid var(--color-border); margin: 1.25rem 0; }
.form__hint   { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.1rem; }
.form__errors { list-style: none; padding: 0; margin: 0.25rem 0 0; display: flex; flex-direction: column; gap: 0.2rem; }
.form__error  { font-size: 0.8rem; color: var(--color-danger); font-weight: 500; }
.form__input--mono { font-family: monospace; }

.result-image,
.result-video {
    max-width: 100%;
    width: 512px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    display: block;
    margin-bottom: 12px;
}

.result-text {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 12px;
}
.form__actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.auth-card__subtitle { color: var(--color-text-muted); margin-bottom: 1rem; font-size: 0.9rem; }
.btn--secondary { background: #e9ecef; color: var(--color-text); }
.btn--secondary:hover { background: #dee2e6; text-decoration: none; }
.btn--ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--ghost:hover { background: var(--color-bg); text-decoration: none; }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--danger:hover { background: #bb2d3b; text-decoration: none; }
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; }
.tag { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 999px; padding: 0.2rem 0.75rem; font-size: 0.8rem; color: var(--color-text); }

/* ============================================================
   Modale (dialog natif HTML5)
   ============================================================ */

/* Pas de display ici : le navigateur applique display:none sur dialog:not([open]).
   On active flex uniquement quand la dialog est ouverte via showModal(). */
.modal {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    padding: 0;
    max-width: 640px;
    width: 90%;
    max-height: 85vh;
    margin: auto; /* centrage horizontal ; showModal() centre dans le viewport */
}
.modal[open] {
    display: flex;
    flex-direction: column;
}
.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}
.modal__panel {
    display: flex;
    flex-direction: column;
    min-height: 0; /* nécessaire pour que flex + overflow fonctionne */
    flex: 1;
}
.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.modal__title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.modal__close {
    padding: 0.25rem 0.6rem;
    font-size: 1.1rem;
    line-height: 1;
}
.modal__body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.modal__body h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.4rem;
}
.modal__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}
