/* ============================================================
   Q&S Talk — Purple Hospital Theme
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
  --p50:  #faf5ff;
  --p100: #f3e8ff;
  --p200: #e9d5ff;
  --p300: #d8b4fe;
  --p400: #c084fc;
  --p500: #a855f7;
  --p600: #9333ea;
  --p700: #7e22ce;
  --p800: #6b21a8;
  --p900: #581c87;

  --primary:       #7e22ce;
  --primary-light: #a855f7;
  --primary-dark:  #581c87;
  --primary-grad:  linear-gradient(135deg, #581c87 0%, #7e22ce 60%, #9333ea 100%);
  --accent-grad:   linear-gradient(135deg, #a855f7, #ec4899);

  --bg:      #faf5ff;
  --card-bg: #ffffff;
  --border:  #e9d5ff;

  --text-primary:   #1e1b2e;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;

  --shadow-sm:  0 1px 4px rgba(126,34,206,.08);
  --shadow-md:  0 4px 16px rgba(126,34,206,.12);
  --shadow-lg:  0 8px 32px rgba(126,34,206,.16);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --navbar-h: 64px;
  --bottomnav-h: 66px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--p50); }
::-webkit-scrollbar-thumb { background: var(--p300); border-radius: 3px; }

/* ─────────────────────────────────────────
   TOP NAVBAR
───────────────────────────────────────── */
.app-navbar {
  background: var(--primary-grad);
  height: var(--navbar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(88,28,135,.3);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}

.nav-brand .brand-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.18);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.nav-brand .brand-name {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.1;
}

.nav-brand .brand-sub {
  font-size: 11px;
  opacity: .75;
  line-height: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link-item {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.nav-link-item:hover,
.nav-link-item.active {
  background: rgba(255,255,255,.2);
  color: #fff;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  background: rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.lang-toggle .lang-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,.75);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 18px;
  cursor: pointer;
  transition: .15s;
  font-family: 'Sarabun', sans-serif;
}

.lang-toggle .lang-btn.active {
  background: rgba(255,255,255,.3);
  color: #fff;
}

.user-chip {
  background: rgba(255,255,255,.18);
  color: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  transition: background .15s;
}

.btn-logout:hover { background: rgba(255,255,255,.25); }

/* ─────────────────────────────────────────
   BOTTOM NAV (mobile only)
───────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(126,34,206,.1);
}

.bottom-nav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 8px 4px;
  transition: color .15s;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
}

.bottom-nav .bn-item .bn-icon { font-size: 20px; line-height: 1; }

.bottom-nav .bn-item.active,
.bottom-nav .bn-item:hover { color: var(--primary); }

.bottom-nav .bn-add {
  background: var(--primary-grad);
  border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  color: #fff !important;
  font-size: 22px;
  margin-top: -14px;
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
  border: 3px solid var(--bg);
}

@media (max-width: 767px) {
  .bottom-nav { display: flex; }
  .page-content { padding-bottom: calc(var(--bottomnav-h) + 16px); }
  .nav-links { display: none; }
  .user-chip { display: none; }
  .btn-logout { display: none; }
}

/* ─────────────────────────────────────────
   PAGE LAYOUT
───────────────────────────────────────── */
.page-content {
  padding: 24px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 767px) {
  .page-content { padding: 16px 12px; }
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ─────────────────────────────────────────
   AUTH PAGES
───────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-grad);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
  top: -200px; right: -150px;
}

.auth-wrapper::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
  bottom: -100px; left: -80px;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo .logo-circle {
  width: 72px; height: 72px;
  background: var(--primary-grad);
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(126,34,206,.35);
}

.auth-logo h4 {
  font-weight: 800;
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-logo p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

.form-label {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14.5px;
  font-family: 'Sarabun', sans-serif;
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(168,85,247,.15);
  outline: none;
}

/* ─────────────────────────────────────────
   BUTTONS
───────────────────────────────────────── */
.btn-primary-purple {
  background: var(--primary-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: opacity .15s, transform .1s, box-shadow .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  box-shadow: 0 4px 12px rgba(126,34,206,.3);
}

.btn-primary-purple:hover {
  opacity: .9;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(126,34,206,.4);
}

.btn-primary-purple:disabled {
  opacity: .6;
  transform: none;
  cursor: not-allowed;
}

.btn-outline-purple {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--p300);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: .15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-outline-purple:hover {
  background: var(--p50);
  border-color: var(--primary);
}

/* ─────────────────────────────────────────
   CARDS
───────────────────────────────────────── */
.card-base {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* KPI Cards */
.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--p100);
  right: -30px; top: -30px;
  z-index: 0;
}

.kpi-card .kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
  position: relative; z-index: 1;
}

.kpi-card .kpi-value {
  font-size: 38px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  position: relative; z-index: 1;
}

.kpi-card .kpi-icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 28px;
  opacity: .2;
  z-index: 0;
}

