/* ═══════════════════════════════════════════════════════════════
   Chat Dashboard — Lumen AI Interface
   High-contrast, accessible design with proper tier gating
   ═══════════════════════════════════════════════════════════════ */

.chat-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: clamp(38rem, 72vh, 56rem);
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgb(59 130 246 / 10%), transparent 22%), linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

/* ── Tier Gate Banner ───────────────────────────────────────── */
.tier-gate-banner {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2744 100%);
  padding: 2rem 1.5rem;
  border-block-end: 3px solid #f59e0b; /* Amber warning */
}

.tier-gate-banner__inner {
  max-width: 900px;
  margin-inline: auto;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tier-gate-banner__inner svg {
  color: #fbbf24; /* Amber-400 */
  flex-shrink: 0;
}

.tier-gate-banner__content {
  flex: 1;
}

.tier-gate-banner__content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.5rem;
}

.tier-gate-banner__content p {
  font-size: 1rem;
  color: #e2e8f0; /* Slate-200 */
  margin: 0 0 1rem;
  line-height: 1.6;
}

.tier-gate-banner__btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: #f59e0b; /* Amber-500 */
  color: #1e293b; /* Slate-800 */
  font-weight: 700;
  text-decoration: none;
  border-radius: 0.5rem;
  transition:
    background 200ms ease,
    transform 200ms ease;
}

.tier-gate-banner__btn:hover {
  background: #fbbf24; /* Amber-400 */
  transform: translateY(-1px);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.chat-sidebar {
  background: rgb(255 255 255 / 88%);
  border-inline-end: 1px solid #e5e7eb; /* Gray-200 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.chat-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-block-end: 1px solid #e5e7eb;
  background: rgb(248 250 252 / 82%);
}

.chat-sidebar__title {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937; /* Gray-800 */
  margin: 0;
}

.chat-sidebar__new {
  width: 32px;
  height: 32px;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db; /* Gray-300 */
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #4b5563; /* Gray-600 */
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.chat-sidebar__new:hover {
  background: #f3f4f6; /* Gray-100 */
  border-color: #3b82f6; /* Primary-500 */
  color: #2563eb; /* Primary-600 */
}

.chat-form {
  padding: 1rem 1.25rem;
  border-block-end: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgb(248 250 252 / 82%);
}

.chat-form .auth-input {
  padding: 0.625rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: #fff;
  color: #1f2937;
}

.chat-form .auth-input::placeholder {
  color: #9ca3af;
}

.chat-form .auth-btn--sm {
  padding: 0.5rem 1rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-form .auth-btn--sm:hover {
  background: #1d4ed8;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
  background: transparent;
}

.chat-list__item {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  margin-block-end: 0.375rem;
  transition:
    background 150ms ease,
    border-color 150ms ease;
  border: 1px solid transparent;
}

.chat-list__item:hover {
  background: #f3f4f6;
  border-color: #e5e7eb;
}

.chat-list__item[aria-current="true"] {
  background: #eff6ff; /* Primary-50 */
  border-color: #3b82f6;
  color: #1e40af; /* Primary-800 */
}

.chat-list__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
  line-height: 1.4;
}

.chat-list__meta {
  font-size: 0.75rem;
  color: #6b7280; /* Gray-500 */
  margin-block-start: 0.25rem;
}

.chat-list__empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

.chat-sidebar__footer {
  padding: 1rem 1.25rem;
  border-block-start: 1px solid #e5e7eb;
  background: rgb(248 250 252 / 82%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-usage {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: #4b5563;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
}

.chat-usage__label {
  color: #6b7280;
}

.chat-usage__count {
  font-weight: 700;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

.chat-tier-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
}

.chat-tier-info__label {
  color: #6b7280;
}

.chat-tier-info__badge {
  padding: 0.25rem 0.625rem;
  background: #dbeafe; /* Primary-100 */
  color: #1e40af; /* Primary-800 */
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-sidebar__upgrade {
  display: block;
  text-align: center;
  padding: 0.625rem 1rem;
  border-radius: 0.375rem;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  box-shadow: 0 1px 2px rgb(37 99 235 / 20%);
  transition:
    background 200ms ease,
    transform 200ms ease,
    box-shadow 200ms ease;
}

.chat-sidebar__upgrade:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgb(37 99 235 / 30%);
}

/* ── Main Chat Area ─────────────────────────────────────────── */
.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

.chat-empty {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 3.5rem 2rem;
  max-width: 900px;
  margin-inline: auto;
}

.chat-empty__visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 1.5rem;
}

.chat-empty__icon {
  color: #2563eb; /* Primary-600 */
  filter: drop-shadow(0 2px 4px rgb(37 99 235 / 20%));
}

.chat-empty__badge {
  padding: 0.375rem 0.875rem;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 4px rgb(37 99 235 / 30%);
}

.chat-empty__title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 0.75rem;
  line-height: 1.3;
}

.chat-empty__desc {
  font-size: 1rem;
  color: #4b5563;
  margin: 0 0 2.5rem;
  max-width: 70ch;
  line-height: 1.7;
}

.chat-suggestions {
  width: 100%;
}

.chat-suggestions__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-suggestions__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.chat-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  background: #fff;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 200ms ease,
    background 200ms ease,
    box-shadow 200ms ease,
    transform 200ms ease;
  position: relative;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}

.chat-suggestion:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 4px 8px rgb(37 99 235 / 15%);
  transform: translateY(-2px);
}

.chat-suggestion svg {
  flex-shrink: 0;
  color: #2563eb;
  margin-block-start: 0.125rem;
}

.chat-suggestion__content {
  flex: 1;
  min-width: 0;
}

