/* =========================================================================
   ponera/app-toolkit — interface commune des apps Ponera (tokens et composants de Sauron).
   Composants : layout (.app .sidebar .main .topbar .content), .btn, .badge, .panel .toolbar
   .table, .state, .card, .config-grid, .kv, .tag, .exec-header, utilitaires (.muted .mono
   .flex-between .stack-actions .section-stack). Couleurs : variables --c-* de :root.
   ========================================================================= */

:root {
    --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

    /* Surfaces */
    --c-bg: #f7f8fa;
    --c-surface: #fff;
    --c-surface-alt: #fafbfc;
    --c-sidebar: #181d27;
    --c-sidebar-hover: rgba(255, 255, 255, .07);

    /* Texte */
    --c-text: #161b22;
    --c-text-2: #5a6472;
    --c-text-3: #8a93a3;
    --c-text-disabled: #b4bac4;
    --c-sidebar-text: #c4cad6;
    --c-sidebar-muted: #7e8798;
    --c-sidebar-label: #5b6475;

    /* Bordures */
    --c-border: #e7e9ee;
    --c-border-soft: #eef0f3;
    --c-border-strong: #d9dce2;

    /* Accents */
    --c-accent: #ec5c43;
    --c-blue: #1257c7;
    --c-indigo: #443ce0;
    --c-green: #0b7a43;
    --c-green-dot: #14a85c;
    --c-red: #c0341d;
    --c-amber-bg: #fdf3c4;
    --c-amber-text: #7a5b00;

    --radius: 8px;
    --radius-lg: 10px;
    --shadow-card: 0 1px 3px rgba(16, 24, 40, .07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--c-text);
    background: var(--c-bg);
    -webkit-font-smoothing: antialiased;
}

@keyframes srpulse {
    0% { opacity: 1; }
    50% { opacity: .3; }
    100% { opacity: 1; }
}

@keyframes srshimmer {
    0% { background-position: -450px 0; }
    100% { background-position: 450px 0; }
}

a {
    color: var(--c-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.mono {
    font-family: var(--font-mono);
}


/* ----------------------------------------------------------------- layout */

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

.sidebar {
    width: 236px;
    flex-shrink: 0;
    background: var(--c-sidebar);
    color: var(--c-sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px 14px;
}

.sidebar__logo {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* léger halo de flamme : l'œil qui veille */
    filter: drop-shadow(0 0 6px rgba(236, 92, 67, .45));
}

.sidebar__logo svg {
    display: block;
}

.sidebar__brand-name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.sidebar__brand-sub {
    font-family: var(--font-mono);
    font-size: 10px;
    color: #7a8396;
    margin-top: 3px;
}

.sidebar__group {
    padding: 12px 16px 6px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: .09em;
    color: var(--c-sidebar-label);
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-sidebar-text);
    border-left: 3px solid transparent;
}

a.sidebar__item:hover {
    text-decoration: none;
    background: var(--c-sidebar-hover);
}

.sidebar__item--active {
    border-left-color: var(--c-accent);
    background: var(--c-sidebar-hover);
    font-weight: 600;
    color: #fff;
}


.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 26px;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
}

.topbar__crumb {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .03em;
    color: var(--c-text-3);
    margin-bottom: 6px;
}

.topbar__title {
    font-size: 20px;
    font-weight: 700;
}

.content {
    padding: 22px 26px;
    flex: 1;
}

.content--flush {
    padding: 0;
}


/* --------------------------------------------------------------- éléments */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--c-border-strong);
    background: var(--c-surface);
    color: var(--c-text-2);
    cursor: pointer;
}

.btn:hover {
    text-decoration: none;
    border-color: var(--c-text-3);
}

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

.btn--danger {
    color: var(--c-red);
    border-color: #f0c4bc;
}


/* badges de statut */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

.badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}


/* ------------------------------------------------------------------ liste */

.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    /* overflow visible : sinon le menu d'actions (⋮) est rogné sur les dernières lignes.
       Les coins sont arrondis sur les enfants de bord plutôt que par un clip global. */
    overflow: visible;
}

.panel > .toolbar:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.panel > .table tbody tr:last-child td:first-child {
    border-bottom-left-radius: var(--radius-lg);
}

.panel > .table tbody tr:last-child td:last-child {
    border-bottom-right-radius: var(--radius-lg);
}

