/*
 * Design tokens for the admin panel.
 *
 * Structure and rules come from /DESIGN.md (calm layout, hairline borders, 8px spacing,
 * 8px buttons/inputs, sentence-case labels, one primary action per view).
 * COLORS come from the Sneat admin theme (purple #696cff, cool gray canvas) so every
 * screen matches the sidebar and the rest of the panel.
 *
 * Use these variables and .ds-* classes for all admin UI.
 * Do not hardcode hex colors in Blade or page CSS — reference var(--ds-*).
 */
:root {
    /* Brand — Sneat primary (same as the active sidebar item) */
    --ds-primary: #696cff;
    --ds-primary-hover: #5f61e6;
    --ds-primary-soft: #e7e7ff;      /* active menu background, primary badges */
    --ds-primary-tint: #f4f4ff;      /* info panels, row hover */
    --ds-primary-shadow: 0 2px 4px 0 rgba(105, 108, 255, 0.4);
    --ds-on-primary: #ffffff;

    /* Text — Sneat slate */
    --ds-ink: #566a7f;               /* headings, labels */
    --ds-ink-body: #697a8d;          /* body text */
    --ds-ink-muted: #8592a3;         /* secondary text */
    --ds-ink-subtle: #a1acb8;        /* captions, hints */
    --ds-ink-tertiary: #b4bdc6;      /* disabled */

    /* Surfaces */
    --ds-canvas: #f5f5f9;            /* page background */
    --ds-surface-1: #ffffff;         /* cards */
    --ds-surface-2: #f8f8fb;         /* table header, subtle fills */
    --ds-hairline: #d9dee3;          /* borders */
    --ds-hairline-soft: #eceef1;     /* row dividers */
    --ds-card-shadow: 0 2px 6px 0 rgba(67, 89, 113, 0.12);

    /* Status — Sneat label colors */
    --ds-success: #71dd37;
    --ds-success-text: #56ac28;
    --ds-success-soft: #e8fadf;
    --ds-error: #ff3e1d;
    --ds-error-hover: #e6381a;
    --ds-error-soft: #ffe0db;
    --ds-error-border: #ffc5ba;
    --ds-warning: #ffab00;
    --ds-warning-soft: #fff2d6;
    --ds-neutral-soft: #ebeef0;

    /* AI accent — Sneat info (AI features only) */
    --ds-accent: #03c3ec;
    --ds-accent-hover: #03b0d4;
    --ds-accent-soft: #d7f5fc;

    /* Charts */
    --ds-chart-blue: #03c3ec;
    --ds-chart-pink: #ff3e1d;
    --ds-chart-lime: #71dd37;
    --ds-chart-cyan: #696cff;

    /* Typography */
    --ds-font: "Public Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
    --ds-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

    /* Radius */
    --ds-radius-xs: 4px;
    --ds-radius-sm: 6px;
    --ds-radius-md: 8px;             /* buttons, inputs, cards (matches Sneat .card) */
    --ds-radius-lg: 12px;
    --ds-radius-xl: 16px;
    --ds-radius-pill: 9999px;

    /* Spacing (8px base) */
    --ds-space-xxs: 4px;
    --ds-space-xs: 8px;
    --ds-space-sm: 12px;
    --ds-space-md: 16px;
    --ds-space-lg: 24px;
    --ds-space-xl: 32px;
    --ds-space-xxl: 48px;

    /* Tables */
    --ds-row-hover: var(--ds-primary-tint);
    --ds-row-alt: #fafafc;
}

/* ---------- Surfaces ---------- */
.ds-canvas { background: var(--ds-canvas); }

/* Same look as Sneat .card so new and old screens match */
.ds-card {
    background: var(--ds-surface-1);
    border: 0;
    border-radius: var(--ds-radius-md);
    padding: var(--ds-space-lg);
    box-shadow: var(--ds-card-shadow);
    overflow: hidden;
}

/* Info panel / hint — soft theme tint with a primary accent line */
.ds-card-muted {
    background: var(--ds-primary-tint);
    border: 1px solid var(--ds-primary-soft);
    border-left: 3px solid var(--ds-primary);
    border-radius: var(--ds-radius-md);
    padding: var(--ds-space-md) var(--ds-space-lg);
    color: var(--ds-ink-body);
}
.ds-card-muted > .d-flex > .bx:first-child,
.ds-card-muted .ds-hint-icon { color: var(--ds-primary); }

