@tailwind base;
@tailwind components;
@tailwind utilities;

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ─── Design tokens (from Tinker style guide) ─────────────────────────────── */
:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

:root, [data-theme="dark"] {
  --bg: #0b0f14;
  --panel: #0f141b;
  --panel-raise: #151b23;
  --fg: #e6e9ee;
  --muted: rgba(230,233,238,0.55);
  --muted2: rgba(230,233,238,0.4);
  --line: rgba(255,255,255,0.07);
  --line-strong: rgba(255,255,255,0.14);
  --chip-bg: rgba(255,255,255,0.035);
  --row-hover: rgba(255,255,255,0.025);
  --input-bg: rgba(0,0,0,0.25);
  --seg-active-bg: rgba(255,255,255,0.08);
  --nav-bg: #060a0f;
  --nav-line: rgba(255,255,255,0.05);
  --nav-fg: rgba(230,233,238,0.72);
  --nav-muted: rgba(230,233,238,0.4);
  --nav-active-bg: rgba(255,255,255,0.05);
  --nav-active-fg: #f5f7fa;
  --nav-hover-bg: rgba(255,255,255,0.03);
  --nav-badge-bg: rgba(255,255,255,0.08);
  --accent: oklch(74% 0.14 65);
  --accent-fg: #1a0f04;
  --ok: oklch(74% 0.12 155);
  --danger: oklch(68% 0.17 25);
  --danger-line: color-mix(in oklch, var(--danger) 45%, transparent);
}

[data-theme="light"] {
  --bg: #f5f4ef;
  --panel: #fbfaf6;
  --panel-raise: #ffffff;
  --fg: #1a1814;
  --muted: rgba(26,24,20,0.58);
  --muted2: rgba(26,24,20,0.4);
  --line: rgba(26,24,20,0.08);
  --line-strong: rgba(26,24,20,0.16);
  --chip-bg: rgba(26,24,20,0.035);
  --row-hover: rgba(26,24,20,0.025);
  --input-bg: #ffffff;
  --seg-active-bg: #ffffff;
  --nav-bg: #14110c;
  --nav-line: rgba(255,255,255,0.08);
  --nav-fg: rgba(245,241,232,0.72);
  --nav-muted: rgba(245,241,232,0.4);
  --nav-active-bg: rgba(255,255,255,0.08);
  --nav-active-fg: #faf7ef;
  --nav-hover-bg: rgba(255,255,255,0.04);
  --nav-badge-bg: rgba(255,255,255,0.12);
  --accent: oklch(62% 0.14 50);
  --accent-fg: #fff8f1;
  --ok: oklch(58% 0.11 155);
  --danger: oklch(55% 0.18 25);
  --danger-line: color-mix(in oklch, var(--danger) 35%, transparent);
}

/* ─── Base ────────────────────────────────────────────────────────────────── */
body {
  @apply flex w-full h-full;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1 { @apply text-3xl font-semibold; letter-spacing: -0.02em; }
h2 { @apply text-2xl font-semibold; letter-spacing: -0.015em; }
h3 { @apply text-xl font-semibold; letter-spacing: -0.01em; }
h4 { @apply text-lg font-semibold; }
h5 { @apply text-base font-semibold; }
h6 { @apply text-sm font-semibold; }

.container {
  @apply flex flex-col flex-1 mx-auto max-w-4xl px-4 py-8;
}

.field {
  @apply flex flex-col my-2;
}

label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-block;
  line-height: 1.4;
}

input[type="email"], input[type="text"], input[type="password"], input[type="search"],
input[type="tel"], input[type="url"], input[type="number"], input[type="date"],
input[type="time"], input[type="datetime-local"], input[type="month"],
input[type="week"], input[type="color"], input[type="file"], select, textarea {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  line-height: 1.4;
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  transition: border-color .15s;
}
textarea { height: auto; padding: 10px 12px; min-height: 72px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 20%, transparent); }
input::placeholder, textarea::placeholder {
  color: var(--muted2);
  opacity: 0.7;
  font-weight: 400;
}

input[type="checkbox"] {
  width: 16px; height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--input-bg);
}

