@import url('/portal/fonts/fonts.css');

/**
 * HoraMigo portal — visual system.
 *
 * Direction: "clinical luxe". A tool that clinic staff sit in all day, so it
 * stays quiet: a warm paper canvas rather than the usual cold blue-grey, deep
 * navy for structure, and a single teal accent used sparingly enough that it
 * still means something. Fraunces (serif) appears only on page titles and
 * headline figures — that editorial note is what separates this from a generic
 * admin template, and it is deliberately rationed.
 */

:root {
  /* Brand, inherited from the clinic's own identity */
  --navy-900: #0e2547;
  --navy-800: #14315b;
  --navy-700: #1b3d6d;
  --navy-600: #2a5288;
  --teal-400: #71e3dd;
  --teal-600: #14a89f;
  --teal-050: #e7faf8;

  /* Warm neutrals: paper, not screen-grey */
  --paper: #f7f6f3;
  --paper-2: #f2f0ec;
  --surface: #ffffff;
  --ink-900: #14202f;
  --ink-700: #33445c;
  --ink-500: #64748b;
  --ink-400: #8a97a8;
  --line: #e6e2db;
  --line-strong: #d6d1c8;

  --ok-bg: #e8f6ec;
  --ok-fg: #1a6b34;
  --warn-bg: #fdf3e2;
  --warn-fg: #96591a;
  --err-bg: #fdecec;
  --err-fg: #a32020;
  --info-bg: #eaf2fb;
  --info-fg: #1b4a80;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Layered rather than single-blur: closer to how light actually falls */
  --shadow-xs: 0 1px 2px rgba(20, 32, 47, 0.05);
  --shadow-sm: 0 1px 2px rgba(20, 32, 47, 0.05), 0 2px 6px rgba(20, 32, 47, 0.04);
  --shadow-md: 0 1px 3px rgba(20, 32, 47, 0.06), 0 8px 24px -8px rgba(20, 32, 47, 0.12);
  --shadow-lg: 0 2px 6px rgba(20, 32, 47, 0.06), 0 20px 44px -16px rgba(20, 32, 47, 0.22);

  --sans: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', ui-serif, Georgia, 'Times New Roman', serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-900);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv05' 1;
}

::selection { background: var(--teal-400); color: var(--navy-900); }

.loading {
  padding: 90px 20px;
  text-align: center;
  color: var(--ink-400);
  font-size: 14px;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------------------- structure */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #eaf1f9;
  position: sticky;
  top: 0;
  height: 100vh;
  /* Depth comes from a soft radial bloom over the gradient, not a flat fill. */
  background:
    radial-gradient(120% 60% at 12% 0%, rgba(113, 227, 221, 0.16), transparent 62%),
    linear-gradient(180deg, var(--navy-800) 0%, var(--navy-900) 100%);
}

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.015em;
  padding: 2px 10px 22px;
  color: #fff;
}
.brand small {
  display: block;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: rgba(234, 241, 249, 0.62);
  margin-top: 3px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: rgba(234, 241, 249, 0.72);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.nav-link svg { width: 17px; height: 17px; flex: none; opacity: 0.75; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link:hover svg { opacity: 1; }
.nav-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }
.nav-link.active svg { opacity: 1; color: var(--teal-400); }
/* The accent rail is the one place the teal is allowed to shout. */
.nav-link.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--teal-400);
}
.nav-link:focus-visible { outline: 2px solid var(--teal-400); outline-offset: 2px; }

