/* VentaAI / Diloo Design System */

:root {
  /* Surfaces */
  --ds-surface: #f8f9fa;
  --ds-surface-dim: #d9dadb;
  --ds-surface-bright: #f8f9fa;
  --ds-surface-container-lowest: #ffffff;
  --ds-surface-container-low: #f3f4f5;
  --ds-surface-container: #edeeef;
  --ds-surface-container-high: #e7e8e9;
  --ds-surface-container-highest: #e1e3e4;
  --ds-neutral: #ffffff;
  --ds-on-neutral: #191c1d;

  /* Content */
  --ds-on-surface: #191c1d;
  --ds-on-surface-variant: #424655;
  --ds-on-background: #191c1d;
  --ds-inverse-surface: #2e3132;
  --ds-inverse-on-surface: #f0f1f2;

  /* Borders & outlines */
  --ds-outline: #727787;
  --ds-outline-variant: #c2c6d8;
  --ds-border: #dee2e6;
  --ds-input-border: #ced4da;

  /* Brand colors */
  --ds-primary: #0d6efd;
  --ds-primary-dark: #0b5ed7;
  --ds-on-primary: #ffffff;
  --ds-primary-container: #0d6efd;
  --ds-primary-tint: #0057ce;
  --ds-inverse-primary: #b1c5ff;

  --ds-secondary: #575f67;
  --ds-on-secondary: #ffffff;
  --ds-secondary-container: #d8e1ea;
  --ds-on-secondary-container: #5b646b;
  --ds-secondary-muted: #6c757d;

  --ds-tertiary: #a63b00;
  --ds-on-tertiary: #ffffff;
  --ds-tertiary-container: #cf4b00;

  --ds-success: #198754;
  --ds-success-dark: #157347;
  --ds-on-success: #ffffff;

  --ds-error: #ba1a1a;
  --ds-on-error: #ffffff;
  --ds-error-container: #ffdad6;
  --ds-on-error-container: #93000a;

  --ds-label-color: #495057;

  /* Elevation */
  --ds-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --ds-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --ds-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.08);

  /* Radius */
  --ds-radius-sm: 0.125rem;
  --ds-radius: 0.25rem;
  --ds-radius-md: 0.375rem;
  --ds-radius-lg: 0.5rem;
  --ds-radius-xl: 0.75rem;
  --ds-radius-full: 9999px;

  /* Spacing (8px base) */
  --ds-space-xs: 4px;
  --ds-space-sm: 12px;
  --ds-space-base: 8px;
  --ds-space-md: 24px;
  --ds-space-lg: 48px;
  --ds-space-xl: 80px;
  --ds-container-max: 1200px;
  --ds-gutter: 24px;

  /* Bootstrap overrides */
  --bs-body-font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bs-body-color: var(--ds-on-surface);
  --bs-body-bg: var(--ds-surface);
  --bs-primary: var(--ds-primary);
  --bs-primary-rgb: 13, 110, 253;
  --bs-secondary: var(--ds-secondary-muted);
  --bs-secondary-rgb: 108, 117, 125;
  --bs-success: var(--ds-success);
  --bs-success-rgb: 25, 135, 84;
  --bs-danger: var(--ds-error);
  --bs-danger-rgb: 186, 26, 26;
  --bs-border-color: var(--ds-border);
  --bs-border-radius: var(--ds-radius);
  --bs-border-radius-sm: var(--ds-radius-sm);
  --bs-border-radius-lg: var(--ds-radius-lg);
  --bs-border-radius-xl: var(--ds-radius-xl);
  --bs-link-color: var(--ds-primary);
  --bs-link-hover-color: var(--ds-primary-dark);
}

/* Typography */
body {
  font-family: var(--bs-body-font-family);
  color: var(--ds-on-surface);
  background-color: var(--ds-surface);
  -webkit-font-smoothing: antialiased;
}

.ds-display-lg {
  font-family: var(--bs-body-font-family);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ds-on-surface);
}

@media (min-width: 768px) {
  .ds-display-lg {
    font-size: 3rem;
    line-height: 1.2;
  }
}

.ds-headline-md {
  font-family: var(--bs-body-font-family);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ds-on-surface);
}

@media (min-width: 768px) {
  .ds-headline-md {
    font-size: 2rem;
  }
}

.ds-title-lg {
  font-family: var(--bs-body-font-family);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ds-on-surface);
}

.ds-body-lg {
  font-family: var(--bs-body-font-family);
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--ds-on-surface-variant);
}

.ds-body-md {
  font-family: var(--bs-body-font-family);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ds-on-surface-variant);
}

.ds-label-sm {
  font-family: var(--bs-body-font-family);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--ds-label-color);
}

.ds-text-muted {
  color: var(--ds-secondary-muted) !important;
}