/* ─── Flash ───────────────────────────────────────────────────────────────── */
.notice, .alert {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel-raise);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.08);
  animation: fadeOut 0.5s ease-in-out 6s forwards;
}
.notice { border-left: 3px solid var(--ok); }
.alert  { border-left: 3px solid var(--danger); }

/* ─── Buttons (legacy names preserved, retokenized) ───────────────────────── */
.button-base, .button-primary, .button-secondary, .button-secondary-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: 7px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: opacity .15s, background .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.button-base:focus-visible, .button-primary:focus-visible, .button-secondary:focus-visible, .button-secondary-danger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-primary, a.button-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.button-primary:hover { opacity: 0.9; }

.button-secondary, a.button-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--line-strong);
}
.button-secondary:hover { background: var(--chip-bg); }
.button-secondary.disabled { opacity: 0.4; cursor: not-allowed; }

.button-secondary-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-line);
}
.button-secondary-danger:hover { background: color-mix(in oklch, var(--danger) 10%, transparent); }

/* Small variants */
.button-base-sm, .button-primary-sm, .button-secondary-sm, .button-secondary-danger-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: opacity .15s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.button-primary-sm, a.button-primary-sm { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.button-secondary-sm, a.button-secondary-sm { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.button-secondary-danger-sm { background: transparent; color: var(--danger); border-color: var(--danger-line); }

/* ─── Status pills ────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--fg);
}
.pill .dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.pill.in-service   { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); background: color-mix(in oklch, var(--ok) 10%, transparent); }
.pill.checked-out  { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 38%, transparent); background: color-mix(in oklch, var(--accent) 10%, transparent); }
.pill.needs-service{ color: var(--danger); border-color: var(--danger-line); background: color-mix(in oklch, var(--danger) 10%, transparent); }
.pill.storage      { color: var(--muted); }
.pill.sm           { height: 18px; padding: 0 6px; font-size: 10px; }

/* Legacy pill-primary mapping */
.pill-primary             { @apply pill; }
.pill-primary.red         { color: var(--danger); border-color: var(--danger-line); background: color-mix(in oklch, var(--danger) 10%, transparent); }
.pill-primary.yellow      { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 38%, transparent); background: color-mix(in oklch, var(--accent) 10%, transparent); }
.pill-primary.green       { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); background: color-mix(in oklch, var(--ok) 10%, transparent); }
.pill-primary.blue        { color: oklch(68% 0.12 230); border-color: color-mix(in oklch, oklch(68% 0.12 230) 35%, transparent); background: color-mix(in oklch, oklch(68% 0.12 230) 10%, transparent); }

/* ─── Badges (legacy) ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--fg);
}
.badge-primary            { @apply badge; }
.badge-primary.red        { color: var(--danger); border-color: var(--danger-line); background: color-mix(in oklch, var(--danger) 10%, transparent); }
.badge-primary.yellow     { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 38%, transparent); background: color-mix(in oklch, var(--accent) 10%, transparent); }
.badge-primary.green      { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); background: color-mix(in oklch, var(--ok) 10%, transparent); }
.badge-primary.blue       { color: oklch(68% 0.12 230); border-color: color-mix(in oklch, oklch(68% 0.12 230) 35%, transparent); background: color-mix(in oklch, oklch(68% 0.12 230) 10%, transparent); }
.badge-primary.indigo     { color: oklch(62% 0.15 270); border-color: color-mix(in oklch, oklch(62% 0.15 270) 35%, transparent); background: color-mix(in oklch, oklch(62% 0.15 270) 10%, transparent); }
.badge-primary.purple     { color: oklch(62% 0.15 310); border-color: color-mix(in oklch, oklch(62% 0.15 310) 35%, transparent); background: color-mix(in oklch, oklch(62% 0.15 310) 10%, transparent); }
.badge-primary.pink       { color: oklch(62% 0.14 350); border-color: color-mix(in oklch, oklch(62% 0.14 350) 35%, transparent); background: color-mix(in oklch, oklch(62% 0.14 350) 10%, transparent); }
.badge-dot                { @apply badge; }
.badge-secondary          { @apply badge; }
.badge-dive               { @apply badge; }

/* Priority badges (legacy) */
.priority--badge { @apply badge; font-weight: 600; text-transform: capitalize; }
.priority--high   { @apply priority--badge; color: var(--danger); border-color: var(--danger-line); background: color-mix(in oklch, var(--danger) 10%, transparent); }
.priority--medium { @apply priority--badge; color: var(--accent); border-color: color-mix(in oklch, var(--accent) 38%, transparent); background: color-mix(in oklch, var(--accent) 10%, transparent); }
.priority--low    { @apply priority--badge; color: var(--ok); border-color: color-mix(in oklch, var(--ok) 35%, transparent); background: color-mix(in oklch, var(--ok) 10%, transparent); }
.tag--generic     { @apply priority--badge; color: var(--muted); }

