/* ═══════════════════════════════════════════════════════════════════════════
   app-enterprise.css — Enterprise visual upgrade layer for Sayl CRM app shell
   Loaded AFTER app.css to layer enhancements without replacing the base system.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ──────────────────────────────────────────────────── */
:root {
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);
  --shadow-xl:    0 20px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-teal:  0 4px 16px rgba(14,159,135,0.25);
  --shadow-teal-lg: 0 8px 32px rgba(14,159,135,0.30);
  --gradient-brand: linear-gradient(135deg, #0e9f87 0%, #0a7a67 100%);
  --gradient-brand-shine: linear-gradient(135deg, #4df5c8 0%, #0e9f87 50%, #0a7a67 100%);
  --gradient-accent: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-surface: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  --easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --border-subtle: 1px solid rgba(0,0,0,0.06);
  --color-teal: #0e9f87;
  --color-teal-dark: #0a7a67;
  --color-teal-light: #e6f7f4;
  --color-sidebar: #033a2d;
}

/* ─────────────────────────────────────────────────────────────────────────
   GLOBAL BASE
   ───────────────────────────────────────────────────────────────────────── */

body {
  background-color: #f8fafb;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ─────────────────────────────────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────────────────────────────────── */

.sidebar {
  background: #033a2d !important;
  border-inline-end: 1px solid rgba(255,255,255,0.04) !important;
  box-shadow: none;
}

/* Logo area */
.sidebar-brand {
  background: transparent !important;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}
.sidebar-brand-admin {
  background: transparent !important;
}
.sidebar-brand-admin:hover { background: rgba(255,255,255,0.05) !important; }
.sidebar-brand-name { color: #ffffff !important; }
.sidebar-brand-sub { color: rgba(255,255,255,0.38) !important; }
.sidebar-brand-icon {
  background: #0e9f87 !important;
  backdrop-filter: none;
}
.sidebar-brand:hover { background: rgba(255,255,255,0.04) !important; }

/* Section labels */
.sidebar nav > p {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.26);
  padding-inline: 0.75rem;
  padding-block: 0.625rem 0.3125rem;
  margin-top: 0.25rem;
}

/* Nav items */
.nav-item {
  position: relative;
  border-radius: 9px !important;
  margin-inline: 0.25rem;
  padding: 0.5rem 0.75rem !important;
  gap: 0.625rem;
  color: rgba(255,255,255,0.58) !important;
  transition: background 0.14s, color 0.14s !important;
  overflow: hidden;
}
.nav-item::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #4df5c8;
  opacity: 0;
  transform: scaleY(0);
  transition: opacity 0.14s, transform 0.18s var(--easing-spring);
}
[dir="rtl"] .nav-item::before {
  border-radius: 3px 0 0 3px;
}
.nav-item:hover {
  background: rgba(255,255,255,0.07) !important;
  color: #ffffff !important;
  transform: none;
}

.nav-item.active {
  background: rgba(255,255,255,0.14) !important;
  color: #ffffff !important;
  font-weight: 600;
}
.nav-item.active::before {
  opacity: 1;
  transform: scaleY(1);
}
.nav-item svg {
  transition: none;
  flex-shrink: 0;
}
.nav-item.active svg { color: #4df5c8 !important; }

/* User profile at bottom */
.sidebar-profile {
  background: transparent;
  border-top: 1px solid rgba(255,255,255,0.07) !important;
}
.sidebar-profile-card {
  background: rgba(0,0,0,0.16) !important;
  border: none !important;
  box-shadow: none;
}
.sidebar-profile-card:hover {
  background: rgba(0,0,0,0.24) !important;
}
.sidebar-profile-card .text-xs { color: #ffffff !important; }
.sidebar-profile-card .text-\[10px\] { color: rgba(255,255,255,0.38) !important; }
.sidebar-profile-card .text-gray-400 { color: rgba(255,255,255,0.28) !important; }
.sidebar-profile-card .hover\:text-red-500:hover { color: #fca5a5 !important; }
.sidebar-profile-card .hover\:bg-red-50:hover { background: rgba(239,68,68,0.15) !important; }

/* ─────────────────────────────────────────────────────────────────────────
   TOPBAR
   ───────────────────────────────────────────────────────────────────────── */

.topbar {
  position: relative;
  z-index: 20;
  background: rgba(255,255,255,0.95) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  height: 3.75rem !important;
}

/* Search in topbar */
.topbar input[type="text"] {
  background: #f8fafb !important;
  border: 1px solid #edf2f7 !important;
  border-radius: 9px !important;
  font-size: 0.8125rem !important;
  height: 2.25rem !important;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s !important;
}
.topbar input[type="text"]:focus {
  background: #ffffff !important;
  border-color: rgba(14,159,135,0.35) !important;
  box-shadow: 0 0 0 3px rgba(14,159,135,0.08) !important;
}

/* Icon buttons in topbar */
.topbar button[type="button"],
.topbar a[href="/logout"] {
  border-radius: 9px !important;
  transition: background 0.18s, transform 0.15s var(--easing-spring) !important;
}
.topbar button[type="button"]:hover,
.topbar a[href="/logout"]:hover {
  background: rgba(14,159,135,0.08) !important;
  color: #0e9f87 !important;
  transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--gradient-brand) !important;
  box-shadow: var(--shadow-teal);
  border-radius: 10px !important;
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  transition: box-shadow 0.2s, transform 0.15s var(--easing-spring), background 0.2s !important;
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0e9f87 0%, #0a7a67 100%) !important;
  box-shadow: var(--shadow-teal-lg) !important;
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.97) translateY(0) !important; box-shadow: var(--shadow-teal) !important; }

.btn-secondary {
  border-radius: 10px !important;
  border: 1px solid rgba(0,0,0,0.10) !important;
  background: #ffffff !important;
  box-shadow: var(--shadow-xs);
  font-weight: 500 !important;
  transition: box-shadow 0.2s, transform 0.15s var(--easing-spring), background 0.18s !important;
}
.btn-secondary:hover {
  background: #F8FAFC !important;
  border-color: rgba(0,0,0,0.14) !important;
  box-shadow: var(--shadow-sm) !important;
  transform: translateY(-1px);
}
.btn-secondary:active { transform: scale(0.97) translateY(0) !important; }

.btn-danger {
  border-radius: 10px !important;
  transition: box-shadow 0.2s, transform 0.15s var(--easing-spring) !important;
}
.btn-danger:hover { box-shadow: 0 4px 12px rgba(239,68,68,0.25) !important; transform: translateY(-1px); }

/* ─────────────────────────────────────────────────────────────────────────
   FORM INPUTS
   ───────────────────────────────────────────────────────────────────────── */

.input {
  border-radius: 10px !important;
  border: 1px solid rgba(0,0,0,0.10) !important;
  background: #ffffff !important;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s !important;
  font-size: 0.875rem !important;
  color: #1a202c !important;
}
.input:hover:not(:focus) { border-color: rgba(0,0,0,0.16) !important; }
.input:focus {
  border-color: rgba(14,159,135,0.45) !important;
  box-shadow: 0 0 0 3px rgba(14,159,135,0.10), var(--shadow-xs) !important;
  background: #ffffff !important;
}
.input::placeholder { color: #a0aec0 !important; }

.label {
  font-weight: 600 !important;
  font-size: 0.8125rem !important;
  color: #374151 !important;
  margin-bottom: 0.4rem !important;
}

/* Select inputs */
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='1.7' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 16px;
  padding-right: 2.5rem !important;
}
[dir="rtl"] select.input {
  background-position: left 0.75rem center;
  padding-right: 0.75rem !important;
  padding-left: 2.5rem !important;
}

/* Textarea */
textarea.input { resize: vertical; min-height: 5rem; }

/* ─────────────────────────────────────────────────────────────────────────
   CARDS
   ───────────────────────────────────────────────────────────────────────── */

.card {
  border-radius: 14px !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: var(--shadow-sm) !important;
  background: #ffffff !important;
  transition: box-shadow 0.25s, transform 0.2s var(--easing-smooth) !important;
}
.card:hover {
  box-shadow: var(--shadow-md) !important;
}

.card-header {
  border-bottom: 1px solid rgba(0,0,0,0.06) !important;
  font-weight: 700 !important;
  font-size: 0.8125rem !important;
  letter-spacing: 0.01em;
  color: #111827 !important;
  padding: 1rem 1.25rem !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   KPI CARDS
   ───────────────────────────────────────────────────────────────────────── */

.kpi {
  border-radius: 16px !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: var(--shadow-sm) !important;
  background: #ffffff !important;
  transition: box-shadow 0.25s, transform 0.2s var(--easing-smooth) !important;
  overflow: hidden;
  position: relative;
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-brand);
  opacity: 0;
  transition: opacity 0.25s;
}
.kpi:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-2px) !important;
}
.kpi:hover::before { opacity: 1; }

