/* Outreach CRM - app styles. Every colour, radius, shadow and font is a token from
   theme.css (generated from the EUDOCK design system; never edit colours here).
   Build-less consumer: this file mirrors the shadcn primitives by hand
   (Button, ToggleGroup, Card, Tabs, Badge, Empty, Skeleton, Alert, Dialog, sonner). */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted-foreground); }
.small { font-size: 12px; }
h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1.2;
  padding: 7px 12px; min-height: 32px;
  border-radius: var(--radius-md); border: 1px solid transparent;
  background: var(--muted); color: var(--foreground);
  cursor: pointer; white-space: nowrap;
}
.btn:focus-visible, .seg button:focus-visible, .tab:focus-visible, .icon-btn:focus-visible,
input:focus-visible, textarea:focus-visible, .row:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 1px;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 90%, var(--background)); }
.btn-outline { background: var(--background); border-color: var(--border); color: var(--foreground); }
.btn-outline:hover:not(:disabled), .btn-ghost:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive-outline { background: var(--background); border-color: var(--border); color: var(--destructive); }
.btn-destructive-outline:hover:not(:disabled) { background: var(--destructive-soft); }
.btn-sm { font-size: 12px; padding: 4px 9px; min-height: 26px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--muted-foreground); cursor: pointer;
}
.icon-btn:hover { background: var(--accent); color: var(--accent-foreground); }
.icon-btn svg { width: 16px; height: 16px; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ToggleGroup (buttons over dropdowns, design-system D21) ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  font: inherit; font-size: 13px; line-height: 1.2; padding: 6px 10px; min-height: 30px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--background); color: var(--foreground); cursor: pointer; white-space: nowrap;
}
.seg button:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
.seg button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.seg button:disabled { opacity: 0.5; cursor: default; }
.seg.seg-sm button { font-size: 12px; padding: 3px 8px; min-height: 26px; }

/* ---------- form controls ---------- */
input, textarea {
  font: inherit; font-size: 14px; color: var(--foreground);
  background: var(--background); border: 1px solid var(--input);
  border-radius: var(--radius-md); padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }
input[type="checkbox"] { width: auto; accent-color: var(--primary); }
label { font-size: 13px; font-weight: 500; }
.field { display: grid; gap: 6px; min-width: 0; }
.form { display: grid; gap: 16px; }
.form-2 { display: grid; gap: 16px; }
@media (min-width: 640px) { .form-2 { grid-template-columns: 1fr 1fr; } }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input { flex: 1 1 140px; width: auto; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; cursor: pointer; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--border);
}
.tb-brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .ver { color: var(--muted-foreground); font-weight: 400; font-size: 12px; margin-left: 6px; }
.tb-nav { display: flex; gap: 4px; }
.tb-nav a { padding: 6px 10px; border-radius: var(--radius-md); color: var(--muted-foreground); white-space: nowrap; }
.tb-nav a:hover { background: var(--accent); color: var(--accent-foreground); }
.tb-nav a.active { background: var(--muted); color: var(--foreground); font-weight: 500; }
.tb-search { position: relative; flex: 1 1 220px; max-width: 420px; min-width: 0; }
.tb-user { display: flex; align-items: center; gap: 6px; margin-left: auto; }
@media (max-width: 639px) {
  .tb-search { order: 3; flex-basis: 100%; max-width: none; }
  .brand .ver { display: none; }
}
.popover {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
  background: var(--popover); color: var(--popover-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  max-height: 360px; overflow: auto; padding: 4px;
}
.popover .row { border: none; border-radius: var(--radius-sm); }
.popover .note-line { padding: 8px 10px; font-size: 13px; }

/* ---------- layout ---------- */
#app { padding: 16px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; min-width: 0;
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.stack { display: grid; gap: 12px; min-width: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.person-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .person-grid { grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); align-items: start; }
}
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 4px; background: var(--muted);
  border-radius: var(--radius-lg); overflow-x: auto; max-width: 100%;
}
.tab {
  font: inherit; font-size: 13px; padding: 6px 12px; border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--muted-foreground); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab[aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: var(--shadow-sm); font-weight: 500; }
.count {
  font-size: 11px; min-width: 20px; padding: 0 6px; border-radius: var(--radius-xl);
  background: var(--background); color: var(--muted-foreground); text-align: center; line-height: 18px;
}
.tab[aria-selected="true"] .count { background: var(--primary); color: var(--primary-foreground); }

