/* ============================================================================
   Hakwork Design System  ·  hakwork.css
   Single source of truth for tokens + reusable components. New pages link this
   and use the classes; do NOT re-declare colors inline. Naming: BEM-ish
   (block, block__element, block--modifier). Tokens are --hw-<group>-<name>.
   ============================================================================ */

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* Brand (evolved from the existing purple accent) */
  --hw-brand-50:  #efeafe;
  --hw-brand-100: #e0d7fc;
  --hw-brand-500: #5b2ee5;   /* primary accent */
  --hw-brand-600: #4a23c4;   /* accent hover / pressed */
  --hw-brand-700: #3c1ba3;

  /* Neutral scale */
  --hw-gray-0:   #ffffff;
  --hw-gray-50:  #f7f6fb;
  --hw-gray-100: #f3f1fa;
  --hw-gray-200: #e7e4f2;
  --hw-gray-300: #d7d3e6;
  --hw-gray-400: #9a94b0;
  --hw-gray-500: #6f6b85;
  --hw-gray-700: #443f5c;
  --hw-gray-900: #1d1a2e;

  /* Semantic hues */
  --hw-success: #16a34a;  --hw-success-bg: rgba(22,163,74,0.10);  --hw-success-bd: rgba(22,163,74,0.28);
  --hw-warning: #d97706;  --hw-warning-bg: rgba(217,119,6,0.10);  --hw-warning-bd: rgba(217,119,6,0.28);
  --hw-danger:  #dc2626;  --hw-danger-bg:  rgba(220,38,38,0.10);  --hw-danger-bd:  rgba(220,38,38,0.28);
  --hw-info:    #5b2ee5;  --hw-info-bg:    rgba(91,46,229,0.08);  --hw-info-bd:    rgba(91,46,229,0.25);

  /* Semantic roles (use these in components, not raw hues) */
  --hw-bg:        var(--hw-gray-50);
  --hw-surface:   var(--hw-gray-0);
  --hw-surface-2: var(--hw-gray-100);
  --hw-border:    var(--hw-gray-200);
  --hw-text:      var(--hw-gray-900);
  --hw-muted:     var(--hw-gray-500);
  --hw-accent:    var(--hw-brand-500);
  --hw-accent-hover: var(--hw-brand-600);
  --hw-on-accent: #ffffff;

  /* Type */
  --hw-font: 'Inter', system-ui, -apple-system, sans-serif;
  --hw-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --hw-text-xs: 0.72rem; --hw-text-sm: 0.82rem; --hw-text-base: 0.9rem;
  --hw-text-lg: 1.05rem; --hw-text-xl: 1.3rem; --hw-text-2xl: 1.6rem;

  /* Space (4px scale) */
  --hw-space-1: 0.25rem; --hw-space-2: 0.5rem; --hw-space-3: 0.75rem;
  --hw-space-4: 1rem; --hw-space-5: 1.5rem; --hw-space-6: 2rem; --hw-space-8: 3rem;

  /* Radius / shadow / motion */
  --hw-radius-sm: 8px; --hw-radius: 12px; --hw-radius-lg: 16px; --hw-radius-full: 999px;
  --hw-shadow-sm: 0 1px 2px rgba(29,26,46,0.06);
  --hw-shadow:    0 4px 16px rgba(29,26,46,0.08);
  --hw-shadow-lg: 0 12px 32px rgba(29,26,46,0.12);
  --hw-transition: 0.15s ease;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
.hw { color: var(--hw-text); font-family: var(--hw-font); }

/* Centered single-card layout (auth, settings) */
.hw-shell { min-height: 100vh; background: var(--hw-bg); display: flex;
  align-items: flex-start; justify-content: center; padding: var(--hw-space-6) var(--hw-space-4); }
.hw-shell--center { align-items: center; }

