/* ============================================================
 * CHAT WIDGET & ATENDIMENTO — Professional Design System
 * Self-contained: widget CSS has no DaisyUI dependency
 * Inspired by: Intercom, Crisp, Zendesk, Tidio
 * ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  --cw-primary: #0057FF;
  --cw-primary-dark: #0047D4;
  --cw-primary-light: rgba(0, 87, 255, .10);
  --cw-primary-glow: rgba(0, 87, 255, .35);
  --cw-on-primary: #ffffff;

  --cw-bg: #ffffff;
  --cw-surface: #F4F5F7;
  --cw-surface-hover: #ECEEF1;

  --cw-text: #1A1D26;
  --cw-text-secondary: #6B7280;
  --cw-text-muted: #9CA3AF;

  --cw-border: rgba(0, 0, 0, .08);
  --cw-border-strong: rgba(0, 0, 0, .13);

  --cw-shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --cw-shadow-lg: 0 8px 40px rgba(0,0,0,.16), 0 2px 12px rgba(0,0,0,.06);
  --cw-shadow-fab: 0 4px 14px rgba(0,0,0,.28);

  --cw-badge: #EF4444;
  --cw-badge-text: #fff;
  --cw-success: #22C55E;

  --cw-bubble-mine: #0057FF;
  --cw-bubble-mine-text: #fff;
  --cw-bubble-other: #F3F4F6;
  --cw-bubble-other-text: #1A1D26;

  --cw-radius: 16px;
  --cw-radius-sm: 10px;
  --cw-radius-pill: 20px;
  --cw-radius-full: 50%;

  --cw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --cw-win-w: 380px;
  --cw-win-h: 620px;
}

/* ========== FLOATING ACTION BUTTON (FAB) ========== */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: var(--cw-radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  box-shadow: var(--cw-shadow-fab), 0 0 0 0 var(--cw-primary-glow);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease;
  animation: cw-fab-in .5s cubic-bezier(.34,1.56,.64,1) both;
  animation-delay: .8s;
  font-family: var(--cw-font);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0,0,0,.3), 0 0 0 0 var(--cw-primary-glow);
}
.chat-fab:active { transform: scale(.94); }
.chat-fab svg {
  width: 26px;
  height: 26px;
  transition: transform .3s ease, opacity .25s ease;
  pointer-events: none;
}
.chat-fab .cw-icon-close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(.5);
}
.chat-fab.is-open .cw-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(.5);
}
.chat-fab.is-open .cw-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Badge on FAB */
.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--cw-badge);
  color: var(--cw-badge-text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2.5px solid var(--cw-bg);
  animation: cw-badge-pop .3s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 2px 8px rgba(239,68,68,.4);
  font-family: var(--cw-font);
  line-height: 1;
}
.chat-fab-badge.hidden { display: none; }

@keyframes cw-fab-in {
  0% { opacity: 0; transform: scale(0) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cw-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ========== CHAT WINDOW ========== */
.chat-win {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9998;
  width: var(--cw-win-w);
  height: var(--cw-win-h);
  max-height: calc(100dvh - 120px);
  border-radius: var(--cw-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--cw-bg);
  box-shadow: var(--cw-shadow-lg), 0 0 0 1px var(--cw-border);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .3s cubic-bezier(.34,1.56,.64,1), visibility .25s ease;
  font-family: var(--cw-font);
}
.chat-win[aria-hidden="true"] {
  opacity: 0;
  transform: scale(.88) translateY(8px);
  pointer-events: none;
  visibility: hidden;
}
.chat-win[aria-hidden="false"] {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  visibility: visible;
}

/* --- Header --- */
.chat-win-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--cw-primary) 0%, var(--cw-primary-dark) 100%);
  color: var(--cw-on-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.chat-win-header::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -25%;
  width: 150px;
  height: 150px;
  border-radius: var(--cw-radius-full);
  background: rgba(255,255,255,.06);
  pointer-events: none;
}
.chat-win-header-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}
.chat-win-header-info .cw-subtitle {
  font-size: 12px;
  opacity: .75;
  font-weight: 400;
  margin-top: 3px;
}
.chat-win-header-actions {
  display: flex;
  gap: 4px;
}
.chat-win-header-actions button,
.chat-win-header-actions a {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,.15);
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease;
  text-decoration: none;
  outline: none;
}
.chat-win-header-actions button:hover,
.chat-win-header-actions a:hover {
  background: rgba(255,255,255,.25);
}
.chat-win-header-actions svg { width: 16px; height: 16px; pointer-events: none; }