.kpi-value {
  font-size: 2rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #111827 0%, #374151 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-label {
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.09em !important;
  color: #9ca3af !important;
  text-transform: uppercase;
}
.kpi-pulse {
  border-radius: 12px !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   PAGE HERO
   ───────────────────────────────────────────────────────────────────────── */

.page-hero {
  border-radius: 16px !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden;
  position: relative;
}
.page-hero::before {
  background:
    radial-gradient(ellipse at top right, rgba(14,159,135,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at bottom left, rgba(217,119,6,0.10) 0%, transparent 55%),
    radial-gradient(ellipse at center, rgba(99,102,241,0.04) 0%, transparent 70%) !important;
}

/* Mesh dot overlay on page hero */
.page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  opacity: 0.4;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #0e9f87;
  background: rgba(14,159,135,0.08);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  border: 1px solid rgba(14,159,135,0.15);
}

.page-title { font-size: 1.375rem !important; font-weight: 800 !important; letter-spacing: -0.015em !important; }
.page-subtitle { font-size: 0.875rem !important; color: #6b7280 !important; }

/* ─────────────────────────────────────────────────────────────────────────
   TABLE
   ───────────────────────────────────────────────────────────────────────── */

.table-base { border-spacing: 0; width: 100% !important; }

.table-base thead tr {
  background: linear-gradient(180deg, #F8FAFC 0%, #F1F4F9 100%) !important;
}
.table-base thead th {
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.07em !important;
  color: #6b7280 !important;
  border-bottom: 1px solid rgba(0,0,0,0.08) !important;
  padding: 0.75rem 1rem !important;
  white-space: nowrap;
}
.table-base tbody tr {
  transition: background 0.15s !important;
  border-bottom: 1px solid rgba(0,0,0,0.04) !important;
}
.table-base tbody tr:last-child { border-bottom: none !important; }
.table-base tbody tr:hover { background: rgba(14,159,135,0.03) !important; }
.table-base tbody td {
  padding: 0.875rem 1rem !important;
  color: #374151 !important;
  font-size: 0.875rem !important;
  vertical-align: middle;
}

/* ─────────────────────────────────────────────────────────────────────────
   BADGES
   ───────────────────────────────────────────────────────────────────────── */

.badge {
  border-radius: 999px !important;
  font-weight: 600 !important;
  font-size: 0.6875rem !important;
  letter-spacing: 0.01em;
  padding: 0.2rem 0.625rem !important;
}
.badge-primary  { background: rgba(14,159,135,0.10) !important; color: #0e9f87 !important; border: 1px solid rgba(14,159,135,0.15) !important; }
.badge-accent   { background: rgba(217,119,6,0.10)  !important; color: #D97706 !important; border: 1px solid rgba(217,119,6,0.15)  !important; }
.badge-success  { background: rgba(34,197,94,0.10)  !important; color: #16a34a !important; border: 1px solid rgba(34,197,94,0.15)  !important; }
.badge-warning  { background: rgba(234,179,8,0.10)  !important; color: #a16207 !important; border: 1px solid rgba(234,179,8,0.15)  !important; }
.badge-danger   { background: rgba(239,68,68,0.10)  !important; color: #dc2626 !important; border: 1px solid rgba(239,68,68,0.15)  !important; }
.badge-neutral  { background: rgba(107,114,128,0.10) !important; color: #4b5563 !important; border: 1px solid rgba(107,114,128,0.12) !important; }

/* ─────────────────────────────────────────────────────────────────────────
   SEGMENTED NAV
   ───────────────────────────────────────────────────────────────────────── */

.seg-nav {
  border-radius: 14px !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  background: #F1F4F9 !important;
  box-shadow: none !important;
  padding: 4px !important;
}
.seg-item {
  border-radius: 10px !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  color: #6b7280 !important;
  transition: all 0.18s !important;
  padding: 0.45rem 0.875rem !important;
}
.seg-item:hover:not(.active) { background: rgba(255,255,255,0.7) !important; color: #111827 !important; }
.seg-item.active {
  background: #ffffff !important;
  color: #0e9f87 !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10) !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   CHIPS / FILTER
   ───────────────────────────────────────────────────────────────────────── */

.chip {
  border-radius: 999px !important;
  font-weight: 500 !important;
  transition: all 0.18s !important;
  border-color: rgba(0,0,0,0.10) !important;
  box-shadow: var(--shadow-xs);
}
.chip:hover { border-color: rgba(14,159,135,0.25) !important; background: rgba(14,159,135,0.04) !important; }
.chip.active { background: rgba(14,159,135,0.10) !important; border-color: rgba(14,159,135,0.25) !important; color: #0e9f87 !important; }

/* ─────────────────────────────────────────────────────────────────────────
   ALERT / FEEDBACK
   ───────────────────────────────────────────────────────────────────────── */

.alert-success,
.alert-error,
.alert-info {
  border-radius: 12px !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
}
.alert-success { border-color: rgba(34,197,94,0.2) !important; }
.alert-error   { border-color: rgba(239,68,68,0.2) !important; }
.alert-info    { border-color: rgba(14,159,135,0.2) !important; }

/* ─────────────────────────────────────────────────────────────────────────
   AVATAR
   ───────────────────────────────────────────────────────────────────────── */

.avatar {
  box-shadow: 0 0 0 2px #ffffff, 0 2px 6px rgba(0,0,0,0.12) !important;
  transition: transform 0.18s var(--easing-spring);
}
.avatar:hover { transform: scale(1.08); }

/* ─────────────────────────────────────────────────────────────────────────
   EMPTY STATE
   ───────────────────────────────────────────────────────────────────────── */

.empty {
  padding: 4rem 2rem !important;
}
.empty-icon {
  width: 4.5rem !important;
  height: 4.5rem !important;
  border-radius: 20px !important;
  background: linear-gradient(135deg, rgba(14,159,135,0.08) 0%, rgba(14,159,135,0.16) 100%) !important;
  box-shadow: 0 4px 20px rgba(14,159,135,0.12);
  transition: transform 0.25s var(--easing-spring);
}
.empty:hover .empty-icon { transform: scale(1.05) rotate(-3deg); }
.empty-title { font-size: 1rem !important; font-weight: 700 !important; color: #111827 !important; }
.empty-sub { font-size: 0.875rem !important; color: #9ca3af !important; }

/* ─────────────────────────────────────────────────────────────────────────
   STAT CARD
   ───────────────────────────────────────────────────────────────────────── */

.stat-card {
  border-radius: 14px !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: box-shadow 0.25s, transform 0.2s var(--easing-smooth) !important;
}
.stat-card:hover { box-shadow: var(--shadow-md) !important; transform: translateY(-1px); }
.stat-value { font-weight: 800 !important; letter-spacing: -0.02em !important; }
.stat-icon { border-radius: 12px !important; }

/* ─────────────────────────────────────────────────────────────────────────
   DROPDOWN MENUS
   ───────────────────────────────────────────────────────────────────────── */

.topbar [class*="rounded-xl"][class*="shadow-lg"],
[class*="rounded-xl"][class*="shadow-lg"][class*="border-gray-100"] {
  border-radius: 14px !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06) !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   ICON TILE
   ───────────────────────────────────────────────────────────────────────── */

.icon-tile {
  border-radius: 12px !important;
  transition: transform 0.18s var(--easing-spring) !important;
}
.icon-tile:hover { transform: scale(1.05); }

/* ─────────────────────────────────────────────────────────────────────────
   PROGRESS
   ───────────────────────────────────────────────────────────────────────── */

.progress {
  border-radius: 999px !important;
  background: rgba(0,0,0,0.06) !important;
  height: 6px !important;
}
.progress > span {
  background: var(--gradient-brand) !important;
  border-radius: 999px !important;
  box-shadow: 0 0 8px rgba(14,159,135,0.35);
}

/* ─────────────────────────────────────────────────────────────────────────
   SCROLLBARS (Webkit)
   ───────────────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ─────────────────────────────────────────────────────────────────────────
   CONVERSATION BUBBLES
   ───────────────────────────────────────────────────────────────────────── */

.msg-inbound {
  border-radius: 16px 16px 16px 4px !important;
  box-shadow: var(--shadow-xs) !important;
  border: 1px solid rgba(0,0,0,0.07) !important;
}
.msg-outbound {
  border-radius: 16px 16px 4px 16px !important;
  background: var(--gradient-brand) !important;
  box-shadow: 0 2px 8px rgba(14,159,135,0.25) !important;
}
[dir="rtl"] .msg-inbound  { border-radius: 16px 16px 4px 16px !important; }
[dir="rtl"] .msg-outbound { border-radius: 16px 16px 16px 4px !important; }

/* ─────────────────────────────────────────────────────────────────────────
   SIDEBAR MOBILE BACKDROP
   ───────────────────────────────────────────────────────────────────────── */

.sidebar-backdrop { backdrop-filter: blur(4px); background: rgba(0,0,0,0.35) !important; }

/* ─────────────────────────────────────────────────────────────────────────
   PAGE CONTENT WRAPPER — consistent inner padding
   ───────────────────────────────────────────────────────────────────────── */

main > div { /* each page's content div */
  min-height: calc(100vh - 3.75rem);
}

/* ─────────────────────────────────────────────────────────────────────────
   MOBILE VIEWPORT HEIGHT FIX (dvh)
   ─────────────────────────────────────────────────────────────────────────
   Problem: mobile browsers (iOS Safari, Chrome Android) define 100vh as the
   full viewport height *including* the browser's address bar and bottom nav
   bar. When those UI elements are visible the page overflows by that amount
   and — because the body has overflow:hidden — content is silently clipped.

   Fix: replace 100vh everywhere with 100dvh (dynamic viewport height), which
   always equals the *currently visible* area and shrinks when browser chrome
   is shown. dvh is supported in Safari 15.4+, Chrome 108+, Firefox 101+.
   A @supports guard means older browsers simply keep the 100vh fallback.
   ───────────────────────────────────────────────────────────────────────── */

@supports (height: 100dvh) {

  /* ── Shell body (h-screen / min-h-screen on every admin & app page) ───── */
  .h-screen     { height:     100dvh !important; }
  .min-h-screen { min-height: 100dvh !important; }

  /* ── Sidebar — fixed panel must span the full visible height ─────────── */
  .sidebar { height: 100dvh !important; }

  /* ── Main content area below the topbar (60px = 3.75rem) ─────────────── */
  main > div { min-height: calc(100dvh - 3.75rem) !important; }

  /* ── Auth / login page centering container ────────────────────────────── */
  body.flex.min-h-screen { min-height: 100dvh !important; }
}

/* ─────────────────────────────────────────────────────────────────────────
   AUTH PAGES
   ───────────────────────────────────────────────────────────────────────── */

@keyframes auth-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}

/* Form card in auth pages */
.bg-white.rounded-2xl.shadow-lg {
  border-radius: 20px !important;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05) !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   LOADING SHIMMER UTILITY
   ───────────────────────────────────────────────────────────────────────── */

@keyframes shimmer {
  from { background-position: -600px 0; }
  to   { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f1f4f9 25%, #e8ecf4 50%, #f1f4f9 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}

/* ─────────────────────────────────────────────────────────────────────────
   FOCUS VISIBLE (keyboard navigation)
   ───────────────────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid rgba(14,159,135,0.5);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* ─────────────────────────────────────────────────────────────────────────
   SETTINGS TAB BAR — always scrollable at every viewport width
   With 10 tabs the total item width (~1150 px) exceeds most viewports and
   even typical laptop content areas (~960 px). Apply scroll + fade at all
   sizes so the active tab is always reachable with a swipe/drag.
   ───────────────────────────────────────────────────────────────────────── */

/* Shell is the clipping + gradient host */
.seg-nav-shell {
  position: relative;
  width: 100%;
}

/* Nav scrolls horizontally, hides the scrollbar UI */
.seg-nav {
  overflow-x: scroll !important;
  scrollbar-width: none !important;          /* Firefox */
  -webkit-overflow-scrolling: touch;         /* iOS momentum */
}
.seg-nav::-webkit-scrollbar { display: none !important; }

/* Right-edge fade — tells the user there are more tabs */
.seg-nav-shell::after {
  content: '';
  position: absolute;
  /* Inset 5 px to sit inside the nav's 4 px padding + 1 px border */
  top: 5px;
  bottom: 5px;
  right: 5px;
  width: 3.25rem;
  /* Fade matches nav background (#F1F4F9) */
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(241, 244, 249, 0.82) 40%,
    #F1F4F9 100%
  );
  border-radius: 0 10px 10px 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.18s ease;
}

/* Fade disappears once the user has scrolled all the way to the end */
.seg-nav-shell.seg-nav-at-end::after {
  opacity: 0;
}

/* RTL: fade goes on the left side */
[dir="rtl"] .seg-nav-shell::after {
  right: auto;
  left: 5px;
  border-radius: 10px 0 0 10px;
  background: linear-gradient(
    to left,
    transparent 0%,
    rgba(241, 244, 249, 0.82) 40%,
    #F1F4F9 100%
  );
}

/* ─────────────────────────────────────────────────────────────────────────
   SCROLLBAR UTILITIES
   ───────────────────────────────────────────────────────────────────────── */

/* Hide scrollbar without disabling scroll (used in compose action bar, etc.) */
.scrollbar-none {
  scrollbar-width: none !important;          /* Firefox */
  -webkit-overflow-scrolling: touch;         /* iOS momentum */
}
.scrollbar-none::-webkit-scrollbar { display: none !important; }

/* ─────────────────────────────────────────────────────────────────────────
   RESPONSIVE — MOBILE IMPROVEMENTS
   ───────────────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .page-hero { padding: 1.25rem !important; margin-inline: -0.25rem; }
  .page-title { font-size: 1.125rem !important; }
  .kpi { padding: 1rem !important; }
  .kpi-value { font-size: 1.75rem !important; }
  .card { border-radius: 12px !important; }
  .topbar { padding-inline: 0.875rem !important; }
  .table-base thead { display: none; }
  .table-base tbody tr { display: block; border-bottom: 1px solid rgba(0,0,0,0.07) !important; padding: 0.75rem 0; }
  .table-base tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 1rem !important;
    font-size: 0.8125rem !important;
    white-space: normal !important;
    text-align: start !important;
  }
  .table-base tbody td::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-inline-end: 0.5rem;
    flex-shrink: 0;
    white-space: nowrap;
  }
  /* Action column — keep content right-aligned on mobile */
  .table-base tbody td.ch-action-cell {
    justify-content: space-between;
  }
  .table-base tbody td.ch-action-cell > *:last-child,
  .table-base tbody td.ch-action-cell > form:last-child {
    margin-inline-start: auto;
  }
}

@media (max-width: 639px) {
  .toolbar { flex-direction: column; gap: 0.75rem; }
  /* Full-width CTA buttons — but NOT the compose send button which lives
     inside a flex row and must stay compact to leave room for the textarea. */
  .btn-primary:not([type="submit"]),
  .btn-secondary:not([type="submit"]) { width: 100%; justify-content: center; }
  .stat-card { padding: 1rem !important; }
  .kpi { border-radius: 12px !important; }

  /* Smooth horizontal scroll on tables */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  /* Prevent header cells from wrapping (table is still visible on ≥768px) */
  .table-base th {
    white-space: nowrap;
  }

  /* Hero sections — tighten up on very small screens */
  .hero-platform,
  .rounded-2xl.border.shadow-card.p-6 {
    padding: 1rem !important;
  }

  /* Keep topbar compact */
  .topbar {
    padding-inline: 0.75rem !important;
  }

  /* ── Conversation thread — mobile ──────────────────────────────────────── */

  /* Cap message bubble width so they never overflow the phone screen.
     The base CSS sets max-width: 24rem (384 px) which exceeds most phones. */
  .msg-inbound,
  .msg-outbound {
    max-width: 82vw !important;
  }

  /* Thread area — keep readable 10 px gutter on both sides */
  #message-thread {
    padding-inline: 0.625rem !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   REDUCED MOTION
   ───────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   NOTIFICATION BELL BADGE
   Pill-shaped counter with subtle glow and pulse when unread.
   ───────────────────────────────────────────────────────────────────────── */

.sayl-bell-badge {
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
  letter-spacing: 0.02em;
  pointer-events: none;
}

.sayl-bell-active::after {
  content: "";
  position: absolute;
  top: -2px;
  inset-inline-end: -2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.45);
  animation: sayl-bell-pulse 1.6s ease-out infinite;
  pointer-events: none;
}

@keyframes sayl-bell-pulse {
  0%   { transform: scale(1);   opacity: 0.65; }
  80%  { transform: scale(2.2); opacity: 0;    }
  100% { transform: scale(2.2); opacity: 0;    }
}

/* ─────────────────────────────────────────────────────────────────────────
   TOAST NOTIFICATION (top-right, 3s auto-dismiss)
   ───────────────────────────────────────────────────────────────────────── */

.sayl-toast-stack {
  position: fixed;
  top: 76px;
  inset-inline-end: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
  width: calc(100vw - 40px);
}

.sayl-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-inline-start: 3px solid #0e9f87;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px -8px rgba(15, 23, 42, 0.22),
              0 4px 12px -4px rgba(15, 23, 42, 0.10);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.sayl-toast:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px -10px rgba(15, 23, 42, 0.28),
              0 6px 14px -4px rgba(15, 23, 42, 0.12);
}

.sayl-toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 159, 135, 0.12);
  color: #0e9f87;
}

.sayl-toast-body {
  flex: 1;
  min-width: 0;
}

.sayl-toast-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}

.sayl-toast-text {
  font-size: 12px;
  color: #64748b;
  margin: 2px 0 0;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sayl-toast-close {
  background: none;
  border: 0;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-inline-start: 4px;
  flex-shrink: 0;
}
.sayl-toast-close:hover { color: #475569; }

/* Alpine transition classes */
.sayl-toast-enter        { transition: transform 0.25s ease, opacity 0.25s ease; }
.sayl-toast-enter-start  { transform: translateX(120%); opacity: 0; }
.sayl-toast-enter-end    { transform: translateX(0);    opacity: 1; }
.sayl-toast-leave        { transition: transform 0.25s ease, opacity 0.25s ease; }
.sayl-toast-leave-start  { transform: translateX(0);    opacity: 1; }
.sayl-toast-leave-end    { transform: translateX(120%); opacity: 0; }

/* RTL: slide in from the left edge */
[dir="rtl"] .sayl-toast-enter-start,
[dir="rtl"] .sayl-toast-leave-end { transform: translateX(-120%); }

/* ─────────────────────────────────────────────────────────────────────────
   CONVERSATION ROW UNREAD COUNTER
   ───────────────────────────────────────────────────────────────────────── */

.sayl-unread-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
  flex-shrink: 0;
}