.panel > .state {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 22px;
    border-bottom: 1px solid var(--c-border-soft);
    background: var(--c-surface-alt);
    flex-wrap: wrap;
}

.toolbar input[type="search"],
.toolbar select {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    padding: 8px 11px;
}

.toolbar input[type="search"] { width: 248px; }

.toolbar__count {
    margin-left: auto;
    font-size: 12px;
    color: var(--c-text-3);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 9px 16px;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: .05em;
    color: var(--c-text-3);
    background: var(--c-surface-alt);
    border-bottom: 1px solid var(--c-border);
}

.table td {
    padding: 13px 16px;
    vertical-align: top;
    border-bottom: 1px solid #f0f1f4;
}

.table tr:last-child td { border-bottom: 0; }

.table tr.is-inactive td { background: #fcfcfd; }

.table .num { text-align: center; font-family: var(--font-mono); font-size: 12px; color: var(--c-text-2); }

.cell-title { font-weight: 600; font-size: 13.5px; display: inline-block; }
a.cell-title { color: var(--c-text); }
a.cell-title:hover { color: var(--c-blue); text-decoration: underline; }
.cell-sub { font-size: 11px; color: var(--c-text-3); margin-top: 4px; }
.cell-cron { font-family: var(--font-mono); font-weight: 500; font-size: 12px; }

.row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}

.muted { color: var(--c-text-disabled); }


/* états vide / erreur */
.state {
    padding: 54px 24px 58px;
    text-align: center;
}

.state__icon {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    background: #f1f3f7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    font-size: 26px;
}

.state__icon--error { background: #fdecea; }

.state__title { font-weight: 600; font-size: 16px; }

.state__text {
    font-size: 13.5px;
    color: var(--c-text-3);
    margin-top: 8px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.state__detail {
    display: inline-block;
    margin-top: 14px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--c-red);
    background: #fdf0ee;
    border: 1px solid #f6d7d1;
    border-radius: 6px;
    padding: 7px 11px;
}

.state__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}


.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
}

.card__title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card__title::before {
    content: "";
    width: 5px;
    height: 14px;
    background: var(--c-accent);
    border-radius: 2px;
}

.card__title--muted::before { background: #9aa1ad; }

.card__hint { font-weight: 400; color: var(--c-text-3); font-size: 12px; }

.config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 28px;
}

@media (max-width: 720px) {
    .config-grid { grid-template-columns: 1fr; }
}

.config-section__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--c-text-3);
    margin-bottom: 12px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    padding: 4px 0;
}

.summary-row .k { color: var(--c-text-3); }


.exec-header {
    padding: 16px 26px 18px;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface);
}

.exec-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.exec-title { font-weight: 700; font-size: 19px; }

.exec-id {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--c-text-3);
    background: #f1f3f7;
    border-radius: 5px;
    padding: 4px 8px;
}

.exec-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 11px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--c-text-2);
}

.exec-desc {
    margin-top: 10px;
    max-width: 720px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--c-text-2);
    white-space: pre-wrap;
}

.tag {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    background: #f1f3f7;
    border-radius: 6px;
    padding: 5px 9px;
    color: var(--c-text);
}

.tag .k { color: var(--c-text-3); }

.exec-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.exec-main { flex: 1; min-width: 0; }
.exec-rail { width: 312px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }

.kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12.5px;
    padding: 5px 0;
}

.kv .k { color: var(--c-text-3); }
.kv .v { font-family: var(--font-mono); font-size: 12px; }
.kv--sep { border-top: 1px solid var(--c-border-soft); padding-top: 11px; margin-top: 6px; }


.section-stack { display: flex; flex-direction: column; gap: 11px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stack-actions { display: flex; gap: 10px; }

/* ------------------------------------------------------------- statuts génériques */

.badge--ok { background: #e7f8ee; color: var(--c-green); }
.badge--ok .badge__dot { background: var(--c-green-dot); }
.badge--error { background: #fdecea; color: var(--c-red); }
.badge--error .badge__dot { background: var(--c-accent); }
.badge--warning { background: var(--c-amber-bg); color: var(--c-amber-text); }
.badge--warning .badge__dot { background: #caa300; }
.badge--neutral { background: #f1f3f7; color: #4a5364; }
.badge--neutral .badge__dot { background: #98a2b3; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