.chat-suggestion__label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1f2937;
  margin-block-end: 0.25rem;
  line-height: 1.4;
}

.chat-suggestion__meta {
  display: block;
  font-size: 0.8125rem;
  color: #6b7280;
  line-height: 1.5;
}

.chat-suggestion__tier-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.chat-suggestion__tier-badge--starter {
  background: #dbeafe;
  color: #1e40af;
}

.chat-suggestion__tier-badge--core {
  background: #fef3c7;
  color: #92400e;
}

.chat-suggestion__tier-badge--complete {
  background: #dcfce7;
  color: #166534;
}

/* Info Card - Lumen */
.info-card--lumen {
  background: #eff6ff; /* Primary-50 */
  border: 1px solid #bfdbfe; /* Primary-200 */
  border-inline-start: 4px solid #2563eb;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
}

.info-card--lumen .info-card__icon {
  color: #2563eb;
  flex-shrink: 0;
  margin-block-start: 0.125rem;
}

.info-card--lumen .info-card__body {
  font-size: 0.875rem;
  color: #1e40af; /* Primary-800 */
  line-height: 1.6;
  margin: 0;
}

.info-card--lumen .info-card__body strong {
  color: #1e3a5f;
}

/* ── Conversation View ──────────────────────────────────────── */
.chat-conversation {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-conversation__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-block-end: 1px solid #e5e7eb;
  background: rgb(255 255 255 / 84%);
  backdrop-filter: blur(12px);
}

.chat-conversation__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.chat-conversation__actions {
  display: flex;
  gap: 0.5rem;
}

.chat-btn {
  width: 36px;
  height: 36px;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #4b5563;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.chat-btn:hover {
  background: #f3f4f6;
  border-color: #3b82f6;
  color: #2563eb;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background:
    radial-gradient(circle at top, rgb(219 234 254 / 55%), transparent 30%),
    linear-gradient(180deg, rgb(248 250 252 / 70%), rgb(241 245 249 / 70%));
}

.chat-message {
  display: flex;
  gap: 1rem;
  max-width: 900px;
}

.chat-message--user {
  margin-inline-start: auto;
  flex-direction: row-reverse;
}

.chat-message__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #dbeafe;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #1e40af;
}

.chat-message--user .chat-message__avatar {
  background: #e5e7eb;
  color: #374151;
}

.chat-message__content {
  flex: 1;
  max-width: 700px;
}

.chat-message__text {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: #1f2937;
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%);
}

.chat-message--user .chat-message__text {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border-color: #2563eb;
}

.chat-message__meta {
  font-size: 0.75rem;
  color: #6b7280;
  margin-block-start: 0.5rem;
  display: flex;
  gap: 1rem;
}

.chat-message--user .chat-message__meta {
  justify-content: flex-end;
  color: #93c5fd;
}

.chat-message__citation {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  background: #f3f4f6;
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.chat-message__citation svg {
  width: 12px;
  height: 12px;
}

/* ── Input Area ─────────────────────────────────────────────── */
.chat-input-area {
  border-block-start: 1px solid #e5e7eb;
  background: rgb(255 255 255 / 84%);
  padding: 1.25rem 2rem;
  backdrop-filter: blur(12px);
}

.chat-input-form {
  display: flex;
  gap: 0.75rem;
  max-width: 900px;
  margin-inline: auto;
}

.chat-input {
  flex: 1;
  padding: 0.875rem 1.125rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  background: #fff;
  color: #1f2937;
  line-height: 1.5;
}

.chat-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgb(59 130 246 / 15%);
}

.chat-input::placeholder {
  color: #9ca3af;
}

.chat-submit {
  width: 52px;
  height: 52px;
  border-radius: 0.5rem;
  border: none;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background 200ms ease,
    transform 200ms ease,
    box-shadow 200ms ease;
  box-shadow: 0 2px 4px rgb(37 99 235 / 20%);
}

.chat-submit:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgb(37 99 235 / 30%);
}

.chat-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-input__meta {
  display: flex;
  justify-content: space-between;
  max-width: 900px;
  margin-inline: auto;
  margin-block-start: 0.625rem;
  font-size: 0.8125rem;
  color: #6b7280;
}

.chat-input__mode {
  font-weight: 600;
  color: #2563eb;
}

.chat-input__grounding {
  color: #4b5563;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (width <= 1024px) {
  .chat-shell {
    grid-template-columns: 280px 1fr;
  }

  .chat-suggestions__grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (width <= 768px) {
  .chat-shell {
    grid-template-columns: 1fr;
  }

  .chat-sidebar {
    display: none;
  }

  .chat-conversation__header {
    padding: 1rem 1.25rem;
  }

  .chat-messages {
    padding: 1.25rem;
  }

  .chat-input-area {
    padding: 1rem 1.25rem;
  }

  .chat-suggestions__grid {
    grid-template-columns: 1fr;
  }

  .tier-gate-banner {
    padding: 1.5rem 1rem;
  }

  .tier-gate-banner__inner {
    flex-direction: column;
    gap: 1rem;
  }

  .chat-empty {
    padding: 2rem 1.25rem;
  }

  .chat-empty__title {
    font-size: 1.5rem;
  }

  .chat-empty__desc {
    font-size: 0.9375rem;
  }
}

/* ── Accessibility ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .chat-suggestion,
  .chat-submit,
  .chat-sidebar__upgrade,
  .chat-btn {
    transition: none;
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .chat-suggestion {
    border-width: 2px;
  }

  .chat-message__text {
    border-width: 2px;
  }

  .chat-input {
    border-width: 2px;
  }
}