.ds-divider { border-top: 1px solid var(--ds-hairline-soft); }

/* ---------- Type ---------- */
.ds-font { font-family: var(--ds-font); }
.ds-headline { font-size: 26px; font-weight: 500; line-height: 1.25; letter-spacing: -0.4px; color: var(--ds-ink); }
.ds-card-title { font-size: 18px; font-weight: 500; line-height: 1.3; letter-spacing: -0.2px; color: var(--ds-ink); }
.ds-subhead { font-size: 18px; font-weight: 400; line-height: 1.4; color: var(--ds-ink); }
.ds-body { font-size: 15px; line-height: 1.5; color: var(--ds-ink-body); }
.ds-body-sm { font-size: 14px; line-height: 1.5; color: var(--ds-ink-muted); }
.ds-caption { font-size: 12px; line-height: 1.4; color: var(--ds-ink-muted); }
.ds-eyebrow { font-size: 13px; font-weight: 500; line-height: 1.3; color: var(--ds-ink-muted); }
.ds-mono { font-family: var(--ds-font-mono); font-size: 12px; }

/* ---------- Buttons (radius 8px, never pill) ---------- */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ds-space-xs);
    min-height: 40px;
    padding: 9px 18px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    border-radius: var(--ds-radius-md);
    border: 1px solid transparent;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
    text-decoration: none;
    cursor: pointer;
}
.ds-btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }

/* Primary = theme purple, like the sidebar active item and Sneat buttons */
.ds-btn-primary { background: var(--ds-primary); color: var(--ds-on-primary); box-shadow: var(--ds-primary-shadow); }
.ds-btn-primary:hover,
.ds-btn-primary:focus { background: var(--ds-primary-hover); color: var(--ds-on-primary); }

.ds-btn-secondary { background: var(--ds-surface-1); color: var(--ds-primary); border-color: var(--ds-primary); }
.ds-btn-secondary:hover,
.ds-btn-secondary:focus { background: var(--ds-primary-soft); color: var(--ds-primary); }

.ds-btn-tertiary { background: transparent; color: var(--ds-ink-body); }
.ds-btn-tertiary:hover,
.ds-btn-tertiary:focus { background: var(--ds-primary-tint); color: var(--ds-primary); }

.ds-btn-ai { background: var(--ds-accent); color: var(--ds-on-primary); }
.ds-btn-ai:hover,
.ds-btn-ai:focus { background: var(--ds-accent-hover); color: var(--ds-on-primary); }

.ds-btn-danger { background: var(--ds-surface-1); color: var(--ds-error); border-color: var(--ds-error); }
.ds-btn-danger:hover,
.ds-btn-danger:focus { background: var(--ds-error-soft); color: var(--ds-error); }

.ds-btn:disabled,
.ds-btn.disabled { opacity: .5; pointer-events: none; box-shadow: none; }

/* ---------- Icon buttons (table row actions) ---------- */
.ds-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-xs);
}

.ds-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: var(--ds-ink-muted);
    background: var(--ds-surface-1);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius-md);
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
    text-decoration: none;
    cursor: pointer;
}
.ds-icon-btn:hover,
.ds-icon-btn:focus {
    color: var(--ds-primary);
    background: var(--ds-primary-soft);
    border-color: var(--ds-primary-soft);
}
.ds-icon-btn:focus-visible { outline: 2px solid var(--ds-primary); outline-offset: 1px; }

.ds-icon-btn-danger { color: var(--ds-error); }
.ds-icon-btn-danger:hover,
.ds-icon-btn-danger:focus { color: var(--ds-error); background: var(--ds-error-soft); border-color: var(--ds-error-soft); }

/* ---------- Inputs ---------- */
.ds-input {
    min-height: 42px;
    padding: 9px 14px;
    font-size: 15px;
    color: var(--ds-ink-body);
    background: var(--ds-surface-1);
    border: 1px solid var(--ds-hairline);
    border-radius: var(--ds-radius-md);
    box-shadow: none;
}
.ds-input:focus { border-color: var(--ds-primary); outline: none; box-shadow: 0 0 0.25rem 0.05rem rgba(105, 108, 255, 0.1); }
.ds-input[readonly] { background: var(--ds-surface-2); color: var(--ds-ink-muted); }

