/* WGI Quotes — design tokens + layout primitives.
 * Goal: tech-illiterate-friendly. Big targets, plain colors, clear status. */

:root {
  /* Status palette */
  --c-blue:  #2563eb;
  --c-blue-soft:  #dbeafe;
  --c-amber: #d97706;
  --c-amber-soft: #fef3c7;
  --c-green: #15803d;
  --c-green-soft: #dcfce7;
  --c-gray:  #6b7280;
  --c-gray-soft:  #f3f4f6;
  --c-red:   #dc2626;
  --c-red-soft:   #fee2e2;

  /* Surfaces */
  --bg:        #f8fafc;
  --bg-card:   #ffffff;
  --border:    #e5e7eb;
  --border-strong: #d1d5db;
  --text:      #111827;
  --text-soft: #6b7280;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.08);

  /* Type scale */
  --fs-xs: 0.78rem;
  --fs-sm: 0.92rem;
  --fs-md: 1rem;
  --fs-lg: 1.18rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;

  /* Spacing rhythm */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-8: 3rem;

  --radius:    8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: var(--fs-md);
  line-height: 1.5;
}

a { color: var(--c-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────────────────────────────────────────── topbar ─── */

.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  font-weight: 700;
  font-size: var(--fs-lg);
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 480px; }
.search input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-md);
  background: var(--bg);
}
.search input:focus { outline: 2px solid var(--c-blue); outline-offset: 1px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-left: auto;
  font-size: var(--fs-sm);
}
.who { color: var(--text-soft); }
.text-link {
  background: none;
  border: none;
  color: var(--c-blue);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}
.text-link:hover { text-decoration: underline; }

/* ───────────────────────────────────────────── layout ─── */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--sp-5);
}

/* ───────────────────────────────────────────── login ─── */

.login-card {
  max-width: 380px;
  margin: 8vh auto 0;
  padding: var(--sp-6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.login-card h1 {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xl);
}
.login-card label {
  display: block;
  margin: var(--sp-4) 0;
  font-size: var(--fs-sm);
  color: var(--text-soft);
}
.login-card label span { display: block; margin-bottom: var(--sp-1); }
.login-card input[type="password"] {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-md);
}
.login-card input[type="password"]:focus { outline: 2px solid var(--c-blue); outline-offset: 1px; }

/* ───────────────────────────────────────────── buttons ─── */

.btn {
  display: inline-block;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--fs-md);
  font-weight: 500;
  text-align: center;
  transition: filter 0.1s, transform 0.05s;
  min-height: 44px;          /* big enough for fat-finger touch */
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--c-blue); color: white; }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--c-red); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); min-height: 0; }
.btn-link {
  background: transparent;
  border: none;
  color: var(--c-blue);
  text-decoration: underline;
  padding: 0 var(--sp-2);
  min-height: 0;
  font-size: inherit;
  cursor: pointer;
}
.btn-link:hover { filter: brightness(1.15); }

/* generic toggle helper */
.hidden { display: none !important; }

/* row highlight inside base-specifics for compatibility-warning rows */
.row-warning td { background: var(--c-amber-soft); }

/* ───────────────────────────────────────────── alerts / banners ─── */

.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
}
.alert-error   { background: var(--c-red-soft);   color: var(--c-red);   border: 1px solid var(--c-red); }
.alert-warning { background: var(--c-amber-soft); color: var(--c-amber); border: 1px solid var(--c-amber); }
.alert-info    { background: var(--c-blue-soft);  color: var(--c-blue);  border: 1px solid var(--c-blue); }

.muted { color: var(--text-soft); }

/* ───────────────────────────────────────────── kanban ─── */

.kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-5);
  margin-top: var(--sp-2);
}
@media (max-width: 1100px) {
  .kanban { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .kanban { grid-template-columns: 1fr; }
}

.lane {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  min-height: 200px;
}
.lane-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-2) var(--sp-3);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--sp-3);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lane-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}
.lane[data-color="blue"]  .lane-dot { background: var(--c-blue); }
.lane[data-color="amber"] .lane-dot { background: var(--c-amber); }
.lane[data-color="green"] .lane-dot { background: var(--c-green); }
.lane[data-color="gray"]  .lane-dot { background: var(--c-gray); }
.lane-count {
  margin-left: auto;
  background: var(--c-gray-soft);
  color: var(--text-soft);
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 999px;
}

.lane-empty {
  text-align: center;
  padding: var(--sp-5) var(--sp-3);
  color: var(--text-soft);
  font-size: var(--fs-sm);
}

/* ───────────────────────────────────────────── ticket card ─── */

