/* Buttons */
.primary-button,
.secondary-button,
.ghost-button,
.auth-tab,
.session-delete,
.suggestion-button,
.action-button,
.inline-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 500;
  transition: transform 140ms ease, background 200ms ease, border-color 200ms ease, opacity 140ms ease, box-shadow 200ms ease;
}

.primary-button,
.secondary-button,
.ghost-button,
.auth-tab,
.session-delete,
.suggestion-button,
.action-button {
  padding: 10px 20px;
}

.primary-button {
  border: 0;
  color: #ffffff;
  font-weight: 600;
  background: var(--primary);
  box-shadow: var(--shadow-sm);
}

.secondary-button,
.ghost-button,
.auth-tab,
.session-delete,
.suggestion-button,
.action-button,
.inline-link-button {
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: var(--bg);
}

.ghost-button {
  background: transparent;
  border-color: transparent;
}

.primary-button:hover {
  transform: translateY(-2px);
  background: var(--primary-strong);
  box-shadow: 0 6px 20px rgba(91, 164, 182, 0.25);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.secondary-button:hover,
.ghost-button:hover,
.auth-tab:hover,
.session-delete:hover,
.suggestion-button:hover,
.action-button:hover,
.inline-link-button:hover {
  transform: translateY(-2px);
  background: var(--surface);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.secondary-button:active,
.ghost-button:active,
.suggestion-button:active,
.action-button:active,
.inline-link-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled,
.session-delete:disabled,
.suggestion-button:disabled,
.action-button:disabled {
  cursor: default;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.inline-link-button {
  margin-top: 14px;
  padding: 10px 16px;
  min-width: 0;
}

/* App Boot Overlay */
.app-boot-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 220;
}

.app-boot-card {
  width: min(400px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 36px 30px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-xl);
  text-align: center;
}

.app-boot-logo {
  width: 64px;
  height: 64px;
}

.app-boot-title {
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-strong);
}

.app-boot-copy {
  max-width: 30ch;
  color: var(--muted);
  line-height: 1.6;
}

.app-boot-dots {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.app-boot-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
  animation: pendingPulse 1s ease-in-out infinite;
}

.app-boot-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.app-boot-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

/* Sessions */
.session-list {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
  padding-bottom: 8px;
  overscroll-behavior: contain;
}

.session-empty {
  color: var(--muted);
  line-height: 1.7;
}

.session-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
}

.session-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background 200ms ease, border-color 200ms ease;
}

.session-button:hover {
  transform: none;
}

.session-row.active .session-button,
.session-button:hover {
  border-color: var(--border);
  background: var(--surface);
}

.session-title,
.session-preview,
.session-time {
  display: block;
}

.session-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-strong);
}

.session-preview {
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.session-time {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.session-delete {
  min-width: 32px;
  min-height: 32px;
  padding: 0 8px;
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 200ms ease, background 200ms ease;
}

.session-row:hover .session-delete,
.session-row:focus-within .session-delete {
  opacity: 1;
}

@media (max-width: 1080px) {
  .session-delete {
    opacity: 0.6;
  }
}

/* Home Panel / Cards */
.home-panel {
  width: min(960px, 100%);
  padding: 48px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transition: box-shadow 300ms ease, transform 300ms ease;
}

.home-panel:hover {
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.08);
}

.home-panel h1 {
  margin-top: 10px;
  font-size: clamp(36px, 4.5vw, 56px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--text-strong);
}

.home-copy {
  max-width: 600px;
  margin-top: 12px;
  font-size: 16px;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.starter-card {
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: inherit;
  text-align: left;
  transition: transform 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}

.starter-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(91, 164, 182, 0.15);
}

.starter-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.starter-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  transition: background 200ms ease;
}

.starter-card:hover .starter-icon {
  background: rgba(91, 164, 182, 0.18);
}

.starter-title {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
}

.starter-copy {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13.5px;
}

/* Empty Chat */
.empty-chat-state {
  width: min(680px, 100%);
  text-align: center;
}

.empty-chat-illustration {
  margin-bottom: 8px;
}

.empty-chat-eyebrow {
  color: var(--primary-strong);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 600;
}

.empty-chat-title {
  margin-top: 10px;
  font-size: clamp(28px, 3.6vw, 44px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-strong);
}

.empty-chat-copy {
  width: min(540px, 100%);
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

/* Conversation Summary */
.conversation-summary {
  flex-shrink: 0;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

.summary-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
}

.summary-toggle:hover {
  transform: none;
  border-color: var(--border-strong);
  background: var(--surface);
}

.summary-toggle-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.summary-toggle-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.45;
}