.ds-metric-value {
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ds-on-surface);
}

/* Material Symbols Rounded */
.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* Layout */
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.admin-layout {
  height: 100vh;
  overflow: hidden;
}

.admin-sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--ds-neutral);
  color: var(--ds-on-surface);
  border-right: 1px solid var(--ds-border);
}

.admin-main {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background-color: var(--ds-surface);
}

.admin-content {
  min-height: 0;
  overflow-y: auto;
  padding-top: var(--ds-space-md);
  padding-bottom: var(--ds-space-md);
}

@media (max-width: 767.98px) {
  .admin-content {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.admin-content--fill {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding-bottom: 0;
}

.admin-content--fill > .conversation-detail-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-layout--guest {
  width: 100%;
}

.admin-main--guest {
  width: 100%;
}

.admin-content--login {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.login-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.login-page__header {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding-top: var(--ds-space-lg);
  padding-bottom: var(--ds-space-md);
}

.login-page__logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: min(100%, 180px);
}

.login-page__body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-md);
}

.login-page__form-col {
  width: 100%;
  max-width: 420px;
  transform: translateY(-5vh);
}

.ds-page-header {
  margin-bottom: var(--ds-space-md);
}

.ds-page-header .ds-body-md {
  margin-bottom: 0;
}

.ds-page-header .alert {
  margin-top: var(--ds-space-sm);
  margin-bottom: 0;
}

.ds-help-tip {
  font-size: 1rem;
  line-height: 1;
  vertical-align: middle;
  color: var(--ds-secondary-muted);
  cursor: help;
  user-select: none;
}

.ds-help-tip:hover,
.ds-help-tip:focus {
  color: var(--ds-primary);
  outline: none;
}

.ds-help-tip:focus-visible {
  outline: 2px solid var(--ds-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Sidebar */
.sidebar-brand {
  display: block;
  text-decoration: none;
}

.sidebar-brand:hover {
  opacity: 0.9;
}

.sidebar-logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 100%;
}

.sidebar-divider {
  border-color: var(--ds-border);
  opacity: 1;
}

.sidebar-nav .nav-link {
  color: var(--ds-on-surface);
  border-radius: var(--ds-radius);
  padding: var(--ds-space-sm) var(--ds-space-base);
  margin-bottom: var(--ds-space-xs);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link .material-symbols-rounded {
  font-size: 1.25rem;
  color: var(--ds-primary);
}

.sidebar-nav .nav-link:hover {
  color: var(--ds-on-surface);
  background-color: rgba(13, 110, 253, 0.08);
}

.sidebar-nav .nav-link.active {
  color: var(--ds-neutral);
  background-color: var(--ds-primary);
}

.sidebar-nav .nav-link.active .material-symbols-rounded {
  color: var(--ds-neutral);
}

.sidebar-tenant-section .ds-label-sm {
  color: var(--ds-on-surface);
}

.sidebar-tenant-item {
  background-color: transparent;
  color: var(--ds-on-surface);
  border-color: var(--ds-border) !important;
  border-radius: var(--ds-radius);
  font-size: 0.875rem;
}

.sidebar-tenant-item:hover {
  background-color: rgba(13, 110, 253, 0.08);
  color: var(--ds-on-surface);
}

.sidebar-tenant-item.active {
  background-color: var(--ds-primary);
  color: var(--ds-neutral);
  border-color: var(--ds-primary) !important;
}

.sidebar-user-panel {
  background-color: var(--ds-surface-container-low);
  border-radius: var(--ds-radius-lg);
  color: var(--ds-secondary-muted);
}

.sidebar-user-panel .ds-label-sm,
.sidebar-user-panel .material-symbols-rounded {
  color: var(--ds-secondary-muted);
}

.sidebar-user-panel .sidebar-user-email {
  color: var(--ds-on-surface);
}

.sidebar-user-panel .btn-outline-secondary {
  border-color: var(--ds-border);
  color: var(--ds-secondary-muted);
  border-radius: var(--ds-radius);
}

.sidebar-user-panel .btn-outline-secondary:hover,
.sidebar-user-panel .btn-outline-secondary.active {
  background-color: var(--ds-neutral);
  border-color: var(--ds-secondary-muted);
  color: var(--ds-on-surface);
}

/* Cards */
.ds-card {
  background-color: var(--ds-surface-container-lowest);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-sm);
  transition: box-shadow 0.2s ease;
}

.ds-card:hover {
  box-shadow: var(--ds-shadow);
}

.ds-card .card-body {
  padding: var(--ds-space-md);
}

.ds-card--interactive:hover {
  box-shadow: var(--ds-shadow-hover);
}

/* Buttons */
.btn {
  border-radius: var(--ds-radius);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background-color: var(--ds-primary);
  border-color: var(--ds-primary);
  color: var(--ds-on-primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--ds-primary-dark);
  border-color: var(--ds-primary-dark);
  color: var(--ds-on-primary);
}

.btn-success {
  background-color: var(--ds-success);
  border-color: var(--ds-success);
  color: var(--ds-on-success);
}

.btn-success:hover,
.btn-success:focus {
  background-color: var(--ds-success-dark);
  border-color: var(--ds-success-dark);
  color: var(--ds-on-success);
}

.btn-lg,
.btn-primary.btn-lg {
  min-height: 48px;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
}

.btn-outline-primary {
  color: var(--ds-primary);
  border-color: var(--ds-primary);
}

.btn-outline-primary:hover {
  background-color: var(--ds-primary);
  border-color: var(--ds-primary);
}

.btn-outline-secondary {
  color: var(--ds-secondary-muted);
  border-color: var(--ds-border);
}

.btn-outline-secondary:hover {
  background-color: var(--ds-surface-container-low);
  border-color: var(--ds-outline-variant);
  color: var(--ds-on-surface);
}

.btn-outline-danger {
  color: var(--ds-error);
  border-color: var(--ds-error);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
  background-color: var(--ds-error);
  border-color: var(--ds-error);
  color: #fff;
}

/* Form controls */
.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--ds-label-color);
  margin-bottom: var(--ds-space-xs);
}