/* ── Icons ───────────────────────────────────────────────────────────────── */
.hw-icon { width: 1.1em; height: 1.1em; flex-shrink: 0; stroke: currentColor;
  fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
.hw-icon--lg { width: 1.4em; height: 1.4em; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.hw-card { background: var(--hw-surface); border: 1px solid var(--hw-border);
  border-radius: var(--hw-radius); box-shadow: var(--hw-shadow-sm); }
.hw-card__body { padding: var(--hw-space-5); }
.hw-card__title { font-size: var(--hw-text-xl); font-weight: 700; letter-spacing: -0.01em; }
.hw-card__desc { color: var(--hw-muted); font-size: var(--hw-text-sm); margin-top: var(--hw-space-1); line-height: 1.5; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.hw-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--hw-space-2);
  font-family: var(--hw-font); font-size: var(--hw-text-base); font-weight: 600; line-height: 1;
  padding: 0.7rem 1.1rem; border-radius: var(--hw-radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: background var(--hw-transition), border-color var(--hw-transition), color var(--hw-transition); }
.hw-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hw-btn--block { width: 100%; }
.hw-btn--sm { padding: 0.45rem 0.8rem; font-size: var(--hw-text-sm); }
.hw-btn--primary { background: var(--hw-accent); color: var(--hw-on-accent); }
.hw-btn--primary:hover:not(:disabled) { background: var(--hw-accent-hover); }
.hw-btn--ghost { background: var(--hw-surface); color: var(--hw-text); border-color: var(--hw-border); }
.hw-btn--ghost:hover:not(:disabled) { border-color: var(--hw-accent); color: var(--hw-accent); }
.hw-btn--success { background: var(--hw-success-bg); color: var(--hw-success); border-color: var(--hw-success-bd); }
.hw-btn--danger  { background: var(--hw-danger-bg);  color: var(--hw-danger);  border-color: var(--hw-danger-bd); }

/* Back link (subtle, top-of-page) */
.hw-back { display: inline-flex; align-items: center; gap: var(--hw-space-2); color: var(--hw-muted);
  font-size: var(--hw-text-sm); text-decoration: none; border: 1px solid var(--hw-border);
  padding: 0.4rem 0.8rem; border-radius: var(--hw-radius-sm); transition: var(--hw-transition); }
.hw-back:hover { color: var(--hw-text); border-color: var(--hw-muted); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.hw-field { margin-bottom: var(--hw-space-4); }
.hw-label { display: block; font-size: var(--hw-text-sm); font-weight: 600; color: var(--hw-muted); margin-bottom: var(--hw-space-2); }
.hw-input, .hw-select { width: 100%; background: var(--hw-surface-2); border: 1px solid var(--hw-border);
  border-radius: var(--hw-radius-sm); color: var(--hw-text); font-family: var(--hw-font);
  font-size: var(--hw-text-base); padding: 0.6rem 0.75rem; outline: none; transition: border-color var(--hw-transition); }
.hw-input:focus, .hw-select:focus { border-color: var(--hw-accent); }
/* Custom chevron so closed selects match the app (the OPEN list is OS-native
   and can't be CSS-styled — that needs a JS dropdown). */
.hw-select { appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f6b85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; }
.hw-hint { color: var(--hw-muted); font-size: var(--hw-text-xs); margin-top: var(--hw-space-1); }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.hw-switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.hw-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.hw-switch__track { width: 42px; height: 24px; border-radius: var(--hw-radius-full);
  background: var(--hw-gray-300); transition: background var(--hw-transition); flex-shrink: 0; }
.hw-switch__thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--hw-shadow-sm); transition: transform var(--hw-transition); }
.hw-switch input:checked + .hw-switch__track { background: var(--hw-accent); }
.hw-switch input:checked + .hw-switch__track .hw-switch__thumb { transform: translateX(18px); }

/* ── Segmented control ───────────────────────────────────────────────────── */
.hw-segmented { display: inline-flex; width: fit-content; gap: 4px; padding: 4px;
  background: var(--hw-surface-2); border: 1px solid var(--hw-border); border-radius: var(--hw-radius-sm); }
.hw-segmented button { border: none; background: transparent; color: var(--hw-text); font-family: var(--hw-font);
  font-size: var(--hw-text-sm); font-weight: 600; padding: 0.45rem 0.9rem; border-radius: 7px; cursor: pointer;
  transition: background var(--hw-transition), color var(--hw-transition); }
.hw-segmented button:not(.is-active):hover { background: rgba(29,26,46,0.05); }
.hw-segmented button.is-active { background: var(--hw-accent); color: var(--hw-on-accent); box-shadow: var(--hw-shadow-sm); }

/* ── Alerts / banners ────────────────────────────────────────────────────── */
.hw-alert { display: flex; gap: var(--hw-space-2); align-items: flex-start; padding: 0.85rem 1rem;
  border-radius: var(--hw-radius-sm); font-size: var(--hw-text-sm); line-height: 1.5; border: 1px solid transparent; }
.hw-alert--success { background: var(--hw-success-bg); color: var(--hw-success); border-color: var(--hw-success-bd); }
.hw-alert--danger  { background: var(--hw-danger-bg);  color: var(--hw-danger);  border-color: var(--hw-danger-bd); }
.hw-alert--warning { background: var(--hw-warning-bg); color: var(--hw-warning); border-color: var(--hw-warning-bd); }
.hw-alert--info    { background: var(--hw-info-bg);    color: var(--hw-brand-700); border-color: var(--hw-info-bd); }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.hw-badge { display: inline-flex; align-items: center; gap: var(--hw-space-1); font-size: var(--hw-text-xs);
  font-weight: 700; padding: 0.15rem 0.5rem; border-radius: var(--hw-radius-full); }
.hw-badge--pro { background: var(--hw-brand-50); color: var(--hw-brand-700); }
.hw-badge--muted { background: var(--hw-surface-2); color: var(--hw-muted); }

/* ── Brand mark + wordmark ───────────────────────────────────────────────── */
.hw-logo { width: 44px; height: 44px; background: var(--hw-brand-50); border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; }
.hw-logo .hw-icon { width: 24px; height: 24px; stroke: var(--hw-accent); }
/* Brand lockup: logo mark + "Hakwork" wordmark. Use everywhere the product
   should identify itself (auth cards, topbars). */
.hw-brand { display: inline-flex; align-items: center; gap: var(--hw-space-2); text-decoration: none; flex-shrink: 0; }
/* Lowercase logotype; the "o" is a node dot echoing the connector mark → hakw●rk */
.hw-wordmark { font-weight: 800; font-size: var(--hw-text-lg); letter-spacing: -0.045em;
  text-transform: lowercase; color: var(--hw-text); line-height: 1; white-space: nowrap; }
.hw-wordmark__dot { display: inline-block; width: 0.44em; height: 0.44em; background: var(--hw-accent);
  border-radius: 50%; vertical-align: 0.02em; margin: 0 0.015em; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.hw-table { width: 100%; border-collapse: collapse; font-size: var(--hw-text-sm); }
.hw-table th { padding: 0.65rem 1rem; text-align: left; color: var(--hw-muted); font-weight: 600;
  font-size: var(--hw-text-xs); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--hw-border); }
.hw-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--hw-border); vertical-align: middle; }
.hw-table tr:last-child td { border-bottom: none; }
.hw-table tbody tr:hover td { background: var(--hw-surface-2); }
.hw-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Dialog (modal) ──────────────────────────────────────────────────────── */
.hw-dialog { background: var(--hw-surface); border: 1px solid var(--hw-border); border-radius: var(--hw-radius);
  color: var(--hw-text); padding: var(--hw-space-5); width: 340px; max-width: calc(100vw - 2rem); font-family: var(--hw-font); }
