@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap");

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #18181b;
  --muted: #71717a;
  --nav-hover: #e5e5e5;
  --primary: #7aa2f7;
  --primary-contrast: #1a1b26;
  --danger: #ef596f;
  --success: #22c55e;
  --shadow: 0 8px 20px rgb(0 0 0 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1b26;
    --surface: #1f2030;
    --border: #34354a;
    --text: #f1f1f3;
    --muted: #9aa5ce;
    --nav-hover: #7aa2f7;
    --primary: #7aa2f7;
    --primary-contrast: #1a1b26;
    --shadow: 0 8px 20px rgb(0 0 0 / 0.35);
  }
}

* {
  box-sizing: border-box;
}

/* .card/.view/.tabs all set display:flex, which — at equal CSS specificity — beats the
   browser's built-in [hidden]{display:none} rule (author styles win ties over UA styles).
   Without this, hidden elements stay visible. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

/* ---------- header / sidebar nav ---------- */

/* Default (logged out): a slim top bar with just the brand — matches the login screen's
   simple centered-card layout. Once authenticated, app.js adds .app-shell-active to <body>,
   and this same header becomes a fixed left sidebar instead — no DOM restructuring needed,
   .tabs-nav/.tab-link/.tab-panel are all the same elements either way. */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body.app-shell-active .app-header {
  position: fixed;
  inset: 0 auto 0 0;
  width: 225px;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1.75rem;
  padding: 1.25rem 1rem;
  border-bottom: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  min-width: 0;
}

body.app-shell-active .header-left {
  flex-direction: column;
  align-items: stretch;
  gap: 1.75rem;
}

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-account .contact-details {
  min-width: 0;
}

.sidebar-account .contact-name,
.sidebar-account .contact-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}

.brand:hover {
  opacity: 0.8;
}

.brand-logo {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
}

body.app-shell-active .tabs {
  flex-direction: column;
  align-items: stretch;
  gap: 0.15rem;
  overflow: visible;
}

.nav-section-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.9rem 0.75rem 0.35rem;
}

.nav-section-label:first-child {
  padding-top: 0;
}

.tab-link {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

body.app-shell-active .tab-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: flex-start;
  padding: 0.55rem 0.75rem;
}

.tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.tab-link:hover .tab-icon,
.tab-link.active .tab-icon {
  transform: translateY(-2px);
}

.tab-link:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.tab-link.active {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
  font-weight: 500;
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  font: inherit;
  color: var(--primary);
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-weight: 400;
}

.link-btn:hover {
  text-decoration: underline;
}

.icon-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0.4rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}

.icon-btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.icon-btn--confirm:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
}

/* ---------- layout ---------- */

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Wider than the login card — the tool-calls table needs real room, and the extra width
   doesn't hurt the simpler history/contacts/settings panels either. */
#portal-view {
  max-width: 1240px;
}

body.app-shell-active .view {
  margin-left: 225px;
  margin-right: auto;
  padding-left: 1.35rem;
}

.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 -0.5rem;
}

.page-head {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.page-head p {
  margin: 0;
  color: #78716c;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow);
}

/* Portal content (History/Contacts/Settings) sits directly on the page background —
   no bordered/shadowed box — matching the reference dashboard's plain content area. */
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card h1 {
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

#login-verify-form h1 {
  font-weight: 400;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

.phone-input-group {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
}

.phone-input-group input {
  text-align: center;
}

.phone-area,
.phone-exchange {
  flex: none;
  width: 2.5rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.phone-line {
  flex: none;
  width: 3.4rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.phone-area::placeholder,
.phone-exchange::placeholder,
.phone-line::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.phone-area:focus::placeholder,
.phone-exchange:focus::placeholder,
.phone-line:focus::placeholder {
  color: transparent;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  font: inherit;
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
}

.cta-btn {
  align-self: center;
  width: 50%;
  margin-top: 1.25rem;
  color: #ffffff;
}

.code-input {
  align-self: flex-start;
  width: 5.25rem;
  text-align: center;
  letter-spacing: 0.15em;
}

button:hover {
  opacity: 0.9;
}

.icon-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  flex-shrink: 0;
}

.icon-btn-primary svg {
  width: 16px;
  height: 16px;
}

.status {
  min-height: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.date-range {
  font-size: 0.85rem;
}

.activity-map {
  margin-bottom: 1.25rem;
}

.activity-map__months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  margin-left: 28px;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 300;
  line-height: 11px;
  white-space: nowrap;
  color: #78716c;
}

.activity-map__body {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.activity-map__weekdays {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  width: 22px;
  font-size: 0.68rem;
  font-weight: 300;
  line-height: 11px;
  color: #78716c;
  text-align: right;
}

.activity-map__grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 11px);
  grid-auto-columns: 11px;
  gap: 3px;
}

.activity-map__day {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text) 8%, var(--surface));
}