.form-control,
.form-select {
  min-height: 44px;
  border: 1px solid var(--ds-input-border);
  border-radius: var(--ds-radius);
  font-size: 1rem;
  color: var(--ds-on-surface);
  background-color: var(--ds-surface-container-lowest);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--ds-primary);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.form-control-sm,
.form-select-sm {
  min-height: 36px;
  font-size: 0.875rem;
}

.ds-table-actions-bar .form-select-sm {
  width: auto;
  min-width: 10.5rem;
}

.form-check-input:checked {
  background-color: var(--ds-primary);
  border-color: var(--ds-primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}

.password-policy-hints {
  display: grid;
  gap: 0.35rem;
}

.password-policy-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--ds-secondary-muted);
}

.password-policy-hint__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.password-policy-hint.is-met {
  color: var(--ds-success);
}

.password-policy-hint.is-missing {
  color: var(--ds-secondary);
}

/* Badges & chips */
.badge,
.ds-chip {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--ds-radius-full);
  padding: 0.35em 0.75em;
}

.text-bg-primary,
.ds-chip-primary {
  background-color: rgba(13, 110, 253, 0.12) !important;
  color: var(--ds-primary) !important;
}

.text-bg-secondary,
.ds-chip-secondary {
  background-color: rgba(87, 95, 103, 0.12) !important;
  color: var(--ds-secondary) !important;
}

.text-bg-success,
.ds-chip-success {
  background-color: rgba(25, 135, 84, 0.12) !important;
  color: var(--ds-success) !important;
}

.text-bg-danger,
.ds-chip-danger {
  background-color: rgba(186, 26, 26, 0.12) !important;
  color: var(--ds-error) !important;
}

.text-bg-warning,
.ds-chip-warning {
  background-color: rgba(255, 193, 7, 0.15) !important;
  color: #856404 !important;
}

.text-bg-info,
.ds-chip-info {
  background-color: rgba(13, 202, 240, 0.12) !important;
  color: #087990 !important;
}

/* Tables */
.ds-table {
  margin-bottom: 0;
}

.ds-table thead th {
  background-color: var(--ds-surface-container-low);
  color: var(--ds-on-surface-variant);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--ds-border);
  padding: var(--ds-space-sm) var(--ds-space-md);
}

.ds-table tbody td {
  padding: var(--ds-space-sm) var(--ds-space-md);
  vertical-align: middle;
  font-size: 0.9375rem;
  color: var(--ds-on-surface);
  border-bottom: 1px solid var(--ds-border);
}

.ds-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

.ds-table tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.04);
}

/* Human-handoff attention queue (AI → Human). */
@keyframes ds-table-row-blink {
  0%,
  100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(var(--bs-danger-rgb, 186, 26, 26), 0.28);
  }
}

.ds-table tbody tr.table-blink td {
  animation: ds-table-row-blink 1.5s infinite ease-in-out;
}

.ds-table tbody tr.table-blink:hover td {
  /* Keep the attention pulse visible over the default hover tint. */
  animation: ds-table-row-blink 1.5s infinite ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  .ds-table tbody tr.table-blink td {
    animation: none;
    background-color: rgba(var(--bs-danger-rgb, 186, 26, 26), 0.16);
  }
}

.ds-table .sortable {
  cursor: pointer;
  user-select: none;
}

.ds-table .sortable:hover {
  color: var(--ds-primary);
}

