/*
 * Panel component layer — plain CSS, loaded AFTER app.css.
 *
 * Why this file exists: app.css is ToshostCloud's compiled Tailwind bundle,
 * copied here. It was purged against ToshostCloud's OWN templates, so any
 * utility class this panel needs but that panel never used simply does not
 * exist in it — and a missing utility class fails silently, with no error
 * anywhere, just a component that renders wrong. That has already cost this
 * project several debugging sessions (`w-4.5`, `bg-slate-950`, `text-white/80`,
 * `grid-cols-6`, `cursor-not-allowed`, `max-w-4xl` are all absent).
 *
 * Rather than keep checking each class against the bundle, everything new is
 * written as an explicit component class here. app.css still provides the
 * layout utilities already proven present in the existing views.
 *
 * Note the `.card` interaction: app.css's `.card` rule sets a plain white
 * background at the same specificity as a Tailwind gradient utility, and it
 * is defined later, so gradient utilities on a `.card` lose. Gradients are
 * therefore set with inline `style="background:linear-gradient(...)"`.
 */

:root {
  --p-bg: #f1f5f9;
  --p-line: #e2e8f0;
  --p-ink: #0f172a;
  --p-muted: #64748b;
  --p-faint: #94a3b8;
  --p-brand: #2563eb;
  --p-brand-dark: #1d4ed8;
  --p-ok: #059669;
  --p-warn: #b45309;
  --p-bad: #dc2626;
  --p-radius: 12px;
}