.nav-section {
  margin-top: 20px;
  padding: 0 11px 7px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: rgba(234, 241, 249, 0.42);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(234, 241, 249, 0.6);
}
.sidebar-footer .who {
  margin: 10px 0 2px;
  color: rgba(234, 241, 249, 0.85);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-footer button {
  color: rgba(234, 241, 249, 0.6);
  background: none;
  border: 0;
  padding: 2px 0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color 0.16s var(--ease);
}
.sidebar-footer button:hover { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  padding: 36px 40px 80px;
  max-width: 1240px;
}

.page-title {
  margin: 0 0 5px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.page-sub {
  margin: 0 0 28px;
  color: var(--ink-500);
  font-size: 14px;
  max-width: 68ch;
}

/* Each block settles in just after the one before it — enough to feel
   composed on load, not enough to make navigation feel slow. */
.main > * { animation: rise 0.42s var(--ease) both; }
.main > *:nth-child(2) { animation-delay: 0.04s; }
.main > *:nth-child(3) { animation-delay: 0.08s; }
.main > *:nth-child(4) { animation-delay: 0.12s; }
.main > *:nth-child(n + 5) { animation-delay: 0.15s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ components */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card .hint { color: var(--ink-500); font-size: 13px; margin: 0 0 18px; max-width: 72ch; }
.card > .hint:last-child { margin-bottom: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.stat::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-400), transparent 70%);
  opacity: 0;
  transition: opacity 0.24s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat:hover::after { opacity: 1; }
.stat .value {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.stat .label {
  color: var(--ink-500);
  font-size: 12.5px;
  font-weight: 500;
  margin-top: 5px;
  letter-spacing: 0.005em;
}

/* ----------------------------------------------------------------- forms */

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--ink-700);
  margin: 16px 0 6px;
}
label .optional { font-weight: 400; color: var(--ink-400); }

input[type='text'], input[type='email'], input[type='password'],
input[type='number'], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-400); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-400); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px var(--teal-050);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 11px 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-700);
  cursor: pointer;
}
.checkbox input { width: auto; accent-color: var(--navy-700); width: 16px; height: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 17px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--navy-700);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: 0.005em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background 0.16s var(--ease), transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.btn:hover { background: var(--navy-800); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: none; }
.btn:focus-visible { outline: 2px solid var(--teal-600); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface); color: var(--navy-700); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--paper-2); border-color: var(--ink-400); }
.btn.danger { background: var(--err-fg); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; align-items: center; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; vertical-align: middle; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-400);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}
td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.13s var(--ease); }
tbody tr:hover { background: var(--paper); }
td.actions { text-align: right; white-space: nowrap; }
td strong { font-weight: 600; }

/* --------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
/* A dot carries the state at a glance, before anyone reads the word. */
.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.err { background: var(--err-bg); color: var(--err-fg); }
.badge.muted { background: var(--paper-2); color: var(--ink-500); }

/* --------------------------------------------------------------- alerts */