.summary-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.summary-toggle-icon::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 180ms ease;
}

.summary-toggle[aria-expanded="true"] .summary-toggle-icon {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.summary-toggle[aria-expanded="true"] .summary-toggle-icon::before {
  transform: rotate(-135deg) translateX(-1px);
}

.summary-toggle[aria-expanded="true"] {
  border-color: var(--primary);
}

.summary-toggle:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.summary-toggle:focus-visible .summary-toggle-icon {
  border-color: var(--primary);
}

.summary-toggle .section-label {
  font-size: 10px;
}

.summary-toggle-preview,
.summary-value {
  overflow-wrap: anywhere;
}

.conversation-summary-body {
  padding: 10px 4px 4px;
}

.conversation-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.summary-item {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.summary-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10px;
  font-weight: 600;
}

.summary-value {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  color: var(--text-strong);
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--text);
}

.chat-header-actions .ghost-button {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  color: var(--danger);
}

.chat-header-actions .ghost-button:hover {
  background: rgba(245, 101, 101, 0.08);
  border-color: rgba(245, 101, 101, 0.3);
}

.status-pill[data-state="quotes"] {
  border-color: rgba(66, 153, 225, 0.3);
  background: rgba(66, 153, 225, 0.08);
  color: #2b6cb0;
}

.status-pill[data-state="payment"] {
  border-color: rgba(237, 137, 54, 0.3);
  background: rgba(237, 137, 54, 0.08);
  color: #c05621;
}

.status-pill[data-state="confirmed"] {
  border-color: rgba(72, 187, 120, 0.3);
  background: rgba(72, 187, 120, 0.08);
  color: #276749;
}

.status-pill[data-state="complete"] {
  border-color: rgba(66, 153, 225, 0.3);
  background: rgba(66, 153, 225, 0.08);
  color: #2b6cb0;
}

/* Message List & Bubbles */
.message-list {
  flex: 1 0 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 8px 18px 6px;
}

.message-list > :first-child {
  margin-top: auto;
}

.message {
  position: relative;
  flex: 0 0 auto;
  width: fit-content;
  max-width: min(720px, 82%);
  animation: slideFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.message.user {
  align-self: flex-end;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, #5BA4B6, #4A8FA0);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(91, 164, 182, 0.2);
}

.message.assistant.type-chat {
  align-self: flex-start;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--text);
}

.message-card,
.message-empty,
.message-loading {
  align-self: stretch;
  flex: 0 0 auto;
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
}

.message-loading {
  color: var(--muted);
}

.type-quote {
  border-color: rgba(66, 153, 225, 0.2);
  background: rgba(66, 153, 225, 0.04);
}

.type-payment {
  border-color: rgba(237, 137, 54, 0.2);
  background: rgba(237, 137, 54, 0.04);
}

.type-status {
  border-color: rgba(72, 187, 120, 0.2);
  background: rgba(72, 187, 120, 0.04);
}

.type-technician_update,
.type-relay_confirmation {
  border-color: rgba(91, 164, 182, 0.2);
  background: rgba(91, 164, 182, 0.04);
}

.message-card-label {
  margin-bottom: 8px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10.5px;
  font-weight: 600;
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.message.user .message-meta {
  color: rgba(255, 255, 255, 0.7);
}

.message.pending::after {
  content: none;
}

.pending-body {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.pending-label {
  color: var(--text);
}

.pending-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pending-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
  animation: pendingPulse 1s ease-in-out infinite;
}

.pending-dots span:nth-child(2) {
  animation-delay: 0.18s;
}

.pending-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

/* Composer */
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  box-shadow: var(--shadow-md);
}

.chat-view.is-empty .composer {
  width: min(720px, 100%);
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
}

.chat-view.is-empty .composer-input-wrap {
  gap: 0;
  padding: 0;
}

.chat-view.is-empty .composer textarea {
  min-height: 28px;
  max-height: 140px;
  padding: 10px 12px;
}

.chat-view.is-empty .composer-meta {
  display: none;
}

.chat-view.is-empty .composer-button {
  min-width: 84px;
  min-height: 44px;
}

.composer-input-wrap {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 2px 2px 0;
}

.composer textarea {
  min-height: 48px;
  max-height: 180px;
  resize: none;
  border-radius: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 10px 14px 0;
  font-size: 15px;
  line-height: 1.6;
}
.composer textarea:focus {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 14px 4px;
}