/* ─── Role chips ──────────────────────────────────────────────────────────── */
.role-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--chip-bg);
}
.role-chip.owner, .role-chip.admin     { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 40%, transparent); }
.role-chip.maintainer                   { color: var(--ok); border-color: color-mix(in oklch, var(--ok) 40%, transparent); }
.role-chip.operator                     { color: oklch(68% 0.12 230); border-color: color-mix(in oklch, oklch(68% 0.12 230) 40%, transparent); }

/* ─── Segmented control ──────────────────────────────────────────────────── */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--chip-bg);
  padding: 3px;
}
.seg > button, .seg > a {
  appearance: none; border: 0; cursor: pointer;
  padding: 4px 10px; border-radius: 5px;
  font-size: 11.5px; font-weight: 500;
  color: var(--muted); background: transparent;
  text-decoration: none;
}
.seg > button.on, .seg > a.on { background: var(--seg-active-bg); color: var(--fg); }
.seg > button:hover:not(.on), .seg > a:hover:not(.on) { color: var(--fg); }

/* ─── Panel ──────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel-raise);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head .t { font-size: 13px; font-weight: 600; letter-spacing: -0.005em; color: var(--fg); }
.panel-head .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ─── Machine photo placeholder ──────────────────────────────────────────── */
.photo {
  position: relative;
  background: var(--tint, #3a3a3a);
  overflow: hidden;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
}
.photo::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 8px);
}
.photo .id {
  position: absolute; bottom: 4px; right: 6px;
  font-family: var(--mono); font-size: 8.5px;
  color: rgba(255,255,255,0.75);
}

/* ─── Metric tile ────────────────────────────────────────────────────────── */
.metric {
  background: var(--panel-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.metric.urgent::before {
  content: '';
  position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 2px; background: var(--danger); border-radius: 2px;
}
.metric .m-label       { display: flex; align-items: center; justify-content: space-between; }
.metric .m-label > span{ font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.metric .m-value       { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; color: var(--fg); }
.metric .m-delta       { font-size: 11px; color: var(--muted); margin-top: 1px; }
.metric .m-delta.bad   { color: var(--danger); }

/* ─── Avatar ─────────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  flex: none;
}

/* ─── Table ──────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table td, .data-table th {
  padding: 10px 12px;
  text-align: left;
  border-top: 1px solid var(--line);
  color: var(--fg);
}
.data-table th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--chip-bg);
  border-top: 0;
}
.data-table td.mono { font-family: var(--mono); color: var(--muted); }

/* ─── Markdown prose ─────────────────────────────────────────────────────── */
.markdown {
  @apply prose max-w-4xl py-6;
  color: var(--fg);
}
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { @apply my-4; color: var(--fg); }
.markdown p + p { @apply mt-4; }

.show-details { font-size: 12px; color: var(--muted); }

/* ─── Legacy button-group ────────────────────────────────────────────────── */
.button-group {
  @apply isolate flex items-center;
}
.button-group button {
  @apply button-base-sm;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  border-radius: 0;
  margin-left: -1px;
}
.button-group button:first-child { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.button-group button:last-child  { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.button-group button:hover       { background: var(--chip-bg); color: var(--fg); }
.button-group button.active      { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* Mono utility */
.mono { font-family: var(--mono); }

/* Tabular nums */
.tnum { font-variant-numeric: tabular-nums; }
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