/* ---------- Badges / status (Sneat "label" style) ---------- */
.ds-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-xxs);
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--ds-radius-xs);
    background: var(--ds-neutral-soft);
    color: var(--ds-ink-muted);
}
.ds-badge-primary { background: var(--ds-primary-soft); color: var(--ds-primary); }
.ds-badge-success { background: var(--ds-success-soft); color: var(--ds-success-text); }
.ds-badge-warning { background: var(--ds-warning-soft); color: var(--ds-warning); }
.ds-badge-error { background: var(--ds-error-soft); color: var(--ds-error); }
.ds-badge-ai { background: var(--ds-accent-soft); color: var(--ds-accent-hover); }

/* ---------- Step number (lists of actions) ---------- */
.ds-step {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

/* =====================================================================
 * Tables (global) — applies to every .table in the admin panel.
 * Desktop: calm sentence-case header, hairline rows, soft purple hover.
 * When a table does not fit its container (any screen size), each row becomes
 * a vertical "label · value" block.
 * Labels come from <thead> and are added by assets/admin/js/responsive-table.js.
 * Opt out on a table with class .table-no-stack.
 * ===================================================================== */
.table > :not(caption) > * > * {
    padding: var(--ds-space-sm) var(--ds-space-md);
    border-bottom-color: var(--ds-hairline-soft);
    vertical-align: middle;
}

.table thead th,
.table:not(.table-dark) th {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ds-ink);
}

.table thead th {
    background: var(--ds-surface-2);
    border-bottom: 1px solid var(--ds-hairline-soft);
}

.table tbody td { color: var(--ds-ink-body); }
.table tbody tr { transition: background-color .15s ease; }
.table-hover > tbody > tr:hover > *,
.table tbody tr:hover > * { --bs-table-accent-bg: var(--ds-row-hover); background-color: var(--ds-row-hover); }

/* Stacked mode: added by responsive-table.js whenever a table does not fit its container. */
.ds-table-wrap-stacked { overflow-x: visible !important; }

.ds-table-stack.is-stacked {
    border: 1px solid var(--ds-hairline-soft);
    border-radius: var(--ds-radius-md);
    overflow: hidden;
    background: var(--ds-surface-1);
}

.ds-table-stack.is-stacked thead { display: none; }

.ds-table-stack.is-stacked,
.ds-table-stack.is-stacked tbody,
.ds-table-stack.is-stacked tr,
.ds-table-stack.is-stacked td {
    display: block;
    width: 100%;
}

.ds-table-stack.is-stacked tbody tr { border-bottom: 1px solid var(--ds-hairline); }
.ds-table-stack.is-stacked tbody tr:last-child { border-bottom: 0; }
.ds-table-stack.is-stacked tbody tr:nth-child(even) > td { background: var(--ds-row-alt); }
.ds-table-stack.is-stacked tbody tr:hover > * { background-color: inherit; }

.ds-table-stack.is-stacked.table > :not(caption) > * > *,
.ds-table-stack.is-stacked td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-md);
    min-height: 44px;
    padding: var(--ds-space-sm);
    text-align: right !important;
    white-space: normal;
    word-break: break-word;
    border-bottom: 1px solid var(--ds-hairline-soft);
}

.ds-table-stack.is-stacked td:last-child { border-bottom: 0; }

.ds-table-stack.is-stacked td::before {
    content: attr(data-label);
    flex-shrink: 0;
    max-width: 45%;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    color: var(--ds-ink);
}

.ds-table-stack.is-stacked td:not([data-label])::before,
.ds-table-stack.is-stacked td[data-label=""]::before { content: none; }
.ds-table-stack.is-stacked td:not([data-label]),
.ds-table-stack.is-stacked td[data-label=""] { justify-content: flex-end; }

/* Empty-state / full-width rows */
.ds-table-stack.is-stacked td[colspan] { justify-content: center; text-align: center !important; }
.ds-table-stack.is-stacked td[colspan]::before { content: none; }

/* ---------- Confirmation modal (components/confirmation-modal.blade.php) ---------- */
.ds-confirm-modal .modal-dialog { max-width: 420px; }

.ds-confirm-modal .modal-content {
    position: relative;
    border: 0;
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-card-shadow);
    overflow: hidden;
}

