:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d8dde6;
  --text: #111827;
  --muted: #667085;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --assistant: #ffffff;
  --user: #e8f3f1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "topbar"
    "language"
    "messages"
    "composer";
  height: 100vh;
  height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.language-switcher {
  grid-area: language;
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 12px 22px 0;
}

.language-switcher[hidden] {
  display: none;
}

.language-switcher button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 13px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
}

.language-switcher button:first-child {
  border-radius: 7px 0 0 7px;
}

.language-switcher button:last-child {
  margin-left: -1px;
  border-radius: 0 7px 7px 0;
}

.language-switcher button.selected {
  position: relative;
  border-color: var(--accent);
  background: #e8f3f1;
  color: var(--accent-strong);
  font-weight: 650;
}

.language-switcher button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar button,
.composer button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}

.topbar button {
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.topbar button:hover,
.composer button:hover {
  background: var(--accent-strong);
}

.messages {
  grid-area: messages;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 22px;
}

.message {
  display: flex;
  margin: 0 0 16px;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(720px, 84%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--assistant);
  line-height: 1.45;
  white-space: pre-wrap;
}

.user .bubble {
  background: var(--user);
  border-color: #c8dfda;
}

.lead-form,
.calendly-embed {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.lead-form-title {
  font-weight: 650;
}

.lead-form label {
  display: grid;
  gap: 5px;
}

.lead-form span {
  color: var(--muted);
  font-size: 13px;
}

.lead-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  outline: none;
}

.lead-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 15%);
}

.lead-form button {
  justify-self: start;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}

.lead-form button:disabled,
.lead-form input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.lead-form-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.calendly-embed iframe {
  width: min(100%, 640px);
  height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.calendly-embed a {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 650;
}

.processing .bubble {
  color: var(--muted);
  position: relative;
}

.processing .bubble::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 4px;
  margin-left: 8px;
  border-radius: 999px;
  background: currentColor;
  vertical-align: middle;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }

  50% {
    opacity: 0.8;
  }
}

.composer {
  grid-area: composer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

textarea {
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  line-height: 1.4;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 15%);
}

.composer button {
  width: 76px;
  min-height: 44px;
}

.composer button:disabled,
.topbar button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 640px) {
  .shell {
    border: 0;
  }

  .topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .topbar button {
    padding: 0 10px;
    font-size: 13px;
  }

  .messages {
    padding: 18px 14px;
  }

  .bubble {
    max-width: 92%;
  }

  .composer {
    padding: 12px 14px 14px;
    gap: 8px;
  }
}

.admin-body {
  min-height: 100%;
}

.admin-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--panel);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.admin-topbar button,
.admin-login button,
.lead-list-header button,
.process-form button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
}

.admin-topbar button,
.lead-list-header button,
.process-form button {
  min-height: 36px;
  padding: 0 13px;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-actions[hidden] {
  display: none;
}

.admin-actions button.selected {
  border-color: var(--accent);
  background: #e8f3f1;
  color: var(--accent-strong);
}

.admin-login {
  display: grid;
  place-items: start center;
  padding: 48px 18px;
}

.admin-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.admin-card h2,
.lead-detail h2,
.lead-detail h3 {
  margin: 0;
}

.admin-card label,
.process-form label {
  display: grid;
  gap: 6px;
}

.admin-card span,
.process-form span {
  color: var(--muted);
  font-size: 13px;
}

.admin-card input,
.process-form select,
.process-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  outline: none;
}

.admin-card input:focus,
.process-form select:focus,
.process-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 15%);
}

.admin-card button {
  min-height: 40px;
}

.admin-error {
  min-height: 18px;
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: calc(100vh - 76px);
}

.lead-list {
  border-right: 1px solid var(--line);
  min-width: 0;
}

.lead-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.lead-row {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.lead-row:hover,
.lead-row.selected {
  background: #f6f7f9;
}

.lead-row-main {
  color: var(--text);
  font-weight: 650;
}

.lead-status {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 650;
}

.lead-status.qualified,
.lead-status.contacted {
  background: #e8f3f1;
  color: var(--accent-strong);
}

.lead-status.closed {
  background: #ecfdf3;
  color: #027a48;
}

.lead-status.rejected {
  background: #fef3f2;
  color: #b42318;
}

.lead-status.active,
.lead-status.completed {
  background: #eef2f6;
  color: #344054;
}

.lead-status.converted {
  background: #ecfdf3;
  color: #027a48;
}

.lead-status.error,
.lead-status.abandoned,
.lead-status.dropoff {
  background: #fef3f2;
  color: #b42318;
}

.lead-detail {
  display: grid;
  align-content: start;
  gap: 22px;
  min-width: 0;
  padding: 22px;
  overflow: auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.detail-header p,
.detail-grid p,
.empty-detail {
  margin: 5px 0 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.detail-grid > div,
.process-form,
.transcript,
.lead-detail pre {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.detail-grid > div {
  padding: 12px;
}

.process-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.process-form textarea {
  min-height: 110px;
  resize: vertical;
}

.process-form p {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.transcript {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.transcript-message {
  display: grid;
  gap: 5px;
}

.transcript-message p {
  margin: 0;
  white-space: pre-wrap;
}

.transcript-message small {
  color: var(--muted);
  font-size: 11px;
}

.transcript-message.user p {
  color: var(--accent-strong);
}

.lead-detail pre {
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .admin-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions {
    flex-wrap: wrap;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .lead-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}