.ds-table-actions-bar {
  padding: var(--ds-space-sm) var(--ds-space-md);
  background-color: var(--ds-surface-container-low);
  border-bottom: 1px solid var(--ds-border);
}

.ds-table-pagination-bar {
  padding: var(--ds-space-sm) var(--ds-space-md);
  background-color: var(--ds-surface);
  border-bottom: 1px solid var(--ds-border);
}

.ds-table-pagination-bar[data-pagination-slot="bottom"] {
  border-bottom: none;
  border-top: 1px solid var(--ds-border);
}

.ds-table-select-col {
  width: 3rem;
  white-space: nowrap;
}

/* Alerts */
.alert {
  border-radius: var(--ds-radius-lg);
  border: 1px solid transparent;
}

/* Footer */
.admin-footer {
  flex-shrink: 0;
  padding: var(--ds-space-sm) var(--ds-space-md);
  text-align: center;
  font-size: 0.875rem;
  color: var(--ds-secondary-muted);
  border-top: 1px solid var(--ds-border);
  background-color: var(--ds-surface);
}

/* Chat UI */
.conversation-detail-page .conversation-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.conversation-detail-page .conversation-card .card-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.conversation-back-link {
  color: var(--ds-secondary-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.conversation-back-link:hover {
  color: var(--ds-primary) !important;
}

.chat-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--ds-surface-container-lowest);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
}

.chat-load-more {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-xs);
  text-align: center;
  padding: var(--ds-space-sm) var(--ds-space-md);
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-surface-container-lowest);
}

.chat-messages-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--ds-space-sm) var(--ds-space-md);
}

#chatMessages {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-base);
}

.chat-message-row {
  display: flex;
}

.chat-message-row--customer {
  justify-content: flex-end;
}

.chat-message-row--agent {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 80%;
  padding: 0.5rem 0.875rem;
  border-radius: var(--ds-radius-xl);
  font-size: 0.875rem;
  line-height: 1.5;
}

.chat-bubble--customer {
  background-color: var(--ds-primary);
  color: var(--ds-on-primary);
}

.chat-bubble--agent {
  background-color: var(--ds-surface-container-low);
  color: var(--ds-on-surface);
}

.chat-bubble__sender {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
  letter-spacing: 0.01em;
}

.chat-bubble__time {
  font-size: 0.6875rem;
  margin-top: 0.25rem;
  opacity: 0.75;
}

.chat-bubble--agent .chat-bubble__time {
  color: var(--ds-secondary-muted);
}

.chat-composer-panel {
  flex-shrink: 0;
  padding-top: var(--ds-space-sm);
}

.chat-composer-send {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border-radius: var(--ds-radius-full);
}

.chat-composer-send .material-symbols-rounded {
  font-size: 1.125rem;
  line-height: 1;
}

/* Metric cards */
.ds-metric-card .material-symbols-rounded {
  font-size: 1.375rem;
  color: var(--ds-primary);
}

.ds-metric-card .ds-label-sm {
  text-transform: uppercase;
  color: var(--ds-secondary-muted);
}

/* Section headings in forms */
.ds-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ds-on-surface);
  margin-bottom: var(--ds-space-sm);
  padding-bottom: var(--ds-space-xs);
  border-bottom: 1px solid var(--ds-border);
}

/* Error page */
.ds-error-icon {
  font-size: 4rem;
  color: var(--ds-secondary-muted);
}

/* Tenant form — stepped configuration cards */
.tenant-form-page {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.tenant-form-steps {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-md);
}

.tenant-form-step {
  position: relative;
}

.tenant-form-step__header {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-sm);
  margin-bottom: var(--ds-space-md);
  padding-bottom: var(--ds-space-sm);
  border-bottom: 1px solid var(--ds-border);
}

.tenant-form-step__number {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--ds-radius-full);
  background-color: rgba(13, 110, 253, 0.12);
  color: var(--ds-primary);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
}

.tenant-form-step__number .material-symbols-rounded {
  font-size: 1.25rem;
}

.tenant-form-step__fields {
  max-width: 100%;
}

.tenant-form-step__fields .form-control,
.tenant-form-step__fields .form-select {
  width: 100%;
}

.tenant-form-step fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.tenant-form-step fieldset legend {
  float: left;
  width: 100%;
}

.tenant-form-health .tenant-form-step__number {
  background-color: rgba(25, 135, 84, 0.12);
  color: var(--ds-success);
}

.shopify-auth-panel {
  padding: var(--ds-space-sm);
  background-color: var(--ds-surface-container-low);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  margin-bottom: var(--ds-space-xs);
}

.tenant-form-actions {
  margin-top: var(--ds-space-sm);
  padding-top: var(--ds-space-md);
}