/* --- Body --- */
.chat-win-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--cw-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ========== MESSAGES ========== */
.chat-msgs {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  min-height: 0;
  scroll-snap-type: y mandatory;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  margin-bottom: 2px;
  scroll-snap-align: end;
}
.chat-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.is-other { align-self: flex-start; align-items: flex-start; }

.chat-msg-meta {
  font-size: 10px;
  color: var(--cw-text-muted);
  margin-bottom: 2px;
  padding: 0 4px;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--cw-shadow-sm);
}
.chat-msg.is-mine .chat-msg-bubble {
  background: var(--cw-bubble-mine);
  color: var(--cw-bubble-mine-text);
  border-bottom-right-radius: 6px;
}
.chat-msg.is-other .chat-msg-bubble {
  background: var(--cw-bubble-other);
  color: var(--cw-bubble-other-text);
  border-bottom-left-radius: 6px;
}

/* ========== INPUT AREA ========== */
.chat-win-input {
  padding: 12px 14px;
  border-top: 1px solid var(--cw-border);
  background: var(--cw-bg);
  flex-shrink: 0;
}
.chat-win-input form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.chat-win-input input[type="text"],
.chat-win-input textarea {
  flex: 1;
  border-radius: var(--cw-radius-pill);
  padding: 10px 16px;
  font-size: 13px;
  border: 1.5px solid var(--cw-border-strong);
  background: var(--cw-surface);
  color: var(--cw-text);
  outline: none;
  font-family: var(--cw-font);
  transition: border-color .15s ease, box-shadow .15s ease;
  box-sizing: border-box;
}
.chat-win-input input[type="text"]:focus,
.chat-win-input textarea:focus {
  border-color: var(--cw-primary);
  box-shadow: 0 0 0 3px var(--cw-primary-light);
  background: var(--cw-bg);
}
.chat-win-input .cw-send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--cw-radius-full);
  border: none;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s ease, background .15s ease;
  outline: none;
}
.chat-win-input .cw-send-btn:hover {
  transform: scale(1.08);
  background: var(--cw-primary-dark);
}
.chat-win-input .cw-send-btn:active { transform: scale(.92); }
.chat-win-input .cw-send-btn:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
}
.chat-win-input .cw-send-btn svg { width: 18px; height: 18px; pointer-events: none; }

/* ========== CONVERSATION LIST ========== */
.chat-conv-item {
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--cw-border);
  transition: background .15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--cw-font);
}
.chat-conv-item:hover { background: var(--cw-surface); }
.chat-conv-item.is-active {
  background: var(--cw-primary-light);
  border-left: 3px solid var(--cw-primary);
}
.chat-conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--cw-radius-full);
  background: var(--cw-primary-light);
  color: var(--cw-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  text-transform: uppercase;
}
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cw-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-preview {
  font-size: 12.5px;
  color: var(--cw-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}
.chat-conv-time {
  font-size: 10.5px;
  color: var(--cw-text-muted);
}
.chat-conv-unread {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.chat-conv-contact {
  font-size: 11px;
  opacity: .5;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.chat-conv-item.is-waiting {
  border-left: 3px solid oklch(var(--wa, .8 .1 80));
}
.chat-btn-unread {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: .4;
  cursor: pointer;
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.chat-conv-item:hover .chat-btn-unread { display: inline-flex; }
.chat-btn-unread:hover { opacity: 1; background: oklch(var(--bc) / .08); }

/* ========== FORM (New conv / visitor start) ========== */
.chat-form {
  padding: 20px;
  font-family: var(--cw-font);
}
.chat-form h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--cw-text);
  margin: 0 0 4px;
}
.chat-form .cw-form-sub {
  font-size: 12.5px;
  color: var(--cw-text-secondary);
  margin-bottom: 16px;
}
.chat-form label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cw-text-secondary);
  display: block;
  margin-bottom: 5px;
}
.chat-form input,
.chat-form textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--cw-radius-sm);
  border: 1.5px solid var(--cw-border-strong);
  background: var(--cw-surface);
  color: var(--cw-text);
  font-size: 13px;
  font-family: var(--cw-font);
  outline: none;
  margin-bottom: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-sizing: border-box;
}
.chat-form input:focus,
.chat-form textarea:focus {
  border-color: var(--cw-primary);
  box-shadow: 0 0 0 3px var(--cw-primary-light);
  background: var(--cw-bg);
}
.chat-form input::placeholder,
.chat-form textarea::placeholder {
  color: var(--cw-text-muted);
}
.chat-form textarea { resize: vertical; min-height: 72px; }