/* ---------- list rows ---------- */
.list { display: grid; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); overflow: hidden; }
.row {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: pointer; min-width: 0; width: 100%; text-align: left;
  font: inherit; color: inherit; background: transparent;
  border: none; border-top: 1px solid var(--border);
}
.list .row:first-child { border-top: none; }
.row:hover { background: var(--accent); color: var(--accent-foreground); }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-sub { font-size: 12px; color: var(--muted-foreground); overflow-wrap: anywhere; }
.row-side { font-size: 12px; color: var(--muted-foreground); white-space: nowrap; text-align: right; }
@media (max-width: 639px) {
  .row { flex-wrap: wrap; }
  .row-side { white-space: normal; text-align: left; flex-basis: 100%; }
}
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1.4;
  padding: 1px 8px; border-radius: var(--radius-xl); border: 1px solid var(--border);
  color: var(--foreground); background: transparent; white-space: nowrap;
}
.badge-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.badge-muted { background: var(--muted); border-color: var(--muted); color: var(--muted-foreground); }
.badge-destructive { background: var(--destructive); border-color: var(--destructive); color: var(--destructive-foreground); }

/* ---------- Empty / Skeleton / Alert ---------- */
.empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 40px 16px; }
.empty-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--muted); color: var(--muted-foreground);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px;
}
.empty-icon svg { width: 20px; height: 20px; }
.empty .muted { font-size: 13px; max-width: 360px; }
.skel { background: var(--muted); border-radius: var(--radius-md); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }
.alert {
  border: 1px solid var(--destructive); color: var(--destructive); background: var(--destructive-soft);
  border-radius: var(--radius-md); padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere;
}
.alert a { text-decoration: underline; font-weight: 500; }
.notice {
  border: 1px solid var(--border); background: var(--muted); color: var(--foreground);
  border-radius: var(--radius-md); padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere;
}

/* ---------- person page ---------- */
.dnc { border-color: var(--destructive); }
.identity { display: flex; gap: 8px; align-items: baseline; font-size: 13px; min-width: 0; }
.identity .handle { overflow-wrap: anywhere; min-width: 0; }
.membership { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; background: var(--background); }
.membership + .membership { margin-top: 10px; }
.membership-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.summary { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.note { font-size: 13px; padding: 8px 0; border-top: 1px solid var(--border); }
.note:first-child { border-top: none; padding-top: 0; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.collapsible > summary { cursor: pointer; font-size: 13px; color: var(--muted-foreground); list-style: none; padding: 4px 0; }
.collapsible > summary::-webkit-details-marker { display: none; }
/* caret drawn with borders: Outfit has no triangle glyphs (eudock-ui Step 3) */
.collapsible > summary::before {
  content: ""; display: inline-block; margin-right: 6px; vertical-align: 1px;
  border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.collapsible[open] > summary::before { transform: rotate(90deg); }
.collapsible[open] > summary { margin-bottom: 8px; }

/* ---------- timeline ---------- */
.timeline { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .timeline-scroll { max-height: 62vh; overflow-y: auto; padding-right: 4px; }
}
.msg { max-width: 85%; min-width: 0; display: grid; gap: 4px; }
.msg.in { justify-self: start; }
.msg.out { justify-self: end; }
.msg-meta { font-size: 12px; color: var(--muted-foreground); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.msg.out .msg-meta { justify-content: flex-end; }
.bubble {
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px;
  background: var(--card); white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-size: 13px;
}
/* not --secondary: in dark mode it is near-white and every sent message would shout */
.msg.out .bubble { background: var(--primary-soft); color: var(--foreground); }
.msg.draft .bubble { background: var(--background); border-style: dashed; border-color: var(--primary-edge); color: var(--foreground); }
.msg-subject { font-weight: 600; margin-bottom: 4px; }
.msg-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 639px) { .msg { max-width: 100%; } }

/* ---------- login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; }

/* ---------- Dialog ---------- */
#dialog-backdrop {
  position: fixed; inset: 0; z-index: 50; background: var(--overlay);
  display: grid; place-items: center; padding: 16px;
}
#dialog { width: 100%; max-width: 440px; display: grid; gap: 12px; box-shadow: var(--shadow-lg); background: var(--background); }

/* ---------- toasts (sonner, bottom-right) ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; width: 340px; max-width: calc(100vw - 32px); }
.toast {
  background: var(--popover); color: var(--popover-foreground); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 10px 12px; font-size: 13px; overflow-wrap: anywhere;
}
.toast.error { border-color: var(--destructive); color: var(--destructive); }
