/* Beava assistant widget
   z-index: FAB=100, panel=150. Toast is 80, auth modal is 1000. */

.bva-assistant {
  --bva-footer-offset: 0px;
  font-family: var(--font-ui);
}

/* Ensure [hidden] wins over display: flex/grid on any descendant. */
.bva-assistant [hidden],
.bva-panel[hidden] { display: none !important; }

.bva-fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--bva-footer-offset));
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: var(--grad-accent);
  color: var(--c-white);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: grid;
  place-items: center;
  transition: transform 0.22s ease, box-shadow 0.22s ease, bottom 0.22s ease;
}
.bva-fab:hover { transform: translateY(-2px); }
.bva-fab:focus-visible { outline: 3px solid var(--stroke-accent); outline-offset: 2px; }
.bva-fab-icon { color: var(--c-white); }

.bva-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--c-error);
  color: var(--c-white);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s infinite;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.bva-panel {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--bva-footer-offset));
  width: 380px;
  height: min(620px, 80vh);
  max-height: calc(100vh - 40px - var(--bva-footer-offset));
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--stroke);
  border-radius: var(--radius2);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: bvaSlideIn 0.22s ease;
  transition: bottom 0.22s ease;
}

@keyframes bvaSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

body.bva-open .bva-fab { display: none; }

.bva-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--stroke);
  background: var(--glass-75);
}
.bva-panel-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.bva-panel-back,
.bva-panel-close {
  border: 1px solid var(--stroke);
  background: var(--glass);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
}
.bva-panel-back:hover,
.bva-panel-close:hover { background: var(--glass-hover); }

.bva-panel-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 4px 6px;
  border-bottom: 1px solid var(--stroke);
}
.bva-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 2px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-radius: 10px;
  transition: color 0.15s ease, background 0.15s ease;
  min-width: 0;
}
.bva-tab:hover { background: var(--glass-hover); }
.bva-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}
.bva-tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bva-tab.is-active {
  color: var(--c-espresso);
  background: var(--c-cream);
}
.bva-tab.is-active .bva-tab-label { font-weight: 700; }

/* Status pills — shared semantic colors between web + Android */
:root {
  --status-open: #6A9A5C;
  --status-in-progress: #C9A040;
  --status-completed: #8A7B6B;
  --status-cancelled: #A09080;
}
.bva-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  background: rgba(160, 144, 128, 0.15);
  color: var(--status-cancelled);
  text-transform: capitalize;
}
.bva-status-pill[data-status="open"],
.bva-status-pill[data-status="scheduled"] {
  background: rgba(106, 154, 92, 0.15);
  color: var(--status-open);
}
.bva-status-pill[data-status="in_progress"],
.bva-status-pill[data-status="pending"],
.bva-status-pill[data-status="pending_payment"] {
  background: rgba(201, 160, 64, 0.15);
  color: var(--status-in-progress);
}
.bva-status-pill[data-status="completed"] {
  background: rgba(138, 123, 107, 0.15);
  color: var(--status-completed);
}

/* Empty/error states — structured, icon-in-circle + title + subtitle */
.bva-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 20px;
  min-height: 220px;
  gap: 10px;
}
.bva-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--c-cream);
  color: var(--c-espresso);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bva-empty-icon svg { width: 24px; height: 24px; }
.bva-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-family: var(--font-display);
}
.bva-empty-subtitle {
  font-size: 12px;
  color: var(--muted);
  max-width: 260px;
  line-height: 1.4;
}

