/* AiAgent.Admin design tokens */
:root {
  --aa-bg: #f4f5f7;
  --aa-surface: #ffffff;
  --aa-text: #212529;
  --aa-text-muted: #6c757d;
  --aa-border: #dee2e6;
  --aa-header-bar: #212529;
  --aa-accent: #6f42c1;
  --aa-radius: 0.375rem;
  --aa-shadow-header: 0 2px 4px rgba(0, 0, 0, 0.1);
  --aa-shadow-card: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.06);
  --aa-code-bg: #1a1a1e;
  --aa-code-fg: #e8e8ec;
}

/* Base */
html {
  font-size: 14px;
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--aa-bg);
  color: var(--aa-text);
}

/* ----- Layout regions ----- */
.aa-page {
  width: 100%;
  padding-left: clamp(0.75rem, 2.5vw, 2rem);
  padding-right: clamp(0.75rem, 2.5vw, 2rem);
  padding-bottom: 0.25rem;
}

.aa-page-header {
  margin-bottom: 1.25rem;
}

.aa-page-header h1,
.aa-page-header h2 {
  letter-spacing: -0.02em;
}

/* ----- Sidebar ----- */
.aa-shell {
  display: flex;
  align-items: stretch;
}

.aa-main {
  flex: 1 1 auto;
  min-width: 0;
}