.alert {
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: #c9e8d3; }
.alert.err { background: var(--err-bg); color: var(--err-fg); border-color: #f5cfcf; }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: #f0dcbb; }
.alert.info { background: var(--info-bg); color: var(--info-fg); border-color: #cfe0f2; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert li { margin-top: 3px; }

.empty {
  color: var(--ink-400);
  font-size: 13.5px;
  padding: 40px 22px;
  text-align: center;
}

/* -------------------------------------------------------------- login */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(80% 55% at 50% 0%, rgba(113, 227, 221, 0.16), transparent 70%),
    radial-gradient(60% 45% at 85% 100%, rgba(27, 61, 109, 0.09), transparent 70%),
    var(--paper);
}
.login-card {
  width: 100%;
  max-width: 396px;
  padding: 32px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s var(--ease) both;
}
.login-card .brand { color: var(--navy-900); padding: 0 0 8px; font-size: 25px; }
.login-card .brand small { color: var(--ink-500); }

/* ------------------------------------------------------ language switch */

.lang-row { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.lang-select {
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #eaf1f9;
  cursor: pointer;
  transition: background 0.16s var(--ease);
}
.lang-select:hover { background: rgba(255, 255, 255, 0.14); }
.lang-select option { color: var(--ink-900); background: #fff; }
.lang-select:focus-visible { outline: 2px solid var(--teal-400); outline-offset: 2px; }
.lang-select-plain {
  width: auto;
  background: var(--surface);
  color: var(--ink-700);
  border-color: var(--line-strong);
}
.lang-select-plain:hover { background: var(--paper-2); }

/* -------------------------------------------------------- conversations */

.split { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }

.conv-list { max-height: 660px; overflow-y: auto; padding: 6px; }
.conv-item {
  padding: 12px 13px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.14s var(--ease);
  border: 1px solid transparent;
}
.conv-item:hover { background: var(--paper); }
.conv-item.active { background: var(--info-bg); border-color: #cfe0f2; }
.conv-item .num {
  font-weight: 600;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.conv-item .meta { color: var(--ink-400); font-size: 12px; margin-top: 2px; }

.chat {
  max-height: 620px;
  overflow-y: auto;
  padding: 14px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.bubble {
  max-width: 74%;
  padding: 10px 14px;
  border-radius: 14px;
  margin: 9px 10px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
  animation: rise 0.28s var(--ease) both;
}
.bubble.in { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.out { background: #dff5db; margin-left: auto; border-bottom-right-radius: 5px; }
.bubble .time {
  display: block;
  font-size: 10.5px;
  color: var(--ink-400);
  margin-top: 6px;
  letter-spacing: 0.01em;
}
.bubble .ai-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--teal-050);
  color: var(--teal-600);
  border-radius: 4px;
  padding: 2px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ------------------------------------------------------------- rules ui */

.rule-item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fff, var(--paper));
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.rule-item:hover { border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.rule-item .row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.rule-item label:first-child { margin-top: 0; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tab {
  padding: 10px 15px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.tab:hover { color: var(--ink-900); }
.tab.active { color: var(--navy-700); font-weight: 600; border-bottom-color: var(--navy-700); }
.tab:focus-visible { outline: 2px solid var(--teal-600); outline-offset: -2px; }

/* ---------------------------------------------------------- setup steps */

.steps { list-style: none; padding: 0; margin: 0; }
.steps li {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.steps li:last-child { border-bottom: 0; }
.steps .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
  box-shadow: 0 0 0 3px var(--paper-2);
}
.steps .dot.done { background: var(--ok-fg); box-shadow: 0 0 0 3px var(--ok-bg); }
.steps .dot.blocked { background: #d99223; box-shadow: 0 0 0 3px var(--warn-bg); }
.steps .dot.failed { background: var(--err-fg); box-shadow: 0 0 0 3px var(--err-bg); }
.step-detail { font-size: 12px; color: var(--ink-500); margin-top: 2px; max-width: 60ch; }

.setup-cta {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.setup-cta > div { flex: 1; min-width: 240px; }
.setup-cta strong { display: block; margin-bottom: 2px; font-size: 14px; }
.setup-cta .btn { flex: none; }

.tenant-picker { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tenant-choice {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), transform 0.16s var(--ease);
}
.tenant-choice:hover { border-color: var(--navy-600); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.tenant-choice strong { display: block; font-size: 14.5px; font-weight: 600; }
.tenant-choice span { font-size: 12px; color: var(--ink-400); }

.inline-link {
  color: var(--navy-700);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.16s var(--ease);
}
.inline-link:hover { border-bottom-color: var(--navy-700); }

/* ---------------------------------------------------------------- code */

code, pre { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
pre.snippet {
  background: var(--navy-900);
  color: #dbe7f5;
  padding: 16px 18px;
  border-radius: var(--r-md);
  overflow-x: auto;
  line-height: 1.6;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
td code { color: var(--ink-500); font-size: 11.5px; }

/* -------------------------------------------------------------- skeleton */

.skeleton {
  background: linear-gradient(90deg, var(--paper-2) 25%, #fbfaf8 50%, var(--paper-2) 75%);
  background-size: 200% 100%;
  animation: sweep 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes sweep {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
.skeleton-stat { height: 96px; border-radius: var(--r-lg); }
.skeleton-line { height: 13px; margin-bottom: 10px; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .conv-list { max-height: 340px; }
  .rule-item .row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 14px;
  }
  .brand { padding: 0 10px 0 4px; font-size: 18px; }
  .brand small { display: none; }
  .nav-link.active::before { display: none; }
  .nav-section { display: none; }
  .sidebar-footer {
    margin: 0 0 0 auto;
    padding-top: 0;
    border-top: 0;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .sidebar-footer .who { display: none; }
  .lang-select { width: auto; }
  .main { padding: 24px 18px 60px; }
  .page-title { font-size: 25px; }
  .rule-item .row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stat:hover, .btn:hover { transform: none; }
}