/* ── status pills ───────────────────────────────────────────────────────── */
.p-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  padding: .3rem .55rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.p-pill::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.p-pill--plain::before { display: none; }
.p-pill--ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.p-pill--off { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.p-pill--warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.p-pill--bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.p-pill--info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.p-pill--violet { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }

/* ── notices ────────────────────────────────────────────────────────────── */
.p-notice {
  display: flex; gap: .6rem; align-items: flex-start;
  font-size: 13.5px; line-height: 1.5;
  padding: .7rem .85rem; border-radius: 10px; border: 1px solid; margin-bottom: 1rem;
}
.p-notice--ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.p-notice--warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.p-notice--bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.p-notice--info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.p-notice strong { font-weight: 600; }

/* ── buttons ────────────────────────────────────────────────────────────── */
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-size: 13px; font-weight: 500; line-height: 1;
  padding: .5rem .8rem; border-radius: 9px; border: 1px solid var(--p-line);
  background: #fff; color: #334155; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.p-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.p-btn--primary { background: var(--p-brand); border-color: var(--p-brand); color: #fff; }
.p-btn--primary:hover { background: var(--p-brand-dark); border-color: var(--p-brand-dark); }
.p-btn--danger { background: var(--p-bad); border-color: var(--p-bad); color: #fff; }
.p-btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }
.p-btn--ghost-danger { color: #b91c1c; border-color: #fecaca; }
.p-btn--ghost-danger:hover { background: #fef2f2; }
.p-btn--ok { color: #047857; border-color: #a7f3d0; }
.p-btn--ok:hover { background: #ecfdf5; }
.p-btn--sm { font-size: 12px; padding: .35rem .6rem; }
.p-btn[disabled], .p-btn--disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── forms ──────────────────────────────────────────────────────────────── */
.p-field { display: block; margin-bottom: .85rem; }
.p-label { display: block; font-size: 11.5px; font-weight: 500; color: var(--p-muted); margin-bottom: .3rem; }
.p-hint { font-size: 11.5px; color: var(--p-faint); margin-top: .3rem; line-height: 1.5; }
.p-input, .p-select, .p-textarea {
  width: 100%; font-size: 13.5px; color: var(--p-ink);
  padding: .5rem .65rem; border: 1px solid #cbd5e1; border-radius: 9px; background: #fff;
  font-family: inherit;
}
.p-input:focus, .p-select:focus, .p-textarea:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.p-input--mono, .p-textarea--mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.p-textarea { min-height: 5rem; resize: vertical; }
.p-input[readonly] { background: #f8fafc; color: var(--p-muted); }
.p-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.p-checkbox { display: inline-flex; align-items: center; gap: .45rem; font-size: 13px; color: #334155; }

/* ── tables ─────────────────────────────────────────────────────────────── */
.p-table-wrap { overflow-x: auto; }
.p-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.p-table th {
  text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--p-faint);
  padding: .5rem .6rem; border-bottom: 1px solid var(--p-line); white-space: nowrap;
}
.p-table td { padding: .6rem; border-bottom: 1px solid #f1f5f9; color: #334155; vertical-align: middle; }
.p-table tr:last-child td { border-bottom: 0; }
.p-table tbody tr:hover { background: #f8fafc; }
.p-table .p-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.p-table--tight td, .p-table--tight th { padding: .4rem .5rem; }

/* ── section headings inside cards ──────────────────────────────────────── */
.p-section-title { font-size: 13.5px; font-weight: 600; color: #334155; }
.p-section-sub { font-size: 12px; color: var(--p-faint); margin-top: .15rem; line-height: 1.5; }
.p-section-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.p-divider { border: 0; border-top: 1px solid #f1f5f9; margin: 1.1rem 0; }

/* ── key/value list ─────────────────────────────────────────────────────── */
.p-kv { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.p-kv dt { font-size: 11.5px; color: var(--p-faint); margin-bottom: .15rem; }
.p-kv dd { font-size: 13.5px; font-weight: 500; color: #334155; margin: 0; word-break: break-word; }

/* ── metric graphs ──────────────────────────────────────────────────────── */
.p-graph { width: 100%; height: 60px; display: block; overflow: visible; }
.p-graph-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .25rem; }
.p-graph-label { font-size: 11.5px; color: var(--p-faint); }
.p-graph-value { font-size: 14px; font-weight: 600; color: #334155; font-variant-numeric: tabular-nums; }
.p-graph-empty { font-size: 11.5px; color: var(--p-faint); font-style: italic; }

/* ── bars ───────────────────────────────────────────────────────────────── */
.p-bar { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.p-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--p-brand); }
.p-bar--ok > i { background: var(--p-ok); }
.p-bar--warn > i { background: #f59e0b; }
.p-bar--bad > i { background: var(--p-bad); }

/* ── tabs ───────────────────────────────────────────────────────────────── */
.p-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--p-line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.p-tab {
  font-size: 13px; font-weight: 500; color: var(--p-muted); text-decoration: none;
  padding: .5rem .75rem; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
  background: none; border-left: 0; border-right: 0; border-top: 0;
}
.p-tab:hover { color: #334155; }
.p-tab.is-active { color: var(--p-brand); border-bottom-color: var(--p-brand); }
.p-tabpanel[hidden] { display: none; }

/* ── code / log output ──────────────────────────────────────────────────── */
.p-log {
  background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: .8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.6; max-height: 24rem; overflow: auto;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}
.p-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; background: #f1f5f9; border: 1px solid var(--p-line);
  border-radius: 6px; padding: .1rem .35rem; color: #334155;
}

/* ── misc ───────────────────────────────────────────────────────────────── */
.p-muted { color: var(--p-muted); font-size: 13px; }
.p-faint { color: var(--p-faint); font-size: 12px; }
.p-empty { text-align: center; padding: 2.5rem 1rem; color: var(--p-muted); font-size: 13.5px; }
.p-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.p-row--end { justify-content: flex-end; }
.p-spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.p-stack > * + * { margin-top: .85rem; }
.p-inline-form { display: inline; }
.p-breadcrumb { font-size: 12.5px; color: var(--p-muted); }
.p-breadcrumb a { color: var(--p-brand); text-decoration: none; }
.p-breadcrumb a:hover { text-decoration: underline; }

/* Danger zone: visually separated so a destructive control is never one
   mis-aimed click away from a routine one. */
.p-danger-zone { border: 1px solid #fecaca; background: #fff5f5; border-radius: var(--p-radius); padding: 1rem; }
.p-danger-zone .p-section-title { color: #991b1b; }

/* A capability the current role lacks: shown, but visibly inert, so the UI
   stays honest about what exists rather than hiding half the product. */
.p-locked { opacity: .55; }
.p-locked * { pointer-events: none; }

@media (max-width: 640px) {
  .p-kv, .p-grid { grid-template-columns: 1fr 1fr; }
  .p-section-head { flex-direction: column; align-items: stretch; }
}
