/* ============================================================
   Survey Machine — Design System v1.0
   A Rune Tech product · rune-tech.org
   ============================================================ */

/* ── 1. Design Tokens ─────────────────────────────────────── */
:root {
  --sm-azure:      #1A6FBF;
  --sm-tide:       #00B4D8;
  --sm-sage:       #4CAF82;
  --sm-amber:      #F4A22D;
  --sm-slate:      #3D5A80;
  --sm-mist:       #8DA9C4;
  --sm-sky:        #EAF4FF;
  --sm-ink:        #0F1A2E;
  --sm-white:      #FFFFFF;
  --sm-error:      #D93025;

  --sm-border:     rgba(26, 111, 191, 0.18);
  --sm-border-md:  rgba(26, 111, 191, 0.32);
  --sm-border-top: 3px solid #1A6FBF;

  --sm-focus:      0 0 0 3px rgba(26, 111, 191, 0.35);

  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;
}

/* ── 2. Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--sm-ink);
  background: var(--sm-sky);
  -webkit-font-smoothing: antialiased;
}

/* ── 3. Typography ────────────────────────────────────────── */
.sm-display  { font-size: 28px; font-weight: 500; line-height: 1.2; color: var(--sm-ink); }
.sm-h1       { font-size: 22px; font-weight: 500; line-height: 1.3; color: var(--sm-ink); }
.sm-h2       { font-size: 17px; font-weight: 500; line-height: 1.4; color: var(--sm-ink); }
.sm-body     { font-size: 14px; font-weight: 400; line-height: 1.7; color: var(--sm-ink); }
.sm-caption  { font-size: 12px; font-weight: 400; line-height: 1.5; color: var(--sm-mist); }
.sm-label    { font-size: 11px; font-weight: 500; line-height: 1;   color: var(--sm-mist); text-transform: uppercase; letter-spacing: 0.08em; }
.sm-mono     { font-size: 13px; font-family: 'Courier New', monospace; color: var(--sm-slate); }

.sm-text-secondary { color: var(--sm-mist); }
.sm-text-primary   { color: var(--sm-azure); }