.chat-form .cw-submit-btn {
  width: 100%;
  padding: 11px;
  border-radius: var(--cw-radius-sm);
  border: none;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s ease, background .15s ease;
  font-family: var(--cw-font);
  outline: none;
  margin-top: 4px;
}
.chat-form .cw-submit-btn:hover {
  transform: translateY(-1px);
  background: var(--cw-primary-dark);
}
.chat-form .cw-submit-btn:active { transform: translateY(0); }
.chat-form .cw-submit-btn:disabled { opacity: .5; cursor: default; transform: none; }
.chat-form .cw-submit-btn svg { width: 16px; height: 16px; pointer-events: none; }

.chat-form .cw-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.chat-form .cw-btn-ghost {
  flex: 1;
  padding: 10px;
  border-radius: var(--cw-radius-sm);
  border: 1.5px solid var(--cw-border-strong);
  background: transparent;
  color: var(--cw-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--cw-font);
  transition: background .15s ease;
  outline: none;
}
.chat-form .cw-btn-ghost:hover { background: var(--cw-surface); }
.chat-form .cw-btn-primary {
  flex: 1;
  padding: 10px;
  border-radius: var(--cw-radius-sm);
  border: none;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--cw-font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s ease;
  outline: none;
}
.chat-form .cw-btn-primary:hover { background: var(--cw-primary-dark); }
.chat-form .cw-btn-primary:disabled { opacity: .5; cursor: default; }
.chat-form .cw-btn-primary svg { width: 14px; height: 14px; pointer-events: none; }

/* ========== GREETING / WELCOME ========== */
.chat-greeting {
  text-align: center;
  padding: 32px 24px 20px;
  font-family: var(--cw-font);
}
.chat-greeting-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--cw-radius-full);
  background: var(--cw-primary-light);
  color: var(--cw-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
.chat-greeting-avatar svg { width: 28px; height: 28px; }
.chat-greeting h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--cw-text);
  margin: 0 0 6px;
}
.chat-greeting p {
  font-size: 13px;
  color: var(--cw-text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Compact form for small viewports */
@media (max-height: 700px) {
  .chat-greeting { padding: 12px 20px 6px; }
  .chat-greeting-avatar { width: 38px; height: 38px; margin-bottom: 6px; }
  .chat-greeting-avatar svg { width: 20px; height: 20px; }
  .chat-greeting h3 { font-size: 14.5px; margin-bottom: 2px; }
  .chat-greeting p { font-size: 12px; }
  .chat-form { padding: 10px 16px; }
  .chat-form .cw-form-sub { margin-bottom: 6px; }
  .chat-form input,
  .chat-form textarea { padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }
  .chat-form textarea { min-height: 48px; }
  .chat-form label { margin-bottom: 3px; }
  .chat-form .cw-submit-btn { padding: 9px; font-size: 13px; }
}

/* ========== NEW CONVERSATION BUTTON ========== */
.cw-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 32px);
  margin: 16px auto 8px;
  padding: 10px;
  border-radius: var(--cw-radius-sm);
  border: none;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--cw-font);
  transition: transform .15s ease, background .15s ease;
  outline: none;
}
.cw-new-btn:hover { transform: translateY(-1px); background: var(--cw-primary-dark); }
.cw-new-btn:active { transform: translateY(0); }
.cw-new-btn svg { width: 16px; height: 16px; pointer-events: none; }