.ticket-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.08s, box-shadow 0.08s, border-color 0.08s;
}
.ticket-card:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.ticket-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}
.ticket-num {
  color: var(--text-soft);
  font-size: var(--fs-xs);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.ticket-time {
  color: var(--text-soft);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
.ticket-company {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.3;
}
.ticket-subject {
  color: var(--text-soft);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: var(--sp-1);
}
.ticket-badges {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  margin-top: var(--sp-2);
}
.badge {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.badge-amber { background: var(--c-amber-soft); color: var(--c-amber); }
.badge-blue  { background: var(--c-blue-soft);  color: var(--c-blue); }
.badge-green { background: var(--c-green-soft); color: var(--c-green); }
.badge-red   { background: var(--c-red-soft);   color: var(--c-red); }

/* ───────────────────────────────────────────── ticket detail ─── */

.ticket-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.ticket-detail-head h1 {
  margin: 0;
  font-size: var(--fs-xl);
}
.back-link {
  display: inline-block;
  margin-bottom: var(--sp-2);
  color: var(--text-soft);
  font-size: var(--fs-sm);
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.section-title {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-md);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.section-title .pill {
  background: var(--c-blue-soft);
  color: var(--c-blue);
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Email body / quoted source */
.email-body {
  background: var(--bg);
  border-left: 3px solid var(--border-strong);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: var(--fs-sm);
  max-height: 400px;
  overflow-y: auto;
}

/* ───────────────────────────────────────────── envelope summary (Phase 2) ─── */

.envelope-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
}
.envelope-row {
  display: flex;
  gap: var(--sp-3);
  align-items: baseline;
  padding: var(--sp-1) 0;
  font-size: var(--fs-md);
}
.envelope-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  min-width: 90px;
  flex-shrink: 0;
}
.envelope-value { color: var(--text); }
.envelope-section {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.envelope-section .envelope-label {
  display: block;
  margin-bottom: var(--sp-2);
}
.envelope-list {
  margin: 0;
  padding-left: var(--sp-5);
  font-size: var(--fs-sm);
}
.envelope-list li {
  padding: var(--sp-1) 0;
  line-height: 1.5;
}

.base-specifics {
  width: 100%;
  margin-top: var(--sp-2);
  border-collapse: collapse;
  font-size: var(--fs-xs);
}
.base-specifics th, .base-specifics td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.base-specifics thead th {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  background: var(--bg);
}
.base-specifics code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: var(--fs-xs);
  background: var(--c-blue-soft);
  color: var(--c-blue);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ───────────────────────────────────────────── smart flag actions ─── */

.flag-card {
  /* Override .alert padding/margin to make room for the action form. */
  padding: var(--sp-4);
  display: block;
}
.flag-card .flag-head {
  margin-bottom: var(--sp-4);
  font-size: var(--fs-md);
  color: var(--c-amber);
}
.flag-card .flag-head strong { color: var(--c-amber); }
.flag-card .flag-head .muted { color: var(--text-soft); }

/* Each option (create / link / skip) is its own card.  Replaces the old
   fieldset+legend layout — legend was browser-quirky and the title sat on
   the border at a different x-offset than the inputs inside.  Plain
   div+div lets every label and input line up on the same left edge. */
.flag-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 var(--sp-3);
  background: var(--bg-card);
  overflow: hidden;   /* clip the title's top-radius corners */
}
.flag-section-title {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--bg-subtle, #f6f8fa);
  border-bottom: 1px solid var(--border);
}
.flag-section-body { padding: var(--sp-4); }
.flag-section-body > :last-child { margin-bottom: 0; }

/* Compact horizontal row of action buttons (used by the domain-match
   quick-link section above the main form). */
.flag-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.flag-grid label { display: block; font-size: var(--fs-sm); color: var(--text-soft); }
.flag-grid label span { display: block; margin-bottom: 4px; }
.flag-grid input,
.flag-grid select {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-md);
  font-family: inherit;
  background: var(--bg-card);
}
.flag-grid input:focus,
.flag-grid select:focus { outline: 2px solid var(--c-blue); outline-offset: 1px; }

/* ───────────────────────────────────────────── question card ─── */

.question {
  border-top: 1px solid var(--border);
  padding: var(--sp-4) 0;
}
.question:first-of-type { border-top: none; padding-top: 0; }

.question-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.question-num {
  background: var(--c-amber);
  color: white;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.question-prompt {
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--text);
}
.question-why {
  color: var(--text-soft);
  font-size: var(--fs-sm);
  margin: var(--sp-2) 0 0;
  font-style: italic;
}
.question-options { margin-top: var(--sp-3); }
.question-options label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: var(--sp-2);
  transition: border-color 0.05s, background 0.05s;
}
.question-options label:hover {
  background: var(--bg);
  border-color: var(--border-strong);
}
.question-options input[type="radio"],
.question-options input[type="checkbox"] {
  width: 20px; height: 20px;
  flex-shrink: 0;
}
.question-options input[type="text"],
.question-options input[type="number"],
.question-options input[type="date"],
.question-options textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: var(--fs-md);
  font-family: inherit;
}
.question-options textarea { min-height: 80px; resize: vertical; }
.question-answered {
  background: var(--c-green-soft);
  color: var(--c-green);
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}
.actions-right { margin-left: auto; }

/* ───────────────────────────────────────────── toast ─── */

.toast {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  background: var(--text);
  color: white;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  z-index: 100;
}
