/* === GLASS COMPONENTS === */
/* All CSS variables are defined in base.html :root (injected by theme.py context processor).
   This file provides component classes that USE those variables. */

/* Glass card — standard panel */
.glass {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Stronger blur for overlays */
.glass-heavy {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

/* Brand-tinted glass */
.glass-brand {
  background: var(--brand-tint-bg);
  border: 1px solid var(--brand-tint-border);
  border-radius: 16px;
}

/* Pill badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-brand  { background: var(--brand-tint-bg);  color: var(--brand-light); border: 1px solid var(--brand-tint-border); }
.badge-orange { background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.25); }
.badge-red    { background: rgba(239,68,68,0.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.badge-green  { background: rgba(34,197,94,0.12);  color: #86efac; border: 1px solid rgba(34,197,94,0.25); }
.badge-blue   { background: rgba(59,130,246,0.12);  color: #93c5fd; border: 1px solid rgba(59,130,246,0.25); }
.badge-purple { background: rgba(124,58,237,0.12);  color: #c4b5fd; border: 1px solid rgba(124,58,237,0.25); }
.badge-muted  { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 10px;
  font-family: 'Public Sans', 'Public Sans', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover  { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: scale(0.95); opacity: 0.7; }

.btn-brand  { background: var(--brand-gradient); color: #fff; }
.btn-primary{ background: var(--brand-gradient); color: #fff; }
.btn-orange { background: linear-gradient(135deg, #f97316, #fb923c); color: #fff; }
.btn-ghost  { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid rgba(255,255,255,0.10); }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.btn-sm     { padding: 0.4rem 0.875rem; font-size: 0.8125rem; border-radius: 8px; }
.btn-lg     { padding: 0.875rem 1.75rem; font-size: 1rem; border-radius: 12px; }
.btn-icon   { padding: 0.5rem; border-radius: 8px; }

/* Form inputs */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}
.field label {
  font-size: 0.8125rem;
  font-weight: 600;
  /* Was rgba(255,255,255,0.7) — invisible on cream Bone surface.
     Use ink with light muting so labels read on cream AND on dark. */
  color: var(--text, #0F1623);
  opacity: 0.78;
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  /* Was white-translucent — invisible inputs on cream. Switch to a
     faint-ink box that reads on both surfaces, then turns crisp white
     on focus with the brand-orange ring. */
  background: rgba(15,22,35,0.04);
  border: 1px solid rgba(15,22,35,0.12);
  color: var(--text, #0F1623);
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  font-family: 'Public Sans', 'Public Sans', sans-serif;
  font-size: 0.9375rem;
  width: 100%;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--text, #0F1623);
  background: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(234,106,44,0.20);
}
.field input::placeholder,
.field textarea::placeholder {
  color: rgba(15,22,35,0.42);
}

/* Checkboxes & radios must keep their NATIVE control. The `appearance:none`
   above (intended for text inputs) otherwise strips the tick + sizes them as
   a full-width box, so they look like they never check — this is why the
   inventory "Featured" toggle wouldn't check off when tapped. Restore the
   native control and brand the tick. */
.field input[type="checkbox"],
.field input[type="radio"] {
  -webkit-appearance: auto;
  appearance: auto;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 0;
  border-radius: 0;
  background: none;
  border: 0;
  box-shadow: none;
  flex: none;
  accent-color: var(--linq-orange, #EA6A2C);
}
.field input[type="checkbox"]:focus,
.field input[type="radio"]:focus {
  background: none;
  box-shadow: none;
}

/* Select custom arrow — ink chevron on cream surface */
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='rgba(15,22,35,0.42)' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Light scheme so native dropdowns and date pickers render on cream. */
.field select,
.field input[type="date"],
.field input[type="time"],
.field input[type="datetime-local"] {
  color-scheme: light;
}
.field select option {
  background: #FFFFFF;
  color: var(--text, #0F1623);
}

/* Standalone form controls (outside .field wrapper) */
select, input[type="date"] {
  color-scheme: light;
}
select:not(.field select) {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  color: #fff;
  font-family: 'Public Sans', 'Public Sans', sans-serif;
  font-size: 0.875rem;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='rgba(255,255,255,0.4)' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}
select:not(.field select) option {
  background: #1a1f2e;
  color: #fff;
}
select:not(.field select):focus {
  outline: none;
  border-color: var(--brand);
  background-color: rgba(255,255,255,0.08);
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header-left .eyebrow {
  color: var(--text-faint);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.page-header-left h1 {
  font-family: 'Public Sans', sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: #fff;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table th {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0.625rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.9rem;
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s, opacity 0.1s; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table tbody tr:active { opacity: 0.7; background: rgba(255,255,255,0.06); }

/* Responsive page wrapper */
.page {
  padding: 1.5rem;
}
@media (min-width: 641px) and (max-width: 1023px) {
  .page { padding: 1.25rem 1.25rem 2rem; }  /* tablet */
}
@media (max-width: 640px) {
  /* Bottom padding leaves room for the floating FAB-menu (3.75rem +
     1rem inset + safe-area) so it never covers final-row content. */
  .page { padding: 1rem 0.875rem calc(6rem + env(safe-area-inset-bottom, 0px)); }
}

/* Tablet data-table: tighter spacing, smaller text */
@media (min-width: 641px) and (max-width: 1023px) {
  .data-table th {
    padding: 0.5rem 0.625rem;
    font-size: 0.625rem;
  }
  .data-table td {
    padding: 0.625rem 0.625rem;
    font-size: 0.8125rem;
  }
  /* Hide low-priority columns on tablet */
  .data-table .hide-tablet { display: none; }
  /* Page header: stack if needed */
  .page-header { flex-wrap: wrap; }
  .page-header-left h1 { font-size: 1.25rem; }
}
@media (max-width: 640px) {
  .data-table th {
    padding: 0.375rem 0.5rem;
    font-size: 0.6rem;
  }
  .data-table td {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
  }
  .data-table .hide-mobile { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .page-header-left h1 { font-size: 1.125rem; }
}

/* Stat number */
.stat { font-weight: 800; color: var(--brand-light); }

/* Divider */
.divider { height: 1px; background: rgba(255,255,255,0.06); margin: 1.5rem 0; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
  gap: 0.75rem;
}
.empty-state i {
  font-size: 2.5rem;
  color: rgba(255,255,255,0.15);
}
.empty-state p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* === ENHANCED GLASS EFFECTS === */

/* Glass card with hover glow */
.glass-glow {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.glass-glow:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.05);
  transform: translateY(-2px);
}

/* Bubbly icon container */
.icon-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: var(--brand-tint-bg);
  color: var(--brand-light);
  font-size: 1.125rem;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.15s;
}
.icon-bubble:hover { transform: scale(1.08); }
.icon-bubble-sm { width: 2rem; height: 2rem; border-radius: 10px; font-size: 0.95rem; }
.icon-bubble-lg { width: 3rem; height: 3rem; border-radius: 14px; font-size: 1.375rem; }
.icon-bubble.orange { background: rgba(249,115,22,0.12); color: #fb923c; }
.icon-bubble.purple { background: rgba(124,58,237,0.12); color: #c4b5fd; }
.icon-bubble.green  { background: rgba(34,197,94,0.12);  color: #86efac; }
.icon-bubble.blue   { background: rgba(59,130,246,0.12); color: #93c5fd; }
.icon-bubble.red    { background: rgba(239,68,68,0.12);  color: #fca5a5; }

/* Glass stat card with gradient accent */
.glass-stat {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
}
.glass-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-gradient);
  border-radius: 16px 16px 0 0;
}

/* === PULL TO REFRESH === */

.ptr-indicator {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%) translateY(-60px);
  z-index: 500;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(22,28,45,0.95);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
  pointer-events: none;
}
.ptr-indicator i {
  font-size: 1.125rem;
  color: var(--brand-light);
  transition: transform 0.2s;
}
.ptr-indicator.pulling { transform: translateX(-50%) translateY(16px); }
.ptr-indicator.triggered i { transform: rotate(180deg); }
.ptr-indicator.refreshing i {
  animation: ptr-spin 0.6s linear infinite;
}
@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === SWIPE ACTIONS === */

.swipe-container {
  position: relative;
  overflow: hidden;
}
.swipe-content {
  position: relative;
  z-index: 1;
  transition: transform 0.2s ease;
  background: inherit;
}
.swipe-actions-left,
.swipe-actions-right {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  z-index: 0;
}
.swipe-actions-left { left: 0; }
.swipe-actions-right { right: 0; }

.swipe-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 100%;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  flex-direction: column;
  gap: 0.2rem;
}
.swipe-action i { font-size: 1.125rem; }
.swipe-action.swipe-delete { background: rgba(239,68,68,0.85); }
.swipe-action.swipe-archive { background: rgba(249,115,22,0.85); }
.swipe-action.swipe-complete { background: rgba(34,197,94,0.85); }

/* ================================================================
   WhatsApp-style Messages — 2-column persistent sidebar layout
   ================================================================ */
.wa-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  /* Use dvh so mobile browser chrome shrinks the layout instead of the reply bar */
  height: calc(100dvh - 60px);
  overflow: hidden;
}

/* Tablets (641-1023px): the floating pill header is fixed at the top
   (~76px) but .main only adds top padding for it on phones. Push the
   layout below the pill and subtract its height so nothing overlaps,
   and keep the 2-column view (8" tablets in portrait still get a real
   sidebar + thread side-by-side). */
@media (max-width: 1023px) and (min-width: 641px) {
  .wa-layout {
    /* .main has 1rem padding all around at this size; add the pill
       header offset on top of that so the layout starts below it. */
    margin-top: 60px;
    height: calc(100dvh - 60px - 2rem);
  }
}

/* Narrower tablets (641-820px): shrink the conversations sidebar so the
   thread panel still has breathing room. */
@media (max-width: 820px) and (min-width: 641px) {
  .wa-layout { grid-template-columns: 280px 1fr; }
}

/* Phones (≤640px): stack to a single column (sidebar OR thread) and
   reserve space for the pill header (5rem) and the bottom viobar
   (60px + safe area) so the .wa-reply send button is never hidden. */
@media (max-width: 640px) {
  .wa-layout { grid-template-columns: 1fr; }
  .wa-layout .wa-thread-wrap { display: none; }
  .wa-layout.has-thread .wa-sidebar { display: none; }
  .wa-layout.has-thread .wa-thread-wrap { display: flex; }
  .wa-layout {
    height: calc(100dvh - 5rem - 1rem - 60px - env(safe-area-inset-bottom, 0px));
  }
}

/* Sidebar (left panel — always visible) */
.wa-sidebar {
  border-right: 1px solid var(--card-border);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card-bg);
}
.wa-sidebar-header { padding: 0.875rem 1rem 0.5rem; flex-shrink: 0; }
.wa-sidebar-header h1 { font-size: 1.3rem; font-weight: 700; margin: 0; }

/* Tab bar */
.wa-tabs { display: flex; border-bottom: 1px solid var(--card-border); }
.wa-tab {
  flex: 1; padding: 0.6rem 0; text-align: center;
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none; transition: all 0.2s;
}
.wa-tab:hover { color: rgba(255,255,255,0.8); }
.wa-tab.active { color: #25d366; border-bottom-color: #25d366; }

/* Search */
.wa-search { padding: 0.5rem 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
.wa-search-wrap { position: relative; }
.wa-search-wrap i {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.3); font-size: 0.82rem;
}
.wa-search-input {
  width: 100%; background: rgba(255,255,255,0.06);
  border: none; border-radius: 20px;
  padding: 0.5rem 0.75rem 0.5rem 2.25rem;
  color: #fff; font-size: 0.82rem;
}
.wa-search-input:focus { outline: none; background: rgba(255,255,255,0.09); }
.wa-search-input::placeholder { color: rgba(255,255,255,0.3); }

.wa-list { overflow-y: auto; flex: 1; }

/* Conversation rows */
.wa-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer; text-decoration: none; color: inherit;
  transition: background 0.12s;
}
.wa-row:hover, .wa-row.active { background: rgba(255,255,255,0.05); }
.wa-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #128c7e, #25d366);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0; color: #fff;
}
.wa-avatar-customer { background: linear-gradient(135deg, #667eea, #764ba2); }
.wa-avatar-group { background: linear-gradient(135deg, #667eea, #764ba2); }
.wa-info { flex: 1; min-width: 0; }
.wa-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.wa-name {
  font-weight: 600; font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.wa-time { font-size: 0.68rem; flex-shrink: 0; color: var(--text-faint); }
.wa-time.has-unread { color: #25d366; font-weight: 600; }
.wa-bottom { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.1rem; }
.wa-preview {
  font-size: 0.8rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.wa-preview.unread { color: rgba(255,255,255,0.85); }
.wa-badge {
  background: #25d366; color: #000; font-size: 0.65rem; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}

/* New chat form (team sidebar) */
.wa-new-form { padding: 0.75rem 1rem; border-top: 1px solid var(--card-border); }
.wa-new-form select,
.wa-new-form textarea {
  width: 100%; margin-bottom: 0.5rem;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 0.5rem 0.75rem;
  color: #fff; font-size: 0.82rem; font-family: 'Public Sans', 'Public Sans', sans-serif;
  color-scheme: dark;
}
.wa-new-form select:focus,
.wa-new-form textarea:focus { outline: none; background: rgba(255,255,255,0.09); border-color: var(--brand-light); }
.wa-new-form select option { background: #1a1f2e; color: #fff; }

/* Thread panel (right side) */
.wa-thread-wrap {
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--body-bg);
}
.wa-thread-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; gap: 0.75rem;
  color: var(--text-faint); font-size: 0.85rem;
}
.wa-empty-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(37,211,102,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #25d366;
}

/* Chat header */
.wa-chat-header {
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0;
  background: var(--card-bg);
}
.wa-hdr-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.75rem; color: #fff; flex-shrink: 0;
}
.wa-hdr-name { font-weight: 700; font-size: 0.95rem; }
.wa-hdr-sub { font-size: 0.72rem; color: var(--text-faint); }

/* Chat messages area */
.wa-messages {
  flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  background: radial-gradient(ellipse at 20% 50%, rgba(37,211,102,0.02) 0%, transparent 70%),
              radial-gradient(ellipse at 80% 50%, rgba(102,126,234,0.02) 0%, transparent 70%);
}
.wa-date-sep {
  align-self: center; padding: 0.25rem 0.75rem;
  background: rgba(0,0,0,0.3); border-radius: 6px;
  font-size: 0.7rem; color: rgba(255,255,255,0.55); margin: 0.5rem 0;
}
.wa-msg { display: flex; margin-bottom: 0.125rem; }
.wa-msg.outbound, .wa-msg.mine { justify-content: flex-end; }
.wa-msg.inbound, .wa-msg.theirs { justify-content: flex-start; }
.wa-bubble {
  max-width: 65%; padding: 0.5rem 0.625rem 0.25rem;
  border-radius: 8px; font-size: 0.875rem; line-height: 1.45;
  position: relative; word-wrap: break-word;
}
.wa-msg.inbound .wa-bubble,
.wa-msg.theirs .wa-bubble {
  background: var(--card-bg); border-top-left-radius: 0;
}
.wa-msg.outbound .wa-bubble,
.wa-msg.mine .wa-bubble {
  background: rgba(0,92,75,0.55); border-top-right-radius: 0;
}
.wa-msg.inbound.tail .wa-bubble::before,
.wa-msg.theirs.tail .wa-bubble::before {
  content: ''; position: absolute; top: 0; left: -8px;
  border-width: 0 8px 8px 0; border-style: solid;
  border-color: transparent var(--card-bg) transparent transparent;
}
.wa-msg.outbound.tail .wa-bubble::after,
.wa-msg.mine.tail .wa-bubble::after {
  content: ''; position: absolute; top: 0; right: -8px;
  border-width: 0 0 8px 8px; border-style: solid;
  border-color: transparent transparent transparent rgba(0,92,75,0.55);
}
.wa-sender {
  font-size: 0.7rem; font-weight: 600; color: #25d366; margin-bottom: 0.1rem;
}
.wa-bubble-footer {
  display: inline-flex; align-items: center; justify-content: flex-end;
  gap: 0.25rem; margin-top: 0.15rem;
  font-size: 0.62rem; color: rgba(255,255,255,0.45);
  float: right; margin-left: 0.75rem;
  position: relative; top: 0.25rem;
}
.wa-bubble-footer .bi { font-size: 0.78rem; }
.wa-check-read { color: #53bdeb; }
.wa-check-sent { color: rgba(255,255,255,0.35); }
.wa-check-fail { color: #ef4444; }
.wa-bubble-media { margin-top: 0.4rem; max-width: 100%; border-radius: 6px; display: block; }

/* Reply bar */
.wa-reply {
  border-top: 1px solid var(--card-border);
  padding: 0.65rem 0.75rem;
  padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
  background: var(--card-bg); flex-shrink: 0;
}
.wa-reply-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.wa-reply-input {
  flex: 1; background: rgba(255,255,255,0.06);
  border: none; border-radius: 20px;
  color: #fff; padding: 0.6rem 1rem; font-size: 0.875rem;
  font-family: 'Public Sans', 'Public Sans', sans-serif; resize: none;
  min-height: 42px; max-height: 120px; line-height: 1.45;
}
.wa-reply-input:focus { outline: none; background: rgba(255,255,255,0.09); }
.wa-reply-input::placeholder { color: rgba(255,255,255,0.3); }
.wa-send-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: #25d366; border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s; flex-shrink: 0;
}
.wa-send-btn:hover { background: #1fa855; }
.wa-send-btn i { font-size: 1rem; }
.wa-mic-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.06); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.wa-mic-btn:hover { background: rgba(255,255,255,0.12); }
.wa-mic-btn[hidden] { display: none; }
.wa-mic-btn.recording {
  background: #ef4444; color: #fff;
  animation: wa-mic-pulse 1.2s ease-in-out infinite;
}
.wa-mic-btn i { font-size: 1.05rem; }
@keyframes wa-mic-pulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 0   rgba(239,68,68,0.55); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(239,68,68,0);    }
}

/* Pagination */
.wa-paginate {
  padding: 0.5rem 1rem; border-top: 1px solid var(--card-border);
  display: flex; gap: 0.5rem; justify-content: center; align-items: center;
}

/* ================================================================
   Invoice line-item modal (Add / Edit) — opened from /invoicing/<id>
   ================================================================ */
.li-modal {
  position: fixed; inset: 0;
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.li-modal[hidden] { display: none; }
.li-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.li-modal-panel {
  position: relative;
  background: var(--card-bg, #1a2236);
  color: var(--text, #fff);
  border: 1px solid var(--card-border, rgba(255,255,255,0.08));
  border-radius: 18px;
  width: 100%; max-width: 560px;
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 48px rgba(0,0,0,0.45);
}
.li-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border, rgba(255,255,255,0.08));
}
.li-modal-header h2 { margin: 0; font-size: 1.1rem; font-weight: 700; }
.li-modal-close {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
}
.li-modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text, #fff); }

.li-tabs {
  display: flex;
  border-bottom: 1px solid var(--card-border, rgba(255,255,255,0.08));
  padding: 0 .5rem;
}
.li-tab {
  background: none; border: none; cursor: pointer;
  padding: .7rem .9rem;
  font-size: .8rem; font-weight: 600;
  color: var(--text-muted, rgba(255,255,255,0.55));
  border-bottom: 2px solid transparent;
}
.li-tab.active {
  color: var(--brand-light, #14b8a6);
  border-bottom-color: var(--brand-light, #14b8a6);
}

.li-modal-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: .75rem;
}
.li-field { display: flex; flex-direction: column; gap: .3rem; }
.li-label {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted, rgba(255,255,255,0.55));
}
.li-modal input[type="text"],
.li-modal input[type="number"],
.li-modal select,
.li-modal textarea {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text, #fff);
  border-radius: 10px;
  padding: .55rem .75rem;
  font: inherit;
  font-size: .9rem;
}
.li-modal input:focus, .li-modal select:focus, .li-modal textarea:focus {
  outline: none;
  border-color: var(--brand-light, #14b8a6);
  background: rgba(255,255,255,0.09);
}
.li-modal textarea { resize: vertical; min-height: 92px; }

.li-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .6rem;
}
@media (max-width: 540px) { .li-grid-4 { grid-template-columns: repeat(2, 1fr); } }

.li-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .25rem 0;
  font-size: .9rem; font-weight: 500;
}
.li-toggle {
  position: relative;
  display: inline-block; width: 44px; height: 24px;
}
.li-toggle input { opacity: 0; width: 0; height: 0; }
.li-toggle-knob {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(255,255,255,0.18);
  border-radius: 24px; transition: background .2s;
}
.li-toggle-knob::before {
  content: ''; position: absolute;
  height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.li-toggle input:checked + .li-toggle-knob { background: #25d366; }
.li-toggle input:checked + .li-toggle-knob::before { transform: translateX(20px); }

.li-modal-footer {
  display: flex; justify-content: flex-end; gap: .5rem;
  padding-top: .25rem;
  border-top: 1px solid var(--card-border, rgba(255,255,255,0.06));
  margin-top: .25rem;
  padding-top: .85rem;
}

.li-row:hover { background: rgba(255,255,255,0.04); }