/* ========== BACK BUTTON ========== */
.cw-back-bar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--cw-border);
  flex-shrink: 0;
}
.cw-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--cw-text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--cw-font);
  transition: background .15s ease, color .15s ease;
  outline: none;
}
.cw-back-btn:hover { background: var(--cw-surface); color: var(--cw-text); }
.cw-back-btn svg { width: 14px; height: 14px; pointer-events: none; }

/* ========== ONLINE DOT ========== */
.chat-online-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--cw-radius-full);
  background: var(--cw-success);
  display: inline-block;
  animation: cw-dot-pulse 2s ease-in-out infinite;
}
@keyframes cw-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ========== EMPTY STATE ========== */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  font-family: var(--cw-font);
}
.chat-empty svg { width: 40px; height: 40px; color: var(--cw-text-muted); opacity: .35; margin-bottom: 12px; }
.chat-empty p { font-size: 13px; color: var(--cw-text-muted); margin: 0; }

/* ========== LOADING ========== */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.cw-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--cw-border-strong);
  border-top-color: var(--cw-primary);
  border-radius: var(--cw-radius-full);
  animation: cw-spin .6s linear infinite;
}
@keyframes cw-spin { to { transform: rotate(360deg); } }

/* ========== CLOSED NOTICE ========== */
.cw-closed-notice {
  text-align: center;
  font-size: 12.5px;
  color: var(--cw-text-secondary);
  padding: 14px 16px;
  border-top: 1px solid var(--cw-border);
  font-family: var(--cw-font);
}
.cw-closed-notice button {
  color: var(--cw-primary);
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
  font-family: inherit;
}