.aa-nav {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.aa-nav-link,
.aa-nav-sublink {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: var(--aa-radius);
  background: none;
  color: var(--aa-text);
  font-size: 0.9375rem;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.aa-nav-link:hover,
.aa-nav-sublink:hover {
  background-color: rgba(0, 0, 0, 0.04);
  color: var(--aa-text);
  opacity: 1;
}

.aa-nav-link.active,
.aa-nav-sublink.active {
  background-color: rgba(111, 66, 193, 0.1);
  color: var(--aa-accent);
  font-weight: 600;
}

.aa-nav-link > .bi:first-child {
  font-size: 1rem;
  opacity: 0.75;
}

.aa-nav-caret {
  margin-left: auto;
  font-size: 0.75rem;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.aa-nav-toggle[aria-expanded="true"] .aa-nav-caret {
  transform: rotate(180deg);
}

.aa-nav-sub {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.125rem 0 0.25rem 2.25rem;
}

.aa-nav-sublink {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--aa-text-muted);
}

@media (min-width: 992px) {
  .aa-sidebar.offcanvas-lg {
    flex: 0 0 15rem;
    width: 15rem;
    align-self: stretch;
    border-right: 1px solid var(--aa-border);
    background-color: var(--aa-surface) !important;
    transition: flex-basis 0.2s ease, width 0.2s ease;
  }

  /* A flex item won't shrink past its content without this, so width:0 alone does nothing. */
  .aa-sidebar-collapsed .aa-sidebar.offcanvas-lg {
    flex-basis: 0;
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: 0;
  }

  .aa-sidebar .offcanvas-body {
    flex-grow: 1;
    align-items: flex-start;
  }

  .aa-nav {
    position: sticky;
    top: 0;
    padding: 1rem 0.75rem;
  }
}

/* Card headers — use with Bootstrap .card-header */
.card-header-aa {
  background-color: var(--aa-header-bar) !important;
  color: #fff !important;
  border-bottom: none !important;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.card-header-aa-muted {
  background-color: var(--aa-surface) !important;
  color: var(--aa-text) !important;
  border-bottom: 1px solid var(--aa-border) !important;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

/* Dashboard tiles */
.icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hover-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.hover-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.15) !important;
}

/* JSON / payload blocks */
.aa-code-pre {
  max-height: 400px;
  overflow-y: auto;
  font-size: 0.8rem;
  background-color: var(--aa-code-bg);
  color: var(--aa-code-fg);
  border-radius: var(--aa-radius);
  padding: 1rem;
  margin-bottom: 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.aa-code-pre code {
  color: inherit;
  font-size: inherit;
}

/* Retrieval settings */
.aa-threshold-value {
  width: 5.5rem;
  flex: 0 0 auto;
  text-align: center;
}

/* Tables */
.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.card-body.p-0 .table > :not(caption) > * > * {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.card-body.p-0 .table > :not(caption) > * > :first-child {
  padding-left: 1.25rem;
}

.card-body.p-0 .table > :not(caption) > * > :last-child {
  padding-right: 1.25rem;
}

.aa-page .badge {
  font-weight: 500;
}

/* jQuery validate leaves this div in place when the form is clean; empty, it still takes up a row. */
.validation-summary-valid {
  display: none;
}

/* Header */
.header-custom {
  box-shadow: var(--aa-shadow-header);
}

.navbar-dark .navbar-nav .nav-link {
  color: rgba(255, 255, 255, 0.85);
  transition: all 0.3s ease;
  position: relative;
}

.navbar-dark .navbar-nav .nav-link:hover {
  color: #ffffff;
  transform: translateY(-2px);
}

.navbar-dark .navbar-nav .nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background-color: #ffffff;
  transition: width 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover::after {
  width: 80%;
}

.navbar-brand {
  transition: transform 0.3s ease;
}

.navbar-brand:hover {
  transform: scale(1.05);
}

/* Footer */
.footer-custom {
  border-top: 3px solid #333333;
}

.footer-custom a:hover {
  text-decoration: underline !important;
  opacity: 0.8;
}

/* Focus */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #333333;
}

/* Buttons */
.btn-primary {
  background-color: #000000;
  border-color: #000000;
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background-color: #333333;
  border-color: #333333;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-outline-dark {
  transition: all 0.3s ease;
}

.btn-outline-dark:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Links */
a {
  color: #000000;
  text-decoration: none;
  transition: opacity 0.3s ease;
}

a:hover {
  color: #333333;
  opacity: 0.8;
}

/* Forms */
.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Utilities */
.bg-black {
  background-color: #000000 !important;
}

.text-light {
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar-nav {
    padding-top: 1rem;
  }

  .navbar-nav .nav-link {
    padding: 0.5rem 0;
  }
}

/* Sign-out button styled as a dropdown item */
.aa-signout {
  background: none;
  border: none;
  padding: 0.25rem 1rem;
  font: inherit;
  color: inherit;
  width: 100%;
  text-align: left;
}

/* Live chat */
.aa-avatar {
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background-color: #adb5bd;
}

.aa-avatar-customer { background-color: #6c757d; }
.aa-avatar-operator { background-color: #0d6efd; }
.aa-avatar-portal { background-color: #212529; }
.aa-avatar-agent { background-color: #6f42c1; }

.aa-convo-item {
  display: flex;
  gap: 0.875rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border: 0;
  border-bottom: 1px solid #f1f3f5;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.12s ease;
}

.aa-convo-item:last-child {
  border-bottom: 0;
}

.aa-convo-item:hover {
  background-color: #f8f9fa;
  color: inherit;
}

.aa-convo-preview {
  min-width: 0;
  flex: 1 1 auto;
}

.aa-convo-preview p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aa-thread {
  max-height: 58vh;
  overflow-y: auto;
  background-color: #fbfcfd;
}

.aa-row {
  display: flex;
  gap: 0.625rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.aa-row-out {
  flex-direction: row-reverse;
}

.aa-bubble {
  max-width: 32rem;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

/* Only the message body keeps line breaks. On the bubble it also kept Razor's own indentation,
   which left a gaping hole under every message. */
.aa-bubble-text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.aa-bubble-customer {
  background-color: #fff;
  border: 1px solid #e9ecef;
  color: #212529;
  border-bottom-left-radius: 0.25rem;
}

.aa-bubble-operator {
  background-color: #e7f1ff;
  border: 1px solid #d4e5ff;
  color: #0a3d91;
  border-bottom-right-radius: 0.25rem;
}

.aa-bubble-portal {
  background-color: #212529;
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.aa-bubble-agent {
  background-color: #6f42c1;
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.aa-bubble-note {
  background-color: #fff8e1;
  border: 1px dashed #f0c36d;
  color: #664d03;
}

.aa-bubble a {
  color: inherit;
  text-decoration: underline;
}

.aa-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.aa-choice {
  padding: 0.25rem 0.625rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.8125rem;
  opacity: 0.8;
}

.aa-choice-selected {
  background-color: #0a3d91;
  border-color: #0a3d91;
  color: #fff;
  opacity: 1;
}

.aa-field {
  margin-top: 0.5rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid #d4e5ff;
  border-radius: 0.5rem;
  background-color: #fff;
  font-size: 0.8125rem;
  color: #868e96;
}

.aa-attachment-img {
  display: block;
  max-width: 100%;
  max-height: 16rem;
  border-radius: 0.5rem;
  margin-top: 0.25rem;
}

.aa-attachment-file {
  display: inline-block;
  margin-top: 0.25rem;
}

.aa-event {
  text-align: center;
  margin: 0.25rem 0 1rem;
  font-size: 0.75rem;
  color: #868e96;
}

.aa-meta {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 0.125rem;
}

.aa-day {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
  font-size: 0.75rem;
  color: #868e96;
}

.aa-day::before,
.aa-day::after {
  content: "";
  flex: 1;
  border-top: 1px solid #e9ecef;
}