.composer-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.composer-button {
  min-width: 88px;
  min-height: 46px;
  padding: 0 20px;
  font-size: 14px;
  border-radius: 8px;
}

/* Sidebar Rails / Action Cards */
.action-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.suggestions-card {
  flex: 1 1 300px;
  min-height: 260px;
}

.actions-card {
  flex: 1 1 0;
  min-height: 180px;
}

.suggestion-list,
.quick-actions {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 8px;
  overscroll-behavior: contain;
}

.suggestion-button,
.action-button {
  justify-content: flex-start;
  width: 100%;
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  line-height: 1.5;
}

.suggestion-button {
  background: var(--bg-deep);
}

.action-button[data-variant="primary"] {
  border: 0;
  color: #ffffff;
  font-weight: 600;
  background: var(--primary);
}

.action-button[data-variant="warning"] {
  border-color: rgba(237, 137, 54, 0.3);
  background: rgba(237, 137, 54, 0.06);
}

.action-button[data-variant="success"] {
  border-color: rgba(72, 187, 120, 0.3);
  background: rgba(72, 187, 120, 0.06);
}

.action-button[data-variant="danger"] {
  border-color: rgba(245, 101, 101, 0.3);
  background: rgba(245, 101, 101, 0.06);
}

.action-empty {
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

/* Payment Banner */
.payment-banner {
  flex-shrink: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

.payment-banner[data-kind="success"] {
  border-color: rgba(72, 187, 120, 0.3);
  background: rgba(72, 187, 120, 0.06);
}

.payment-banner[data-kind="cancel"] {
  border-color: rgba(237, 137, 54, 0.3);
  background: rgba(237, 137, 54, 0.06);
}

/* Account Launcher Bottom Right */
.account-launcher {
  position: fixed;
  left: 16px;
  right: auto;
  bottom: 16px;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: calc(var(--sidebar-width) - 32px);
  min-width: 0;
  max-width: none;
  min-height: var(--account-launcher-height);
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  text-align: left;
  font-weight: 500;
}

.account-launcher:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: var(--shadow-xl);
}

@media (max-width: 1080px) {
  .home-grid {
    grid-template-columns: 1fr;
  }

  /* Hide fixed launcher on mobile — account accessible via top bar */
  .account-launcher {
    display: none;
  }

}

@media (max-width: 720px) {
  .empty-chat-title {
    font-size: 28px;
  }

  .empty-chat-copy {
    font-size: 13px;
  }

  /* Compact composer */
  .composer {
    padding: 8px;
    border-radius: 14px;
    gap: 8px;
  }

  .composer textarea {
    min-height: 40px;
    padding: 8px 12px 0;
    font-size: 16px;
  }

  .composer-meta {
    padding: 0 10px 4px;
  }

  .composer-hint {
    font-size: 11px;
  }

  .composer-button {
    min-width: 68px;
    min-height: 40px;
    padding: 0 14px;
    font-size: 13px;
  }

  .summary-toggle-preview {
    white-space: normal;
  }

  .status-pill,
  .chat-header-actions .ghost-button {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 12px;
  }

  /* Compact messages */
  .message.user {
    padding: 10px 14px;
    border-radius: 16px;
    border-bottom-right-radius: 5px;
  }

  .message.assistant.type-chat {
    padding: 10px 14px;
    border-radius: 16px;
    border-bottom-left-radius: 5px;
  }

  .message-card,
  .message-empty,
  .message-loading {
    padding: 12px 14px;
    border-radius: 14px;
  }

  .message-body {
    font-size: 14px;
    line-height: 1.6;
  }

  .message-list {
    gap: 10px;
    padding: 8px 4px 12px 4px;
  }

  /* Compact conversation summary */
  .conversation-summary {
    padding: 6px;
    border-radius: 14px;
  }

  .summary-toggle {
    padding: 10px 12px;
    border-radius: 10px;
    gap: 10px;
  }

  .summary-toggle-icon {
    width: 26px;
    height: 26px;
  }

  .conversation-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .summary-item {
    padding: 10px 12px;
    border-radius: 10px;
  }

  /* Compact home panel */
  .home-panel {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .home-panel h1 {
    font-size: 30px;
  }

  .home-copy {
    font-size: 14px;
  }

  .home-actions,
  .profile-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .starter-card {
    padding: 14px;
    border-radius: 10px;
  }

  .starter-title {
    font-size: 14px;
    margin-bottom: 4px;
  }

  .starter-copy {
    font-size: 13px;
  }

}

/* Animations */
@keyframes pendingPulse {
  0%, 80%, 100% { transform: scale(0.72); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

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