.activity-map__day--pad {
  background: transparent;
}

.activity-map__day[data-level="1"] {
  background: color-mix(in srgb, var(--primary) 25%, var(--surface));
}

.activity-map__day[data-level="2"] {
  background: color-mix(in srgb, var(--primary) 50%, var(--surface));
}

.activity-map__day[data-level="3"] {
  background: color-mix(in srgb, var(--primary) 75%, var(--surface));
}

.activity-map__day[data-level="4"] {
  background: var(--primary);
}

.activity-map__legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 300;
  color: #78716c;
}

.activity-map__legend .activity-map__day {
  width: 10px;
  height: 10px;
}

.date-range summary {
  cursor: pointer;
  color: var(--muted);
}

.date-range[open] {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-form input {
  flex: 1;
  min-width: 8rem;
}

#contact-name,
#contact-email,
#search-input {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

#search-input::placeholder {
  color: #78716c;
}

#sidebar-phone {
  color: #78716c;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.message-list {
  max-height: 26rem;
  overflow-y: auto;
  gap: 0;
}

.message {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.message:last-child {
  border-bottom: none;
}

.message__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.message__role {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--nav-hover);
  color: var(--text);
}

.message--assistant .message__role {
  background: var(--primary);
  color: #ffffff;
}

.message__timestamp {
  font-size: 0.85rem;
  font-weight: 300;
  color: #78716c;
}

.message__content {
  white-space: pre-wrap;
  font-weight: 300;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.message__image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  margin-top: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  object-fit: cover;
}

.message--highlighted {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-radius: 8px;
}

.tool-calls-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  overflow-x: auto;
}

.live-camera-view {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.live-camera-view__image {
  max-width: 100%;
  border-radius: 8px;
}

.voice-monitor-view {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 320px;
}

.voice-monitor-volume {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.voice-monitor-volume__label,
.voice-monitor-doa__label {
  font-size: 0.8rem;
  color: var(--muted);
}

.voice-monitor-volume__bar {
  width: 100%;
  height: 14px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}

.voice-monitor-volume__fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.15s ease-out;
}

.voice-monitor-volume__value,
.voice-monitor-doa__value {
  font-size: 0.9rem;
  color: var(--text);
  text-align: center;
}

.voice-monitor-doa {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.voice-monitor-doa__gauge {
  width: 100%;
  color: var(--primary);
}

.voice-monitor-doa__gauge #voice-monitor-doa-needle {
  transition: x2 0.15s ease-out, y2 0.15s ease-out;
}

.voice-monitor-doa__tick {
  font-size: 8px;
  fill: var(--muted);
  stroke: none;
}

.tool-calls-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.tool-calls-table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 0.82rem;
  line-height: 1.3;
  color: #78716c;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
  padding: 1rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tool-calls-table tbody td {
  padding: 1.1rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: left;
  color: var(--text);
  font-weight: 300;
}

.tool-calls-table tbody td.tool-calls-table__started,
.tool-calls-table tbody td.tool-calls-table__duration {
  color: #78716c;
  white-space: nowrap;
}

.tool-calls-table tbody tr:last-child td {
  border-bottom: none;
}

.tool-calls-table__tool {
  font-weight: 500;
  white-space: nowrap;
}

.tool-calls-table__prompt,
.tool-calls-table__result {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-calls-table__duration {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tool-calls-table__cost {
  min-width: 6.5rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tool-calls-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}

.tool-calls-status-pill--completed {
  border-color: #57a87740;
  background: #57a8771a;
  color: #3e7d59;
}

@media (prefers-color-scheme: dark) {
  .tool-calls-status-pill--completed {
    color: #6fbb8d;
  }
}

.tool-calls-status-pill--failed {
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.contact-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.contact-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-size: 0.92rem;
}

.contact-email {
  font-size: 0.85rem;
  color: var(--muted);
}

.contact-row .contact-email {
  color: #78716c;
}

/* ---------- settings / profile ---------- */

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-field dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.profile-field dd {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.profile-field__value {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-field__value--muted {
  color: #78716c;
  font-weight: 300;
  font-size: 0.85rem;
}

.profile-field__input {
  flex: 0 1 auto;
  width: 14rem;
  max-width: 60%;
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}

.google-connect {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.google-connect__label {
  font-weight: 500;
  margin-right: auto;
}

.google-connect__status {
  color: var(--muted);
  font-size: 0.9rem;
}

.proactive-brief {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.proactive-brief__label {
  font-weight: 500;
  flex-basis: 100%;
}

.proactive-brief #proactive-brief-topic {
  flex: 1 1 16rem;
}

.proactive-brief #proactive-brief-status {
  flex-basis: 100%;
  margin: 0;
}

.btn-danger {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  opacity: 1;
}
