/* Floating hub + dark mode + WhatsApp-style assistant */

html[data-theme="dark"] {
  --color-bg: #0b0f14;
  --color-card: #121820;
  --color-dark: #eef1f4;
  --color-muted: #8b97a5;
  --color-border: rgba(197, 160, 89, 0.16);
  --gradient-hero:
    radial-gradient(1000px 560px at 10% -10%, rgba(197, 160, 89, 0.18), transparent 55%),
    radial-gradient(800px 480px at 90% 0%, rgba(212, 184, 122, 0.1), transparent 50%),
    #0b0f14;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] body {
  background: var(--gradient-hero);
  color: var(--color-dark);
}

html[data-theme="dark"] .app-sidebar,
html[data-theme="dark"] .app-topbar,
html[data-theme="dark"] .ds-card,
html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .landing-nav,
html[data-theme="dark"] .landing-panel,
html[data-theme="dark"] .ds-input,
html[data-theme="dark"] .ds-select,
html[data-theme="dark"] .ds-btn-secondary,
html[data-theme="dark"] .role-chip {
  background: rgba(18, 26, 43, 0.92);
  color: var(--color-dark);
}

html[data-theme="dark"] .ds-input,
html[data-theme="dark"] .ds-select {
  border-color: var(--color-border);
}

html[data-theme="dark"] .app-nav-link { color: #CBD5E1; }
html[data-theme="dark"] .table { --bs-table-bg: transparent; color: var(--color-dark); }

.fab-hub {
  position: fixed;
  left: 1.25rem;
  right: auto;
  bottom: 1.25rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
}

[dir="rtl"] .fab-hub {
  left: 1.25rem;
  right: auto;
  align-items: flex-start;
}

.fab-main {
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  line-height: 0;
  cursor: pointer;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.fab-main-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.fab-main-icon::before,
.fab-main-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  border-radius: 2px;
  transform: translate(-50%, -50%);
}

.fab-main-icon::before {
  width: 20px;
  height: 2.5px;
}

.fab-main-icon::after {
  width: 2.5px;
  height: 20px;
}

.fab-main:hover { transform: scale(1.05); }
.fab-main.open { transform: rotate(45deg); }
.fab-main.open:hover { transform: scale(1.05) rotate(45deg); }

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
}

.fab-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-dark);
  border-radius: 999px;
  padding: 0.65rem 0.95rem;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: transform 180ms ease, border-color 180ms ease;
}

.fab-menu-item:hover {
  transform: translateY(-1px);
  border-color: rgba(197, 160, 89, 0.35);
}

.fab-menu-item i { color: var(--color-primary); font-size: 1.05rem; }

.fab-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: end start;
  padding: 1.25rem;
}

[dir="rtl"] .fab-sheet { place-items: end start; }

.fab-sheet-card {
  width: min(380px, calc(100vw - 2rem));
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 1.1rem 1.2rem 1.35rem;
  margin-bottom: 5rem;
}

.fab-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.fab-sheet-head h3 { margin: 0; font-size: 1.05rem; }

.fab-close {
  border: none;
  background: rgba(197, 160, 89, 0.08);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--color-dark);
}

.fab-branding-swatches {
  display: flex;
  gap: 0.6rem;
  margin: 0.85rem 0 1rem;
}

.fab-swatch {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--color-border);
}

.fab-brand-mark-lg {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  background: var(--gradient-primary);
  box-shadow: var(--shadow-glow);
  margin-bottom: 0.75rem;
}

/* Chat shell — WhatsApp style */
.fab-chat {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.fab-chat-shell {
  width: min(920px, 100%);
  height: min(640px, calc(100vh - 2rem));
  display: grid;
  grid-template-columns: 300px 1fr;
  background: var(--color-card);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}

.fab-chat-list {
  border-inline-end: 1px solid var(--color-border);
  background: rgba(197, 160, 89, 0.03);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.fab-chat-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.fab-chat-list-sub {
  padding: 0.35rem 1rem 0.65rem;
  font-size: 0.75rem;
  color: var(--color-muted);
  font-weight: 600;
}

.fab-thread-group {
  margin-bottom: 0.55rem;
}
.fab-thread-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem 0.25rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: #c5a059;
}
.fab-thread-group-title i { margin-inline-end: 0.3rem; }
.fab-thread-group-title span {
  font-weight: 600;
  color: var(--color-muted);
  font-size: 0.68rem;
}
.fab-agent-hist {
  display: block;
  margin-top: 0.45rem;
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 700;
  color: #c5a059;
}

.fab-chat-threads {
  overflow: auto;
  flex: 1;
  padding: 0.35rem;
}

.fab-thread {
  width: 100%;
  text-align: start;
  border: none;
  background: transparent;
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  cursor: pointer;
  color: inherit;
  transition: background 160ms ease;
}

.fab-thread:hover,
.fab-thread.active {
  background: rgba(197, 160, 89, 0.1);
}

.fab-thread-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.fab-thread-preview {
  font-size: 0.78rem;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fab-thread-meta {
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

.fab-chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(197, 160, 89, 0.04), transparent 120px),
    var(--color-card);
}

html[data-theme="dark"] .fab-chat-main {
  background:
    linear-gradient(180deg, rgba(197, 160, 89, 0.08), transparent 120px),
    #0F172A;
}

.fab-chat-main-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
}

html[data-theme="dark"] .fab-chat-main-head {
  background: rgba(15, 23, 42, 0.75);
}

.fab-agent-picker { padding: 1rem; overflow: auto; }
.fab-agent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.fab-agent-card {
  text-align: start;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  border-radius: 16px;
  padding: 0.85rem;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.fab-agent-card:hover {
  border-color: rgba(197, 160, 89, 0.4);
  transform: translateY(-1px);
}

.fab-agent-card strong { display: block; margin: 0.25rem 0; font-size: 0.92rem; }
.fab-agent-card span { color: var(--color-muted); font-size: 0.78rem; }

.fab-messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.fab-bubble {
  max-width: 78%;
  padding: 0.7rem 0.9rem;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
}

.fab-bubble.user {
  margin-inline-start: auto;
  background: linear-gradient(135deg, rgba(197, 160, 89, 0.18), rgba(212, 184, 122, 0.14));
  border-bottom-left-radius: 6px;
}

[dir="rtl"] .fab-bubble.user { border-bottom-left-radius: 16px; border-bottom-right-radius: 6px; }

.fab-bubble.assistant {
  margin-inline-end: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border);
  border-bottom-right-radius: 6px;
}

[dir="rtl"] .fab-bubble.assistant { border-bottom-right-radius: 16px; border-bottom-left-radius: 6px; }

html[data-theme="dark"] .fab-bubble.assistant {
  background: #121A2B;
}

.fab-bubble-time {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  color: var(--color-muted);
}

.fab-send {
  display: flex;
  gap: 0.55rem;
  padding: 0.85rem;
  border-top: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.65);
}

html[data-theme="dark"] .fab-send {
  background: rgba(15, 23, 42, 0.8);
}

.fab-empty {
  margin: auto;
  text-align: center;
  color: var(--color-muted);
  padding: 2rem 1rem;
}

@media (max-width: 760px) {
  .fab-chat-shell { grid-template-columns: 1fr; height: min(720px, calc(100vh - 1rem)); }
  .fab-chat-list { max-height: 38%; border-inline-end: none; border-bottom: 1px solid var(--color-border); }
  .fab-agent-grid { grid-template-columns: 1fr; }
}
