/*
 * Merdigit AI — reusable components: buttons, cards, badges, form controls, tables, alerts, dropdowns, empty/loading
 * states. Loaded after design-system.css (see components/global-styles.blade.php); every rule here only uses the
 * tokens defined there. See design-system.css's own header comment for why this is a static file, not a Vite bundle.
 */

/* ── Alert banners ──────────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px;
    display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px;
    border: 1px solid;
}
.alert-error   { background: rgba(244,70,71,0.08);  border-color: rgba(244,70,71,0.22);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.07);  border-color: rgba(34,197,94,0.18); color: #86efac; }
.alert-warning { background: rgba(251,176,59,0.09); border-color: rgba(251,176,59,0.25); color: #fcd34d; }
.alert-info    { background: rgba(255,255,255,0.04); border-color: var(--border-md); color: var(--text-2); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title  { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.card-link   { font-size: 12px; color: var(--accent); text-decoration: none; }
.card-link:hover { color: #e879f9; }
.card-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-body   { padding: 20px; }

.stat-card {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.stat-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-3); margin-bottom: 8px;
}
.stat-value  { font-size: 26px; font-weight: 700; color: var(--text-1); line-height: 1; }
.stat-sub    { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
/* Semantic colour only - active/inactive/pending state elsewhere in the app is never carried by a badge's colour
   alone (x-cs-state also prefixes a glyph); a badge's text label is always the primary signal. */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: rgba(34,197,94,0.1);  color: var(--state-success); border: 1px solid rgba(34,197,94,0.2); }
.badge-red    { background: rgba(244,70,71,0.1);  color: var(--state-danger); border: 1px solid rgba(244,70,71,0.25); }
.badge-amber  { background: rgba(251,176,59,0.12); color: var(--state-warning); border: 1px solid rgba(251,176,59,0.28); }
.badge-indigo { background: rgba(208,46,244,0.1); color: #e879f9; border: 1px solid rgba(208,46,244,0.25); }
.badge-gray   { background: rgba(255,255,255,0.05); color: var(--text-2); border: 1px solid var(--border); }
/* Neutral/waiting state (e.g. a "pending" job) - not part of the Merdigit brand palette, so this stays gray rather than blue. */
.badge-blue   { background: rgba(255,255,255,0.05); color: var(--text-2); border: 1px solid var(--border); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; text-decoration: none; white-space: nowrap; transition: all var(--transition-fast);
    line-height: 1.4;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-secondary {
    background: rgba(255,255,255,0.05); color: var(--text-1);
    border-color: var(--border-md);
}
.btn-secondary:hover { background: rgba(255,255,255,0.09); }
.btn-danger {
    background: rgba(244,70,71,0.12); color: var(--state-danger);
    border-color: rgba(244,70,71,0.28);
}
.btn-danger:hover { background: rgba(244,70,71,0.2); }
.btn-ghost { background: none; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-1); }
.btn-success {
    background: rgba(34,197,94,0.12); color: var(--state-success);
    border-color: rgba(34,197,94,0.25);
}
.btn-success:hover { background: rgba(34,197,94,0.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: var(--radius-xs); }

/* ── Form fields ────────────────────────────────────────────────────────── */
.form-label {
    display: block; font-size: 12px; font-weight: 500;
    color: var(--text-2); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 12px; background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-md); border-radius: var(--radius-sm);
    color: var(--text-1); font-size: 13.5px; font-family: inherit;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-select { appearance: none; cursor: pointer; }
/*
 * The rule above only styles the CLOSED select box; the popup option list is rendered by the OS/browser using its own
 * defaults unless a background-color is set directly on <select>/<option>. On Windows/Chrome that default is a white
 * popup, while `color: var(--text-1)` above (a light color, for this platform's permanently-dark theme) still applies
 * to the option text - producing an unreadable white-on-near-white list on every <select> platform-wide. Setting an
 * opaque background explicitly on both fixes the popup for every existing .form-select without changing the
 * closed-box look.
 */
.form-select, .form-select option {
    background-color: var(--bg-elevated);
    color: var(--text-1);
}
.form-select option:checked, .form-select option:hover {
    background-color: var(--bg-hover);
}
.form-checkbox {
    width: 15px; height: 15px; border-radius: 4px; cursor: pointer;
    accent-color: var(--accent); background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-md);
}
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.data-table thead tr { background: rgba(255,255,255,0.025); }
.data-table th {
    padding: 10px 16px; text-align: left;
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-3); white-space: nowrap;
}
.data-table td { padding: 11px 16px; border-top: 1px solid var(--border); vertical-align: middle; color: var(--text-1); }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ── Dropdown ───────────────────────────────────────────────────────────── */
/* No dropdown menu existed anywhere in the app before this phase (audited: none found) - this is defined now only
   because PART 7 asks the component set to be normalized, and left unused until a page needs one, so it reuses the
   same surface/border/shadow/spacing language as .card rather than introducing a one-off look when it is needed. */
.dropdown-menu {
    background: var(--bg-elevated); border: 1px solid var(--border-md);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    padding: 6px; min-width: 180px;
}
.dropdown-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border-radius: var(--radius-sm); border: 0; background: none;
    font-size: 13px; color: var(--text-2); text-decoration: none; text-align: left; cursor: pointer;
    font-family: inherit; transition: background var(--transition-fast), color var(--transition-fast);
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--bg-hover); color: var(--text-1); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }

/* ── Progress bar ───────────────────────────────────────────────────────── */
.progress-bar { height: 5px; background: rgba(255,255,255,0.07); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width 0.3s; }

/* ── Toggle switch ──────────────────────────────────────────────────────── */
.toggle {
    width: 38px; height: 22px; border-radius: 99px; border: none; cursor: pointer;
    position: relative; transition: background 0.2s; flex-shrink: 0;
    display: inline-block;
}
.toggle.on  { background: var(--state-success); }
.toggle.off { background: rgba(255,255,255,0.1); }
.toggle::after {
    content: ''; position: absolute; top: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: white; transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle.on::after  { left: 19px; }
.toggle.off::after { left: 3px; }

/* ── Code / mono ────────────────────────────────────────────────────────── */
.code-block {
    background: rgba(0,0,0,0.35); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px; overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    font-size: 12px; line-height: 1.6; color: #cbd5e1;
    white-space: pre;
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 0; }

/* ── Empty / loading state ──────────────────────────────────────────────── */
.empty-state {
    padding: 48px 24px; text-align: center;
    color: var(--text-3); font-size: 13.5px;
}
.empty-state svg { width: 36px; height: 36px; margin: 0 auto 12px; opacity: 0.3; }
