/* Copied verbatim from Apps/pa-toolbox/shared/design/ui.css (shared design system). Edit there, then re-copy. */
/* ==========================================================================
   UI — Prisma Access Toolbox component classes.
   Vanilla-CSS translation of the design-system components (Button, Card,
   Badge, Input, ToolTile, AppShell top bar). Reads only semantic tokens
   from tokens.css so light/dark theming works automatically.
   ========================================================================== */

* { box-sizing: border-box; }

/* Native controls (selects, scrollbars) follow the active theme. */
:root { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-body);
  color: var(--text-body);
  background: var(--bg-app);
}

a { color: var(--text-link); }

/* --- App shell / top bar ------------------------------------------------ */

.pat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 28px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pat-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pat-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pat-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.pat-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--amber-400);
  color: var(--slate-900);
  font-weight: var(--fw-bold);
  font-size: 16px;
}

.pat-logo-word {
  font-size: 16px;
  font-weight: var(--fw-bold);
  color: var(--text-heading);
  letter-spacing: var(--ls-tight);
}

.pat-crumb-sep { color: var(--text-faint); }

.pat-crumb {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--text-body);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background var(--dur) var(--ease);
}

.theme-toggle:hover { background: var(--surface-hover); }

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 9px 16px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--text-on-primary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.btn:hover { background: var(--primary-hover); }
.btn:active { background: var(--primary-press); }

.btn:disabled {
  background: var(--primary-soft);
  color: var(--text-faint);
  cursor: not-allowed;
}

.btn-outline {
  background: var(--surface-card);
  color: var(--text-body);
  border-color: var(--border-strong);
}

.btn-outline:hover, .btn-outline:active { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-body);
}

.btn-ghost:hover, .btn-ghost:active { background: var(--surface-hover); }

.btn-danger { background: var(--block); color: var(--white); }
.btn-danger:hover, .btn-danger:active { background: #b91c1c; }

.btn-sm { height: 32px; padding: 6px 12px; font-size: var(--text-sm); }
.btn-lg { height: 44px; padding: 12px 20px; font-size: var(--text-md); }
.btn-block { width: 100%; }

/* --- Card ---------------------------------------------------------------- */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
}

.card-body { padding: var(--pad-card); }

/* --- Badge ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.4;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  background: var(--amber-400);
  color: var(--slate-900);
}

.badge-soft { background: var(--amber-100); color: var(--amber-700); }
.badge-allow { background: var(--allow); color: var(--white); }
.badge-allow.badge-soft { background: var(--allow-bg); color: var(--allow); }
.badge-block { background: var(--block); color: var(--white); }
.badge-block.badge-soft { background: var(--block-bg); color: var(--block); }
.badge-prompt { background: var(--prompt); color: var(--white); }
.badge-prompt.badge-soft { background: var(--prompt-bg); color: var(--prompt); }
.badge-info { background: var(--info); color: var(--white); }
.badge-info.badge-soft { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--slate-600); color: var(--white); }
.badge-neutral.badge-soft { background: var(--surface-sunken); color: var(--text-muted); }

/* --- Forms ---------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
}

.input {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-body);
  padding: var(--pad-input);
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  outline: none;
  width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.input:disabled {
  background: var(--surface-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

.input.mono { font-family: var(--font-mono); font-size: var(--text-sm); }

select.input { appearance: auto; }

.helper {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
}

/* --- Section label (12px uppercase) --------------------------------------- */

.section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  color: var(--text-muted);
}

/* --- Tool tile (landing grid) ---------------------------------------------- */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.tool-tile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--pad-tile);
  text-decoration: none;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--dur) var(--ease);
}

.tool-tile:hover {
  border-color: var(--amber-400);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--amber-tint-2);
  color: var(--primary-text);
  border: 1px solid var(--primary-soft);
}

.tool-tile-title {
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
}

.tool-tile-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--lh-snug);
  margin-top: 5px;
}

/* --- Progress bar ------------------------------------------------------------ */

.progress {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 300ms var(--ease);
}

.progress-fill.is-success { background: var(--allow); }
.progress-fill.is-error { background: var(--block); }

/* --- Drop zone ------------------------------------------------------------ */

.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--surface-card);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.drop-zone:hover, .drop-zone.is-dragover {
  border-color: var(--amber-400);
  background: var(--amber-tint);
}

/* --- Console / log panes ------------------------------------------------------ */

.console-pane {
  background: var(--slate-900);
  border: 1px solid var(--slate-700);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--slate-300);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .console-pane {
  background: var(--surface-sunken);
  border-color: var(--border);
}

.log-line {
  border-left: 2px solid var(--slate-600);
  padding: 0 0 4px 8px;
  margin-bottom: 4px;
  color: var(--slate-300);
}

.log-line.is-error { border-color: #f87171; color: #f87171; }
.log-line.is-success { border-color: #4ade80; color: #4ade80; }
.log-time { opacity: 0.5; margin-right: 8px; }

/* --- Toggle pill (filter switches) --------------------------------------------- */

.toggle-pill {
  position: relative;
  width: 32px;
  height: 16px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: background var(--dur) var(--ease);
  flex-shrink: 0;
}

.toggle-pill::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-xs);
  transition: all var(--dur) var(--ease);
}

.toggle-pill.is-off { background: var(--border-strong); }
.toggle-pill.is-off::after { right: 18px; }

/* --- Tables ---------------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 10px 24px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--ls-label);
  color: var(--text-muted);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  padding: 10px 24px;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
}

.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }

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

.mono-chip {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-heading);
  background: var(--surface-sunken);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* --- Leaflet popups restyled to match cards ------------------------------------------ */

.leaflet-popup-content-wrapper {
  background: var(--surface-card);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
}

.leaflet-popup-tip { background: var(--surface-card); }

/* --- Utilities ------------------------------------------------------------------------ */

.hidden { display: none !important; }