.hw-dialog::backdrop { background: rgba(29,26,46,0.5); }
.hw-dialog h3 { font-size: var(--hw-text-lg); font-weight: 700; margin-bottom: var(--hw-space-4); }

/* ── Topbar (app pages) ──────────────────────────────────────────────────── */
.hw-topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--hw-space-4);
  flex-wrap: wrap; margin-bottom: var(--hw-space-6); }
.hw-topbar__left { display: flex; align-items: center; gap: var(--hw-space-3); }
.hw-pill { display: inline-flex; align-items: center; gap: var(--hw-space-2); background: var(--hw-surface-2);
  border: 1px solid var(--hw-border); border-radius: var(--hw-radius-full); padding: 0.35rem 0.85rem; font-size: var(--hw-text-xs); }
.hw-pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--hw-success); }

/* ── Step progress (onboarding) ──────────────────────────────────────────── */
.hw-steps { display: flex; gap: var(--hw-space-2); margin-bottom: var(--hw-space-5); }
.hw-steps__bar { flex: 1; height: 4px; border-radius: 2px; background: var(--hw-border); }
.hw-steps__bar--done { background: var(--hw-success); }
.hw-steps__bar--active { background: var(--hw-accent); }

/* ── Instruction note (info panel with ordered steps) ────────────────────── */
.hw-note { background: var(--hw-info-bg); border: 1px solid var(--hw-info-bd); border-radius: var(--hw-radius-sm);
  padding: var(--hw-space-4); font-size: var(--hw-text-sm); line-height: 1.6; color: var(--hw-text); }
.hw-note strong { color: var(--hw-text); }
.hw-note ol, .hw-note ul { padding-left: 1.2rem; margin-top: var(--hw-space-2); }
.hw-note li { margin-bottom: var(--hw-space-1); }
.hw-note a { color: var(--hw-accent); }

/* Inline code (e.g. redirect URIs to copy) */
.hw-code { font-family: var(--hw-mono); font-size: 0.82em; background: var(--hw-surface-2);
  border: 1px solid var(--hw-border); border-radius: 6px; padding: 0.08rem 0.35rem; word-break: break-all; }

/* ── Row (label + control) ───────────────────────────────────────────────── */
.hw-row { display: flex; align-items: center; justify-content: space-between; gap: var(--hw-space-4);
  padding: var(--hw-space-4) 0; border-top: 1px solid var(--hw-border); }
.hw-row:first-of-type { border-top: none; }
.hw-row__label { font-size: var(--hw-text-base); font-weight: 600; }
.hw-row__sub { color: var(--hw-muted); font-size: var(--hw-text-xs); margin-top: 2px; }