/* ── 4. Buttons ───────────────────────────────────────────── */
.sm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.sm-btn:active     { transform: scale(0.98); }
.sm-btn:disabled,
.sm-btn[disabled]  { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.sm-btn:focus-visible { outline: none; box-shadow: var(--sm-focus); }

.sm-btn-primary {
  background: var(--sm-azure);
  color: var(--sm-white);
}
.sm-btn-primary:hover { background: #155DA0; color: var(--sm-white); }

.sm-btn-secondary {
  background: transparent;
  color: var(--sm-azure);
  border: 1px solid var(--sm-azure);
}
.sm-btn-secondary:hover { background: var(--sm-sky); }

.sm-btn-ghost {
  background: transparent;
  color: var(--sm-slate);
  border: 0.5px solid var(--sm-border-md);
}
.sm-btn-ghost:hover { background: var(--sm-sky); }

.sm-btn-destructive {
  background: var(--sm-error);
  color: var(--sm-white);
}
.sm-btn-destructive:hover { background: #b5271e; color: var(--sm-white); }

.sm-btn-sm  { padding: 6px 14px; font-size: 12px; }
.sm-btn-xs  { padding: 4px 10px; font-size: 11px; }

/* ── 5. Inputs ────────────────────────────────────────────── */
.sm-input {
  width: 100%;
  height: 40px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 400;
  font-family: inherit;
  color: var(--sm-ink);
  background: var(--sm-white);
  border: 1px solid var(--sm-border-md);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sm-input::placeholder { color: var(--sm-mist); }
.sm-input:focus  { border-color: var(--sm-azure); box-shadow: var(--sm-focus); }
.sm-input.error  { border-color: var(--sm-error); }
.sm-input.error:focus { box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.25); }

.sm-label-text {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--sm-slate);
  margin-bottom: 6px;
}
.sm-helper { font-size: 12px; color: var(--sm-mist); margin-top: 4px; }
.sm-error-text { font-size: 12px; color: var(--sm-error); margin-top: 4px; }

/* ── 6. Cards ─────────────────────────────────────────────── */
.sm-card {
  background: var(--sm-white);
  border: 0.5px solid var(--sm-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.sm-card-accent {
  border-top: var(--sm-border-top);
}

.sm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--sm-border);
}

/* ── 7. Badges ────────────────────────────────────────────── */
.sm-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.sm-badge-active   { background: #D6F4FA; color: #0A7A96; }
.sm-badge-success  { background: #D8F5E8; color: #2A7A53; }
.sm-badge-pending  { background: #FEF1DA; color: #A0621A; }
.sm-badge-draft    { background: #DAEEFF; color: #1A6FBF; }
.sm-badge-neutral  { background: #E4EBF3; color: #3D5A80; }

/* Convenience aliases for survey open/closed */
.sm-badge-open   { background: #D8F5E8; color: #2A7A53; }
.sm-badge-closed { background: #E4EBF3; color: #3D5A80; }

/* ── 8. Progress Bar ──────────────────────────────────────── */
.sm-progress-track {
  width: 100%;
  height: 5px;
  background: var(--sm-sky);
  border-radius: 99px;
  overflow: hidden;
}
.sm-progress-fill       { height: 100%; border-radius: 99px; background: var(--sm-azure); transition: width 0.3s; }
.sm-progress-fill.high  { background: var(--sm-sage); }
.sm-progress-fill.low   { background: var(--sm-amber); }

/* ── 9. Rating Scale ──────────────────────────────────────── */
.sm-rating-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--sm-border-md);
  color: var(--sm-mist);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}
.sm-rating-dot:hover       { border-color: var(--sm-azure); color: var(--sm-azure); }
.sm-rating-dot.selected    { background: var(--sm-azure); color: #fff; border-color: var(--sm-azure); }
.sm-rating-dot.positive    { background: #D8F5E8; color: #2A7A53; border-color: var(--sm-sage); }

/* ── 10. Navbar (top / page-level) ───────────────────────── */
.sm-navbar {
  height: 56px;
  background: var(--sm-ink);
  display: flex;
  align-items: center;
  padding: 0 24px;
}
.sm-navbar-brand-block {
  width: 28px; height: 28px;
  background: var(--sm-azure);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.sm-navbar-brand-icon { color: var(--sm-tide); }
.sm-navbar-product-name { font-size: 13px; font-weight: 500; color: #EAF4FF; }
.sm-navbar-link        { font-size: 12px; font-weight: 400; color: var(--sm-mist); text-decoration: none; transition: color 0.15s; }
.sm-navbar-link:hover  { color: var(--sm-tide); }
.sm-navbar-link.active { color: var(--sm-tide); }
.sm-rune-badge {
  font-size: 11px;
  color: var(--sm-mist);
  border: 0.5px solid rgba(141, 169, 196, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
}

/* ── 11. Sidebar ──────────────────────────────────────────── */
.sm-sidebar { background: var(--sm-ink); }

.sm-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 400;
  color: var(--sm-mist);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.sm-nav-link:hover  { color: var(--sm-sky); background: rgba(255,255,255,0.06); }
.sm-nav-link.active { color: var(--sm-tide); font-weight: 500; background: rgba(0, 180, 216, 0.1); }
.sm-nav-link svg    { flex-shrink: 0; width: 18px; height: 18px; }

/* ── 12. Stat / Metric Cards ──────────────────────────────── */
.sm-stat-card {
  background: var(--sm-white);
  border: 0.5px solid var(--sm-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}
.sm-stat-number { font-size: 22px; font-weight: 500; color: var(--sm-ink); line-height: 1.2; }
.sm-stat-label  { font-size: 11px; font-weight: 500; color: var(--sm-mist); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

/* ── 13. Tables ───────────────────────────────────────────── */
.sm-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.sm-table thead tr { background: var(--sm-sky); }
.sm-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sm-mist);
  border-bottom: 0.5px solid var(--sm-border);
}
.sm-table td {
  padding: 11px 16px;
  border-bottom: 0.5px solid var(--sm-border);
  color: var(--sm-ink);
}
.sm-table tbody tr:hover { background: var(--sm-sky); }
.sm-table tbody tr:last-child td { border-bottom: none; }

.sm-table-primary-cell { font-weight: 500; color: var(--sm-ink); }
.sm-table-secondary-cell { color: var(--sm-mist); }

/* ── 14. Error / Alert ────────────────────────────────────── */
.sm-alert-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-md);
  color: #991B1B;
  font-size: 14px;
}

.sm-alert-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  color: #92400E;
  font-size: 14px;
}

.sm-alert-success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: var(--radius-md);
  color: #14532D;
  font-size: 14px;
}

/* ── 15. Focus utility ────────────────────────────────────── */
.sm-focus:focus-visible { outline: none; box-shadow: var(--sm-focus); }

/* ── 16. Pagination ───────────────────────────────────────── */
.sm-page-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  color: var(--sm-slate);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
}
.sm-page-btn:hover    { background: var(--sm-sky); }
.sm-page-btn.active   { background: var(--sm-azure); color: var(--sm-white); font-weight: 500; }
.sm-page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── 17. Slide-in panel overlay ───────────────────────────── */
.sm-panel-backdrop { background: rgba(15, 26, 46, 0.4); }
.sm-panel {
  background: var(--sm-white);
  border-left: 0.5px solid var(--sm-border);
}

/* ── 18. Page layout shells ───────────────────────────────── */

/* Dark centred shell — login, password reset */
.sm-page-auth {
  min-height: 100vh;
  background: var(--sm-ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Light top-padded shell — register, longer forms */
.sm-page-form {
  min-height: 100vh;
  background: var(--sm-sky);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 56px 24px 64px;
}

/* ── 18b. Public survey pages ─────────────────────────────── */
/* Centred state pages (thank you, closed, etc.) */
.sm-survey-bg {
  min-height: 100vh;
  background: var(--sm-sky);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.sm-survey-card {
  width: 100%;
  background: var(--sm-white);
  border: 0.5px solid var(--sm-border);
  border-top: var(--sm-border-top);
  border-radius: var(--radius-xl);
  padding: 40px;
}
.sm-survey-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--sm-azure);
  color: var(--sm-white);
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.sm-survey-btn:hover  { background: #155DA0; }
.sm-survey-btn:active { transform: scale(0.99); }

/* ── 19. Icon container ───────────────────────────────────── */
.sm-icon-container {
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: #DAEEFF;
  color: var(--sm-azure);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── 20. Dark mode ────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --sm-white: #16213A;
    --sm-sky:   #0F1824;
  }
  body { background: #1A1A2E; color: #EAF4FF; }
  .sm-card  { background: #16213A; border-color: rgba(26,111,191,0.25); }
  .sm-input { background: #16213A; color: #EAF4FF; }
  .sm-table thead tr { background: #0F1824; }
  .sm-table tbody tr:hover { background: #0F1824; }
}