/* ========== CHANNEL BADGE (admin) ========== */
.cw-channel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
}
.cw-channel svg { width: 12px; height: 12px; }
.cw-channel.visitor { background: #F3F4F6; color: #6B7280; }
.cw-channel.client { background: #DBEAFE; color: #2563EB; }
.cw-channel.seller { background: #D1FAE5; color: #059669; }

/* ========== STATUS BADGE ========== */
.cw-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
}
.cw-status.waiting { background: #FEF3C7; color: #D97706; }
.cw-status.closed { background: #F3F4F6; color: #6B7280; }

/* ========== CLAIM BUTTON ========== */
.cw-claim-btn {
  width: 100%;
  padding: 7px;
  margin-top: 8px;
  border-radius: 8px;
  border: none;
  background: var(--cw-primary);
  color: var(--cw-on-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--cw-font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background .15s ease;
  outline: none;
}
.cw-claim-btn:hover { background: var(--cw-primary-dark); }
.cw-claim-btn:disabled { opacity: .5; cursor: default; }
.cw-claim-btn svg { width: 14px; height: 14px; pointer-events: none; }

/* ========== RESPONSIVE (mobile) ========== */
@media (max-width: 640px) {
  .chat-fab {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .chat-fab svg { width: 22px; height: 22px; }
  .chat-fab.is-open { display: none; }
  .chat-win {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
  .chat-win[aria-hidden="false"] {
    transform: scale(1) translateY(0);
  }
  .chat-win[aria-hidden="true"] {
    transform: scale(1) translateY(100%);
    opacity: 1;
  }
}

/* ============================================================
 * ADMIN: Pagina Atendimento (usa DaisyUI do admin)
 * ============================================================ */
.atd-container {
  display: flex;
  gap: 0;
  height: calc(100vh - 160px);
  background: oklch(var(--b1));
  border-radius: 12px;
  border: 1px solid oklch(var(--bc) / .08);
  overflow: hidden;
}
.atd-sidebar {
  width: 340px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid oklch(var(--bc) / .08);
}
.atd-tabs {
  display: flex;
  padding: 8px 8px 0;
  gap: 2px;
  flex-shrink: 0;
  border-bottom: 1px solid oklch(var(--bc) / .06);
}
.atd-tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  border: none;
  background: transparent;
  color: oklch(var(--bc));
  opacity: .5;
  position: relative;
}
.atd-tab:hover { opacity: .7; background: oklch(var(--bc) / .04); }
.atd-tab.active {
  opacity: 1;
  background: oklch(var(--p) / .08);
  color: oklch(var(--p));
}
.atd-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  right: 20%;
  height: 2px;
  background: oklch(var(--p));
  border-radius: 2px;
}
.atd-tab .atd-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  margin-left: 4px;
  background: oklch(var(--wa, .8 .1 80));
  color: oklch(var(--wac, .2 0 0));
}
.atd-tab .atd-badge.hidden { display: none; }
.atd-list { flex: 1; overflow-y: auto; }
.atd-main { flex: 1; display: flex; flex-direction: column; }

.atd-chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid oklch(var(--bc) / .08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: oklch(var(--b2) / .5);
}
.atd-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}
.atd-chat-msgs .chat {
  scroll-snap-align: end;
}
.atd-chat-input {
  padding: 14px 18px;
  border-top: 1px solid oklch(var(--bc) / .08);
  flex-shrink: 0;
}
.atd-chat-input form {
  display: flex;
  gap: 10px;
  align-items: center;
}
.atd-chat-input input {
  flex: 1;
  padding: 10px 16px;
  border-radius: 20px;
  border: 1px solid oklch(var(--bc) / .12);
  background: oklch(var(--b2));
  color: oklch(var(--bc));
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.atd-chat-input input:focus {
  border-color: oklch(var(--p));
  box-shadow: 0 0 0 3px oklch(var(--p) / .1);
}
.atd-chat-input .atd-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: oklch(var(--p));
  color: oklch(var(--pc));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s, background .15s;
}
.atd-chat-input .atd-send-btn:hover { transform: scale(1.08); }
.atd-chat-input .atd-send-btn:active { transform: scale(.92); }

/* Admin chat bubbles (uses DaisyUI .chat component, enhanced) */
.atd-chat-msgs .chat .chat-bubble {
  font-size: 13px;
  line-height: 1.5;
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.atd-chat-msgs .chat-start .chat-bubble {
  border-bottom-left-radius: 4px;
  background: oklch(var(--b2));
  color: oklch(var(--bc));
}
.atd-chat-msgs .chat-end .chat-bubble {
  border-bottom-right-radius: 4px;
}
.atd-chat-msgs .chat .chat-header {
  font-size: 11px;
  opacity: .5;
}

/* ---------- Admin dark-theme overrides for chat components ---------- */
.atd-container {
  --cw-text: oklch(var(--bc));
  --cw-text-secondary: oklch(var(--bc) / .65);
  --cw-text-muted: oklch(var(--bc) / .45);
  --cw-bg: oklch(var(--b1));
  --cw-surface: oklch(var(--b2));
  --cw-surface-hover: oklch(var(--b2) / .8);
  --cw-border: oklch(var(--bc) / .08);
  --cw-border-strong: oklch(var(--bc) / .13);
  --cw-primary-light: oklch(var(--p) / .12);
}

/* ---------- Dark Theme — Chat Widget Flutuante (Site + Client) ---------- */
[data-theme="dark"] {
  --cw-bg: #1A1A2E;
  --cw-surface: #2D2D44;
  --cw-surface-hover: #3A3A52;

  --cw-text: #E5E7EB;
  --cw-text-secondary: #9CA3AF;
  --cw-text-muted: #6B7280;

  --cw-border: rgba(255, 255, 255, .08);
  --cw-border-strong: rgba(255, 255, 255, .13);

  --cw-bubble-other: #2D2D44;
  --cw-bubble-other-text: #E5E7EB;

  --cw-shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --cw-shadow-lg: 0 8px 40px rgba(0,0,0,.4), 0 2px 12px rgba(0,0,0,.2);
  --cw-shadow-fab: 0 4px 14px rgba(0,0,0,.5);

  --cw-primary-light: rgba(0, 87, 255, .20);
  --cw-primary-glow: rgba(0, 87, 255, .45);
}

/* Admin responsive */
@media (max-width: 768px) {
  .atd-container { flex-direction: column; height: calc(100vh - 140px); }
  .atd-sidebar { width: 100%; min-width: 0; height: 45%; border-right: none; border-bottom: 1px solid oklch(var(--bc) / .08); }
}