.ds-confirm-close {
    position: absolute;
    top: var(--ds-space-sm);
    right: var(--ds-space-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    color: var(--ds-ink-muted);
    background: transparent;
    border: 0;
    border-radius: var(--ds-radius-md);
    transition: background-color .15s ease, color .15s ease;
}
.ds-confirm-close:hover,
.ds-confirm-close:focus { color: var(--ds-ink); background: var(--ds-surface-2); }

.ds-confirm-body {
    padding: var(--ds-space-xl) var(--ds-space-lg) var(--ds-space-md);
    text-align: center;
}

.ds-confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin-bottom: var(--ds-space-md);
    font-size: 30px;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-error-soft);
    color: var(--ds-error);
}

.ds-confirm-title {
    margin-bottom: var(--ds-space-xs);
    font-size: 20px;
    font-weight: 500;
    color: var(--ds-ink);
}

.ds-confirm-question {
    margin-bottom: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ds-ink-body);
    word-break: break-word;
}

.ds-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ds-space-sm);
    padding: var(--ds-space-md) var(--ds-space-lg) var(--ds-space-lg);
}
.ds-confirm-actions .ds-btn { width: 100%; }

/* Neutral secondary (Cancel) and the confirm button, which follows the modal type */
.ds-btn-secondary-neutral { background: var(--ds-surface-1); color: var(--ds-ink-body); border-color: var(--ds-hairline); }
.ds-btn-secondary-neutral:hover,
.ds-btn-secondary-neutral:focus { background: var(--ds-surface-2); color: var(--ds-ink); }

.ds-confirm-modal.is-danger .ds-btn-confirm { background: var(--ds-error); color: var(--ds-on-primary); }
.ds-confirm-modal.is-danger .ds-btn-confirm:hover,
.ds-confirm-modal.is-danger .ds-btn-confirm:focus { background: var(--ds-error-hover); color: var(--ds-on-primary); }

.ds-confirm-modal.is-primary .ds-confirm-icon { background: var(--ds-primary-soft); color: var(--ds-primary); }
.ds-confirm-modal.is-primary .ds-btn-confirm { background: var(--ds-primary); color: var(--ds-on-primary); box-shadow: var(--ds-primary-shadow); }
.ds-confirm-modal.is-primary .ds-btn-confirm:hover,
.ds-confirm-modal.is-primary .ds-btn-confirm:focus { background: var(--ds-primary-hover); color: var(--ds-on-primary); }

@media (max-width: 479.98px) {
    .ds-confirm-actions { grid-template-columns: 1fr; }
    .ds-confirm-actions .ds-btn-confirm { order: -1; }
}

/* ---------- Page tabs (underline, no pills) ---------- */
.ds-tabs {
    display: flex;
    gap: var(--ds-space-lg);
    border-bottom: 1px solid var(--ds-hairline);
    margin-bottom: var(--ds-space-lg);
    overflow-x: auto;
}
.ds-tab {
    padding: var(--ds-space-sm) 0;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: var(--ds-ink-muted);
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
}
.ds-tab:hover { color: var(--ds-ink); }
.ds-tab.active { color: var(--ds-primary); border-bottom-color: var(--ds-primary); }

/* ---------- Stat tile ---------- */
.ds-stat-value { font-size: 26px; font-weight: 500; line-height: 1.2; color: var(--ds-ink); }
.ds-stat-label { font-size: 14px; color: var(--ds-ink-muted); }

/* ---------- Learning proposal ---------- */
.ds-proposal-content {
    background: var(--ds-surface-2);
    border: 1px solid var(--ds-hairline-soft);
    border-radius: var(--ds-radius-md);
    padding: var(--ds-space-sm) var(--ds-space-md);
    color: var(--ds-ink-body);
    white-space: pre-line;
}
.ds-quote {
    border-left: 3px solid var(--ds-hairline);
    padding-left: var(--ds-space-sm);
    color: var(--ds-ink-body);
}

/* ---------- Status dot (top bar cron icon) ---------- */
.ds-status-dot {
    position: absolute;
    top: 8px;
    right: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--ds-surface-1);
    background: var(--ds-warning);
}
.ds-status-dot-running { background: var(--ds-success); }
.ds-status-dot-stopped { background: var(--ds-error); }
.ds-status-dot-never { background: var(--ds-warning); }
.ds-details > summary { cursor: pointer; color: var(--ds-ink); }