.kpi-card.kpi-v2 .kpi-value { color: #0d9488; }
.kpi-card.kpi-v2::after { background: #ccfbf1; }
.kpi-card.kpi-v3 .kpi-value { color: #16a34a; }
.kpi-card.kpi-v3::after { background: #dcfce7; }
.kpi-card.kpi-v4 .kpi-value { color: #d97706; }
.kpi-card.kpi-v4::after { background: #fef3c7; }

/* ─────────────────────────────────────────
   REPORT CARDS
───────────────────────────────────────── */
.report-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 5px solid var(--p300);
  margin-bottom: 12px;
  transition: box-shadow .2s, transform .15s;
}

.report-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.report-card.unread {
  border-left-color: #ef4444;
  background: #fffbfb;
}

.report-card.acked {
  border-left-color: #16a34a;
  background: #f9fffc;
  opacity: .88;
}

.rc-body { padding: 16px 18px 12px; }
.rc-footer { padding: 8px 18px 12px; border-top: 1px solid var(--p100); }

/* ─────────────────────────────────────────
   BADGES & PILLS
───────────────────────────────────────── */
.urgency-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}

.urg-ปกติ,   .urg-Normal   { background: var(--p100); color: var(--p800); }
.urg-ด่วน,   .urg-Urgent   { background: #fef3c7; color: #92400e; }
.urg-ด่วนมาก, .urg-VeryUrgent { background: #fee2e2; color: #991b1b; }

.topic-pill {
  background: var(--p100);
  color: var(--p800);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}

.status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
}

.stat-เสร็จสิ้น,          .stat-Completed  { background: #dcfce7; color: #166534; }
.stat-กำลังดำเนินการ,    .stat-InProgress { background: #fef9c3; color: #854d0e; }
.stat-ยังไม่เริ่ม,        .stat-NotStarted { background: #fee2e2; color: #991b1b; }

.role-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.role-head  { background: var(--p200); color: var(--p800); }
.role-nurse { background: #e0f2fe; color: #0369a1; }

/* ─────────────────────────────────────────
   ACKNOWLEDGE BUTTON
───────────────────────────────────────── */
.btn-ack {
  background: var(--primary-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Sarabun', sans-serif;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(126,34,206,.25);
}

.btn-ack:hover { opacity: .88; transform: translateY(-1px); }
.btn-ack:disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* ─────────────────────────────────────────
   FILTER TABS
───────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 6px;
  background: var(--p100);
  padding: 4px;
  border-radius: 12px;
  width: fit-content;
  flex-wrap: wrap;
}

.filter-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-family: 'Sarabun', sans-serif;
  transition: .15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 6px rgba(126,34,206,.12);
}

/* ─────────────────────────────────────────
   SEARCH BAR
───────────────────────────────────────── */
.search-wrap {
  position: relative;
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

.search-wrap input {
  padding-left: 38px !important;
}

/* ─────────────────────────────────────────
   CHARTS
───────────────────────────────────────── */
.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 20px;
}

.chart-card .chart-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* ─────────────────────────────────────────
   TRACKING TABLE
───────────────────────────────────────── */
.track-done  { background: #f0fdf4; }
.track-pend  { background: #fff7ed; }

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.person-row .person-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.person-row.done .person-avatar { background: #dcfce7; }
.person-row.pend .person-avatar { background: #fef9c3; }

/* ─────────────────────────────────────────
   MODAL OVERRIDES
───────────────────────────────────────── */
.modal-header {
  background: var(--p100);
  border-bottom: 1px solid var(--border);
}

.modal-title { color: var(--primary); font-weight: 700; }

/* ─────────────────────────────────────────
   LOADING OVERLAY
───────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(250,245,255,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--p200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 60px;
  margin-bottom: 16px;
  filter: grayscale(.3);
}

.empty-state h5 { color: var(--text-secondary); font-weight: 700; }

/* ─────────────────────────────────────────
   PROGRESS BAR
───────────────────────────────────────── */
.progress { background: var(--p100); border-radius: 4px; overflow: hidden; }
.progress-bar-purple { background: var(--primary-grad); }

/* ─────────────────────────────────────────
   UTILITIES
───────────────────────────────────────── */
.text-purple { color: var(--primary); }
.bg-purple-light { background: var(--p100); }
.border-purple { border-color: var(--p300) !important; }
.rounded-xl { border-radius: var(--radius-lg) !important; }

/* ─────────────────────────────────────────
   RESPONSIVE HELPERS
───────────────────────────────────────── */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .page-title { font-size: 18px; }
  .kpi-card .kpi-value { font-size: 28px; }
  .auth-card { max-width: 100%; }
  .filter-tabs { width: 100%; }
  .filter-tab { flex: 1; justify-content: center; font-size: 12px; padding: 6px 8px; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
  .show-mobile  { display: none !important; }
}
