/* ============================================================
   AI Automation Hub — Admin Dashboard
   Multi-tenant, Premium SaaS Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS VARIABLES --- */
:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --secondary:     #7c3aed;
  --success:       #059669;
  --warning:       #d97706;
  --danger:        #dc2626;
  --info:          #0284c7;

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --sidebar-bg:    #0f172a;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active:#2563eb;

  --text-primary:  #0f172a;
  --text-secondary:#475569;
  --text-muted:    #94a3b8;
  --border:        #e2e8f0;

  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);

  --sidebar-w:     260px;
  --topbar-h:      64px;
}

/* --- RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- SCROLL --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   LOGIN SCREEN
============================================================ */
#loginContainer {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #0f172a 100%);
  overflow: hidden;
}

.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .35;
  pointer-events: none;
}
.login-bg-orb.orb1 { width: 480px; height: 480px; background: #2563eb; top: -100px; left: -100px; animation: orbPulse 8s infinite alternate; }
.login-bg-orb.orb2 { width: 360px; height: 360px; background: #7c3aed; bottom: -80px; right: -80px; animation: orbPulse 6s infinite alternate-reverse; }
@keyframes orbPulse { from { transform: scale(1); } to { transform: scale(1.2); } }

.login-card {
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  z-index: 2;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  animation: cardEntrance .5s cubic-bezier(.22,1,.36,1);
}
@keyframes cardEntrance { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.login-logo .logo-text { color: #fff; }
.login-logo .logo-text strong { display: block; font-size: 17px; font-weight: 700; }
.login-logo .logo-text span { font-size: 12px; color: rgba(255,255,255,.5); }

.login-title { font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: rgba(255,255,255,.45); margin-bottom: 28px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.55); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.form-group input::placeholder { color: rgba(255,255,255,.25); }
.form-group input:focus { border-color: var(--primary); background: rgba(255,255,255,.09); }

.login-error { display: none; color: #fca5a5; font-size: 12.5px; margin-bottom: 12px; background: rgba(220,38,38,.15); padding: 8px 12px; border-radius: 6px; }

.btn-login {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 14.5px; font-weight: 700;
  cursor: pointer; transition: opacity .2s, transform .1s;
  box-shadow: 0 4px 16px rgba(37,99,235,.35);
}
.btn-login:hover { opacity: .92; transform: translateY(-1px); }
.btn-login:active { transform: none; }

.login-demo { margin-top: 18px; font-size: 11.5px; color: rgba(255,255,255,.35); text-align: center; }

/* ============================================================
   LAYOUT
============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column;
  z-index: 200;
  box-shadow: 2px 0 24px rgba(0,0,0,.15);
  transition: width .3s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 12px;
}
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.brand-label { flex: 1; overflow: hidden; }
.brand-name { color: #fff; font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-version { color: rgba(255,255,255,.35); font-size: 10.5px; }

.sidebar-menu {
  list-style: none;
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-item a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: all .18s;
  white-space: nowrap;
}
.sidebar-item a svg { width: 17px; height: 17px; flex-shrink: 0; transition: stroke .18s; }
.sidebar-item a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-item.active a { background: var(--sidebar-active); color: #fff; box-shadow: 0 2px 12px rgba(37,99,235,.35); }

.sidebar-footer {
  padding: 16px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.user-profile-mini {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  cursor: default;
}
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--secondary)); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.user-meta { flex: 1; overflow: hidden; }
.user-meta .name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-badge { font-size: 10px; background: rgba(255,255,255,.1); color: rgba(255,255,255,.6); padding: 1px 7px; border-radius: 4px; }
.btn-logout { background: transparent; border: none; color: rgba(255,255,255,.35); font-size: 18px; cursor: pointer; transition: color .2s; padding: 4px 8px; }
.btn-logout:hover { color: #f87171; }

/* --- MAIN AREA --- */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* --- TOPBAR --- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.04);
}
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.realtime-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; animation: blink 2s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.realtime-label { font-size: 11.5px; color: var(--text-muted); }

/* --- PAGE BODY --- */
.page-body { padding: 28px; flex: 1; }

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600;
  font-family: inherit;
  transition: all .18s;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.btn-secondary { background: #f8fafc; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 11.5px; border-radius: 6px; }

/* ============================================================
   CARDS
============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 14.5px; font-weight: 700; }
.card-body { padding: 20px; }

/* ============================================================
   STAT TILES
============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; gap: 18px;
  align-items: flex-start;
  transition: transform .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px;
}
.stat-card.blue::before { background: linear-gradient(to bottom, #2563eb, #7c3aed); }
.stat-card.green::before { background: linear-gradient(to bottom, #059669, #10b981); }
.stat-card.amber::before { background: linear-gradient(to bottom, #d97706, #f59e0b); }
.stat-card.indigo::before { background: linear-gradient(to bottom, #4f46e5, #7c3aed); }

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 50px; height: 50px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; }
.stat-icon.green { background: #f0fdf4; }
.stat-icon.amber { background: #fffbeb; }
.stat-icon.indigo { background: #eef2ff; }

.stat-body { flex: 1; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; margin-top: 4px; }
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* ============================================================
   TABS / SECTIONS
============================================================ */
.tab-content { display: none; animation: tabEnter .25s ease; }
.tab-content.active { display: block; }
@keyframes tabEnter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   TABLES
============================================================ */
.table-wrapper { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data-table thead th {
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
table.data-table tbody tr:hover { background: #fafbfc; }
table.data-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

/* ============================================================
   BADGES
============================================================ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef9c3; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }

/* ============================================================
   SEARCH/FILTER BAR
============================================================ */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.search-input, .filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit;
  outline: none; background: var(--surface);
  transition: border-color .2s;
}
.search-input { flex: 1; min-width: 200px; }
.search-input:focus, .filter-select:focus { border-color: var(--primary); }

/* ============================================================
   DOCTORS GRID
============================================================ */
.doctors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 4px;
}
.doctor-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow);
}
.doctor-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.doc-profile { display: flex; gap: 12px; align-items: center; }
.doc-avatar { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, #dbeafe, #eff6ff); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.doc-name { font-size: 14px; font-weight: 700; }
.doc-dept { font-size: 12px; color: var(--text-muted); }
.doc-stars { font-size: 11px; color: #f59e0b; margin-top: 2px; }
.doc-details { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.doc-row { display: flex; justify-content: space-between; color: var(--text-secondary); }
.doc-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--border); }

/* ============================================================
   GOOGLE SHEET GRID
============================================================ */
.sheet-wrapper { overflow: auto; max-height: 70vh; font-size: 12.5px; }
.sheet-table { border-collapse: collapse; width: 100%; }
.sheet-table th, .sheet-table td {
  border: 1px solid #d0d0d0; padding: 6px 10px; white-space: nowrap;
}
.sheet-table thead { position: sticky; top: 0; z-index: 5; }
.sheet-table thead:first-child th { background: #1d3461; color: #fff; font-size: 11px; }
.sheet-table thead:nth-child(2) th { background: #2d6a4f; color: #fff; font-weight: 600; }
.scol-letter { background: #1d3461; color: #aec6e8; font-size: 10px; font-weight: 700; text-align: center; }
.srow { background: #f1f3f4; color: #555; font-size: 10.5px; text-align: center; font-weight: 600; min-width: 32px; }

/* ============================================================
   BILLING LAYOUT
============================================================ */
.billing-layout { display: grid; grid-template-columns: 1fr 420px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .billing-layout { grid-template-columns: 1fr; } }

.invoice-card {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; background: var(--surface);
  font-family: 'Inter', sans-serif;
  box-shadow: var(--shadow);
  transition: background .3s;
}
.invoice-card.paid { background: linear-gradient(135deg, #f0fdf4, #ffffff); border-color: #bbf7d0; }

.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.inv-hname { font-size: 17px; font-weight: 800; color: var(--primary-dark); }

.inv-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: #f8fafc; padding: 14px; border-radius: 8px; margin-bottom: 20px; }
.inv-meta-grid > div { display: flex; flex-direction: column; gap: 2px; }
.inv-meta-grid span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: .4px; }
.inv-meta-grid strong { font-size: 13.5px; }

.inv-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 16px; }
.inv-table th { padding: 8px 10px; background: #f1f5f9; font-size: 11.5px; font-weight: 700; color: var(--text-secondary); text-align: left; }
.inv-table td { padding: 10px 10px; border-bottom: 1px solid #f1f5f9; }

.inv-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 17px; padding: 12px 10px; background: var(--primary); color: #fff; border-radius: 8px; margin-bottom: 20px; }

.pay-section { margin-top: 16px; }
.pay-title { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.pay-btn { border: 1.5px solid var(--border); border-radius: 8px; padding: 12px 8px; text-align: center; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s; }
.pay-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.pay-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }

/* ============================================================
   DRAWERS (SLIDE-IN PANELS)
============================================================ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 500; opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.drawer {
  position: fixed; right: -520px; top: 0; bottom: 0;
  width: 480px; max-width: 95vw;
  background: var(--surface);
  z-index: 501;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transition: right .3s cubic-bezier(.22,1,.36,1);
  overflow: hidden;
}
.drawer.open { right: 0; }
.drawer.open + .drawer-overlay { opacity: 1; pointer-events: all; }

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
}
.drawer-header h2 { font-size: 16px; font-weight: 700; color: #fff; }
.btn-close { background: rgba(255,255,255,.1); border: none; width: 32px; height: 32px; border-radius: 50%; color: #fff; font-size: 18px; cursor: pointer; transition: background .2s; display: flex; align-items: center; justify-content: center; }
.btn-close:hover { background: rgba(255,255,255,.2); }

.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  outline: none; transition: border-color .2s;
  background: var(--surface);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--primary); }

/* ============================================================
   WHATSAPP PHONE SIMULATOR
============================================================ */
.phone-trigger {
  position: fixed; bottom: 28px; right: 28px;
  z-index: 300;
}
.phone-fab {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #25d366, #128c7e);
  border: none; cursor: pointer;
  font-size: 28px;
  box-shadow: 0 4px 20px rgba(37,211,102,.45);
  transition: transform .2s, box-shadow .2s;
  display: flex; align-items: center; justify-content: center;
}
.phone-fab:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(37,211,102,.55); }

.phone-drawer {
  position: fixed; right: -400px; bottom: 0; top: 0;
  width: 390px; max-width: 100vw;
  background: #fff;
  z-index: 400;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transition: right .3s cubic-bezier(.22,1,.36,1);
  border-left: 1px solid var(--border);
}
.phone-drawer.open { right: 0; }

.phone-header {
  background: linear-gradient(135deg, #075e54, #128c7e);
  padding: 16px 18px;
  display: flex; align-items: center; gap: 12px;
  color: #fff;
}
.phone-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.phone-hname { font-size: 15px; font-weight: 700; }
.phone-brand-title { font-size: 11.5px; opacity: .75; }
.phone-header-actions { margin-left: auto; }
.btn-phone-close { background: rgba(255,255,255,.15); border: none; width: 30px; height: 30px; border-radius: 50%; color: #fff; font-size: 16px; cursor: pointer; }
.btn-phone-close:hover { background: rgba(255,255,255,.25); }

.phone-chat-body {
  flex: 1; padding: 14px; overflow-y: auto;
  background: #e5ddd5 url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100' height='100' fill='%23e5ddd5'/%3E%3C/svg%3E");
  display: flex; flex-direction: column;
}

.date-divider { text-align: center; margin: 10px 0; }
.date-divider span, .date-divider { background: #d4ecd0; padding: 3px 12px; border-radius: 12px; font-size: 11.5px; color: #555; }

.phone-msg {
  max-width: 82%; margin: 3px 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px; line-height: 1.5;
  word-wrap: break-word;
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s;
}
.phone-msg.visible { opacity: 1; transform: none; }
.phone-msg-in { background: #fff; align-self: flex-start; border-top-left-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.phone-msg-out { background: #d9fdd3; align-self: flex-end; border-top-right-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.msg-time { font-size: 10px; color: #999; text-align: right; margin-top: 3px; }

.typing-dots { display: flex; gap: 4px; align-items: center; background: #fff; border-radius: 10px; padding: 10px 14px; align-self: flex-start; box-shadow: 0 1px 2px rgba(0,0,0,.08); opacity: 0; transition: opacity .2s; margin: 4px 0; }
.typing-dots span { width: 7px; height: 7px; background: #bbb; border-radius: 50%; animation: dot-bounce 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot-bounce { 0%,80%,100% { transform: scale(.8); opacity:.5; } 40% { transform: scale(1); opacity:1; } }

.phone-chat-input {
  padding: 10px 12px;
  background: #f0f0f0;
  border-top: 1px solid #ddd;
  display: flex; gap: 8px; align-items: center;
}
#phoneUserInput {
  flex: 1; padding: 10px 14px;
  border-radius: 24px; border: none;
  background: #fff; font-size: 13.5px;
  outline: none; font-family: inherit;
}
.phone-send-btn { width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(135deg, #25d366, #128c7e); border: none; font-size: 18px; cursor: pointer; transition: transform .15s; display: flex; align-items: center; justify-content: center; }
.phone-send-btn:hover { transform: scale(1.1); }

/* ============================================================
   PRINT RECEIPT MODAL
============================================================ */
.print-modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
}
.print-modal.open { display: flex; }
.print-modal-inner { background: #fff; border-radius: 14px; padding: 32px; max-width: 380px; width: 90%; box-shadow: var(--shadow-lg); font-size: 13px; }
.prt-header { text-align: center; margin-bottom: 20px; border-bottom: 2px dashed #ddd; padding-bottom: 16px; }
.prt-logo { font-size: 22px; font-weight: 800; color: var(--primary-dark); }
.prt-subtitle { font-size: 11px; color: #888; }
.prt-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f5f5f5; }
.prt-row strong { color: var(--primary-dark); font-weight: 700; font-size: 15px; }
.prt-footer { text-align: center; margin-top: 16px; font-size: 12px; color: #888; }
.prt-footer strong { display: block; margin-top: 6px; color: var(--primary); font-size: 14px; }

/* ============================================================
   REVENUE LOCK (for non-admins)
============================================================ */
#revenueLock {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; z-index: 2;
}
#revenueLock span { font-size: 28px; }
#revenueLock p { color: rgba(255,255,255,.6); font-size: 12px; text-align: center; }

/* ============================================================
   MISC UTILITIES
============================================================ */
.hidden { display: none !important; }
.section-title { font-size: 14px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 14px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--text-muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }

/* Revenue date control */
.rev-date-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.rev-date-row input[type=date] { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; font-family: inherit; outline: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   DATE-TIME PICKER — compact calendar + slot grid
============================================================ */
.dt-picker {
  max-width: 320px;
  margin: 0 auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

/* Compact calendar header */
.dt-cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  color: #fff;
}
.dt-cal-title { font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.dt-cal-nav {
  background: rgba(255,255,255,.12); border: none;
  color: #fff; width: 22px; height: 22px; border-radius: 5px;
  cursor: pointer; font-size: 14px;
  transition: background .15s; display: flex; align-items: center; justify-content: center;
}
.dt-cal-nav:hover { background: rgba(255,255,255,.25); }

/* 7-col date grid */
.dt-cal-grid { padding: 4px 6px 6px; }
.dt-cal-days-header {
  display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px;
}
.dt-cal-days-header span {
  text-align: center; font-size: 9px; font-weight: 700;
  color: var(--text-muted); padding: 2px 0; text-transform: uppercase;
}
.dt-cal-dates { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.dt-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; font-size: 11px; cursor: pointer;
  border: none; background: transparent; font-family: inherit; font-weight: 500;
  transition: all .12s; color: var(--text-primary);
}
.dt-day:hover:not(.dt-day-disabled):not(.dt-day-selected) {
  background: var(--primary-light); color: var(--primary);
}
.dt-day-disabled { color: var(--text-muted); opacity: .3; cursor: not-allowed; text-decoration: line-through; }
.dt-day-today { border: 1.5px solid var(--primary); color: var(--primary); font-weight: 700; }
.dt-day-selected { background: var(--primary) !important; color: #fff !important; font-weight: 700; box-shadow: 0 2px 6px rgba(37,99,235,.3); }
.dt-day-empty { pointer-events: none; }

/* Time slot buttons — 3 col, compact */
.dt-slots-wrap {
  border-top: 1.5px solid var(--border);
  padding: 7px 7px 7px; animation: fadeIn .15s ease;
  max-height: 140px; overflow-y: auto;
}
.dt-slots-label {
  font-size: 9.5px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px;
}
.dt-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.dt-slot {
  padding: 6px 2px; border-radius: 6px; text-align: center;
  font-size: 11px; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface);
  font-family: inherit; transition: all .12s; color: var(--text-primary);
}
.dt-slot:hover:not(.dt-slot-disabled):not(.dt-slot-selected) {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}
.dt-slot-disabled { color: var(--text-muted); opacity: .35; cursor: not-allowed; text-decoration: line-through; border-style: dashed; }
.dt-slot-selected { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 5px rgba(37,99,235,.22); }

/* Summary pill below picker */
.dt-selected-summary { margin-top: 6px; font-size: 11.5px; font-weight: 600; color: var(--primary); min-height: 16px; }

/* -----------------------------------------------------------------------
   DRAWER overrides — compact body + equal footer buttons
----------------------------------------------------------------------- */
.drawer-body { padding: 14px 18px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.drawer-footer .btn { justify-content: center; padding: 10px 24px; }
.form-row { margin-bottom: 10px; }
.form-row label { font-size: 11px; }
.form-row input, .form-row select, .form-row textarea { padding: 7px 10px; font-size: 13px; }

/* Revenue card — lock overlay handles hiding */
#revenueCardBody { visibility: visible; }

/* ============================================================
   WHATSAPP INTERACTIVE DATE+TIME SLOT BUTTONS
============================================================ */
.wa-picker-wrap { margin-top: 4px; }
.wa-picker-label {
  font-size: 10px; font-weight: 700; color: #777;
  text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px;
}
.wa-date-btns, .wa-slot-btns { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.wa-btn {
  padding: 5px 10px; border-radius: 16px;
  border: 1.5px solid #25d366; background: #fff;
  color: #128c7e; font-size: 11.5px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all .13s;
  white-space: nowrap;
}
.wa-btn:hover:not(.wa-btn-disabled) { background: #25d366; color: #fff; }
.wa-btn-selected { background: #25d366 !important; color: #fff !important; border-color: #1da851 !important; }
.wa-btn-disabled { border-color: #ddd; color: #bbb; cursor: not-allowed; text-decoration: line-through; }
.wa-confirm-btn {
  margin-top: 8px; padding: 8px 14px; border-radius: 16px; border: none;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: opacity .13s;
  display: block; width: 100%; text-align: center;
}
.wa-confirm-btn:hover { opacity: .88; }

/* ============================================================
   WHATSAPP CALENDAR DATE PICKER
============================================================ */

.wa-calendar {
  background: #f8faf8;
  border: 1px solid #d9e8df;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 6px;
}

.wa-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #075e54;
  font-size: 12px;
}

.wa-cal-nav {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: #e8f5e9;
  color: #075e54;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-cal-nav:hover {
  background: #25d366;
  color: #fff;
}

.wa-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 3px;
}

.wa-cal-weekdays span {
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: #888;
}

.wa-cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.wa-cal-day {
  width: 100%;
  aspect-ratio: 1;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fff;
  color: #333;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.wa-cal-day:hover:not(:disabled) {
  background: #e8f5e9;
  border-color: #25d366;
}

.wa-cal-today {
  border-color: #25d366;
  color: #128c7e;
}

.wa-cal-selected {
  background: #25d366 !important;
  color: #fff !important;
  border-color: #1da851 !important;
}

.wa-cal-disabled {
  color: #ccc;
  background: #f5f5f5;
  cursor: not-allowed;
}

.wa-cal-empty {
  background: transparent;
  cursor: default;
  border: none;
}

.wa-selected-summary {
  margin-top: 10px;
  padding: 9px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
}