/* Card-shaped list rows (Jobs / Orders / Requests) */
.bva-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bva-task-card {
  background: var(--c-white);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.bva-task-card:hover {
  border-color: var(--c-caramel, var(--c-espresso));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}
.bva-task-card .bva-task-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.bva-task-card .bva-task-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bva-task-card .bva-task-who {
  font-size: 12px;
  color: var(--muted);
}

/* Schedule — always-on block rendering */
.bva-sched {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bva-sched-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 2px;
}
.bva-sched-heading {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.bva-sched-date {
  font-size: 12px;
  color: var(--muted);
}
.bva-sched-block {
  background: var(--c-white);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
}
.bva-sched-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bva-sched-block-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  text-transform: capitalize;
}
.bva-sched-block-hours {
  font-size: 12px;
  color: var(--muted);
}
.bva-sched-pill {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.bva-sched-pill.is-available {
  background: rgba(106, 154, 92, 0.15);
  color: var(--status-open);
}
.bva-sched-pill.is-unavailable {
  background: rgba(160, 144, 128, 0.15);
  color: var(--status-cancelled);
}
.bva-sched-hour-strip {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}
.bva-sched-hour-cell {
  flex: 1 1 0;
  min-width: 22px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 2px;
  border-radius: 4px;
  color: var(--text, #2a241d);
}
.bva-sched-hour-cell.is-open {
  background: rgba(176, 132, 99, 0.18);
}
.bva-sched-hour-cell.is-booked {
  background: var(--c-caramel, #14B8A6);
  color: #fff;
}
.bva-sched-hour-cell.is-closed {
  background: var(--card2, #faf6ef);
  color: var(--muted, #8c8275);
}
.bva-sched-bookings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--stroke);
}
.bva-sched-booking {
  cursor: pointer;
  padding: 6px 0;
  border-left: 3px solid var(--c-caramel, var(--c-espresso));
  padding-left: 10px;
  transition: border-color 0.15s ease;
}
.bva-sched-booking:hover { border-color: var(--c-espresso); }
.bva-sched-booking-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-espresso);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bva-sched-booking-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  margin-top: 2px;
}
.bva-sched-booking-who {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}
.bva-link-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--c-cream);
  color: var(--c-espresso);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.bva-link-btn:hover { background: var(--c-caramel, var(--c-espresso)); color: var(--c-white); }

/* Card-shape the chat conversation row to match the rest of the list */
.bva-conv {
  background: var(--c-white);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.bva-conv:hover {
  background: var(--c-white);
  border-color: var(--c-caramel, var(--c-espresso));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}
.bva-conv-list { gap: 10px; }

.bva-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.bva-loading,
.bva-empty,
.bva-error {
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.bva-error { color: var(--c-error); }

.bva-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Chat list */
.bva-conv-list { gap: 2px; }
.bva-conv {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.bva-conv:hover { background: var(--glass-hover); }
.bva-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--c-cream);
}
.bva-avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--c-espresso);
  font-weight: 700;
  font-size: 14px;
}
.bva-conv-main { flex: 1; min-width: 0; }
.bva-conv-row1, .bva-conv-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bva-conv-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bva-conv-when {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}
.bva-conv-preview {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bva-unread {
  background: var(--c-error);
  color: var(--c-white);
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Thread host inside panel */
.bva-thread-host,
.bva-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.bva-thread-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 10px 0;
}
.bva-thread-list .chat-message {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.bva-thread-list .chat-message.me { align-self: flex-end; align-items: flex-end; }
.bva-thread-list .chat-message.them { align-self: flex-start; align-items: flex-start; }
.bva-thread-list .message-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}
.bva-thread-list .chat-message.me .message-bubble {
  background: var(--c-espresso);
  color: var(--c-white);
  border-bottom-right-radius: 4px;
}
.bva-thread-list .chat-message.them .message-bubble {
  background: var(--c-white);
  color: var(--ink);
  border: 1px solid var(--stroke);
  border-bottom-left-radius: 4px;
}
.bva-thread-list .message-time {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.bva-thread-list .chat-empty {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 30px 12px;
}

.bva-thread-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--stroke);
}
.bva-thread-input {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  resize: none;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--glass);
  font-size: 13px;
  color: var(--ink);
  outline: none;
  font-family: inherit;
}
.bva-thread-input:focus {
  border-color: var(--c-caramel);
  box-shadow: 0 0 0 3px var(--stroke-accent);
}
.bva-thread-send {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* Schedule */
.bva-sched-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin: 6px 0 8px;
  color: var(--ink);
}
.bva-sched-item {
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 6px;
}
.bva-sched-when {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.bva-sched-who {
  font-size: 12px;
  color: var(--muted);
}
.bva-sched-links {
  margin-top: 12px;
  text-align: center;
}
.bva-link-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.bva-link-btn:hover { background: var(--glass-hover); }

/* Task items (jobs/orders/requests) */
.bva-task-item {
  padding: 10px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s ease;
}
.bva-task-item:hover { background: var(--glass-hover); }
.bva-task-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.bva-task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.bva-task-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  flex-shrink: 0;
}
.bva-task-who {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Mobile: fullscreen panel */
@media (max-width: 780px) {
  .bva-panel {
    right: 0;
    bottom: 0;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
  body.bva-open { overflow: hidden; }
  .bva-fab {
    right: 16px;
    bottom: calc(16px + var(--bva-footer-offset));
  }
}

@media (prefers-reduced-motion: reduce) {
  .bva-panel { animation: none; }
  .bva-fab { transition: none; }
}
