/* ========================================
   COMPONENTS.CSS — Custom Components
   ระบบ "มือทำเงินพันล้าน"
   ======================================== */

/* ── Stat Card ── */
.stat-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  padding: 16px;
  border: 1px solid var(--color-card-border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
  margin-top: 8px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Stat card icon variants */
.stat-icon-primary { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon-blue    { background: #EFF6FF; color: #3B82F6; }
.stat-icon-violet  { background: #F5F3FF; color: #7C3AED; }
.stat-icon-amber   { background: #FFFBEB; color: #D97706; }
.stat-icon-rose    { background: #FFF1F2; color: #E11D48; }
.stat-icon-emerald { background: #ECFDF5; color: #10B981; }

/* ── Search Bar ── */
.search-bar {
  position: relative;
  margin-bottom: 16px;
}
.search-bar input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--bs-border-radius);
  font-size: 14px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-bar input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 158, 122, 0.15);
  outline: none;
}
.search-bar input::placeholder {
  color: var(--color-text-muted);
}
.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: 18px;
  pointer-events: none;
}

/* ── Filter Tabs ── */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: #fff;
  border: 1px solid var(--color-card-border);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.filter-tab:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.filter-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.filter-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 6px;
  background: rgba(0,0,0,0.08);
}
.filter-tab.active .tab-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

/* ── Booking Card ── */
.booking-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--color-card-border);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s ease;
  cursor: pointer;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.booking-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.booking-card .booking-info {
  flex: 1;
  min-width: 0;
}
.booking-card .booking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.booking-card .booking-customer {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.booking-card .booking-detail {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}
.booking-card .booking-detail i {
  font-size: 15px;
  color: var(--color-text-muted);
}
.booking-card .booking-promo {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-card-border);
  font-size: 13px;
  color: var(--color-text-secondary);
}
.booking-card .booking-promo .promo-price {
  font-weight: 600;
  color: var(--color-primary);
  margin-left: auto;
}

/* ── Customer Card ── */
.customer-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--color-card-border);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.2s ease;
}
.customer-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.customer-card .customer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}
.customer-card .customer-info {
  flex: 1;
  min-width: 0;
}
.customer-card .customer-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.customer-card .customer-phone {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.customer-card .customer-action {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}
.customer-card .customer-action:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ── Promotion Card ── */
.promo-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--color-card-border);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s ease;
}
.promo-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.promo-card .promo-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.promo-card .promo-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}
.promo-card .promo-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-card-border);
}
.promo-card .promo-price-tag {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}
.promo-card .promo-price-tag small {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

/* ── FAB (Floating Action Button) ── */
.fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(13, 158, 122, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 90;
}
.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(13, 158, 122, 0.45);
}
.fab:active {
  transform: scale(0.95);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
}
.empty-state .empty-icon {
  font-size: 48px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}
.empty-state .empty-desc {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── Section Header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header .section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.section-header .section-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
}
.section-header .section-link:hover {
  text-decoration: underline;
}

/* ── Avatar Colors (for initials) ── */
.avatar-primary { background: var(--color-primary-light); color: var(--color-primary); }
.avatar-blue    { background: #EFF6FF; color: #3B82F6; }
.avatar-violet  { background: #F5F3FF; color: #7C3AED; }
.avatar-amber   { background: #FFFBEB; color: #D97706; }
.avatar-rose    { background: #FFF1F2; color: #E11D48; }
.avatar-emerald { background: #ECFDF5; color: #10B981; }

/* ── Admin Table Card ── */
.admin-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--color-card-border);
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s ease;
}
.admin-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.admin-card .admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.admin-card .admin-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}
.admin-card .admin-card-meta {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.admin-card .admin-card-meta i {
  font-size: 14px;
}
.admin-card .admin-card-actions,
.promo-card .admin-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-card-border);
}
.admin-card .btn-action,
.promo-card .btn-action {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--color-card-border);
  background: #fff;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}
.admin-card .btn-action:hover,
.promo-card .btn-action:hover {
  background: var(--color-page-bg);
  border-color: var(--color-text-muted);
}
.admin-card .btn-action-danger,
.promo-card .btn-action-danger {
  color: #991B1B;
}
.admin-card .btn-action-danger:hover,
.promo-card .btn-action-danger:hover {
  background: #FEE2E2;
  border-color: #991B1B;
}

/* ── Verify Card (Clinic) ── */
.verify-card {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 2px solid var(--color-card-border);
  padding: 20px;
  text-align: center;
}
.verify-card.verify-success {
  border-color: var(--status-confirmed-text);
  background: var(--status-confirmed-bg);
}
.verify-card .verify-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 12px;
}

/* ── Dashboard Chart Placeholder ── */
.chart-placeholder {
  background: #fff;
  border-radius: var(--bs-border-radius-lg);
  border: 1px solid var(--color-card-border);
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.chart-placeholder .chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex: 1;
  padding-top: 16px;
}
.chart-placeholder .chart-bar {
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 8px;
}

/* ── Toggle Switch ── */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #D1D5DB;
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .slider {
  background: var(--color-primary);
}
.toggle-switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ── Login Page ── */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #082C52 0%, #185FA5 50%, #3B82F6 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 12px;
}
.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}
.login-logo p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin: 0;
}

/* ── Modal ── */
.modal-content {
  border-radius: var(--bs-border-radius-lg);
  border: none;
}
.modal-header {
  border-bottom: 1px solid var(--color-card-border);
  padding: 16px 20px;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  border-top: 1px solid var(--color-card-border);
  padding: 12px 20px;
}

/* ── Capacity Indicator ── */
.capacity-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--color-card-border);
  overflow: hidden;
}
.capacity-bar .capacity-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.capacity-fill-ok      { background: var(--color-primary); }
.capacity-fill-warning  { background: #D97706; }
.capacity-fill-full     { background: #E11D48; }

/* ── Responsive Grid for Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}

@media (min-width: 992px) {
  .stat-grid {
    gap: 16px;
  }
  .fab {
    right: 32px;
    bottom: 32px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 26px;
  }
  /* Booking/customer cards in 2 columns on desktop */
  .cards-grid-desktop {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .cards-grid-desktop > * {
    margin-bottom: 0;
  }
  /* Login stays centered */
  .login-container {
    justify-content: center;
  }
  .login-card {
    max-width: 420px;
    padding: 40px 32px;
  }
  /* Chart placeholder wider */
  .chart-placeholder {
    min-height: 240px;
  }
}

/* ── Progress Bar & Track Colors by Clinic ── */
.progress-track-primary { background-color: var(--color-primary-light) !important; }
.progress-bar-primary   { background-color: var(--color-primary) !important; }

.progress-track-blue   { background-color: #EFF6FF !important; }
.progress-bar-blue     { background-color: #3B82F6 !important; }

.progress-track-violet { background-color: #F5F3FF !important; }
.progress-bar-violet   { background-color: #7C3AED !important; }

.progress-track-amber  { background-color: #FFFBEB !important; }
.progress-bar-amber    { background-color: #D97706 !important; }

.progress-track-rose   { background-color: #FFF1F2 !important; }
.progress-bar-rose     { background-color: #E11D48 !important; }

.progress-track-emerald{ background-color: #ECFDF5 !important; }
.progress-bar-emerald  { background-color: #10B981 !important; }


/* ── Tag Input Container ── */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--color-card-border);
  border-radius: var(--bs-border-radius);
  background: #fff;
  min-height: 42px;
  cursor: text;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.tag-input-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 158, 122, 0.15);
}
.tag-input-container input {
  flex: 1;
  min-width: 100px;
  border: none;
  outline: none;
  padding: 4px 0;
  font-size: 13px;
  color: var(--color-text-primary);
  background: transparent;
}
.tag-input-container input::placeholder {
  color: var(--color-text-muted);
}
.tag-input-container .tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  border: 1px solid rgba(13, 158, 122, 0.15);
}
.tag-input-container .tag-badge .tag-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  color: var(--color-text-secondary);
  font-size: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tag-input-container .tag-badge .tag-close:hover {
  background: #E11D48;
  color: #fff;
}

/* ── Package Lock (ฟีเจอร์ล็อกตาม Package — ชวนอัปเกรด) ── */
/* เมนูที่ถูกล็อก: จางลงเล็กน้อย + ไอคอนกุญแจสีทองท้ายรายการ (ยังคลิกเข้าได้ → เจอ upgrade wall) */
.sidebar-nav-item.menu-locked,
.sidebar-sub-item.menu-locked { opacity: 0.72; }
.menu-lock-icon {
  margin-left: auto;
  font-size: 14px;
  color: #D97706;
  flex-shrink: 0;
}
.bottom-nav-item.menu-locked { opacity: 0.7; }
.bottom-nav-item.menu-locked i { color: #D97706; }

/* การ์ด dashboard ที่ถูกล็อก: overlay เบลอ + กล่องกุญแจตรงกลาง (ตัวเรียกครอบด้วย position:relative) */
.pkg-lock-wrap { position: relative; }
.pkg-lock-wrap > .pkg-lock-content {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}
.pkg-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(1px);
  border-radius: inherit;
  z-index: 3;
}
.pkg-lock-inner { text-align: center; padding: 1rem; }
.pkg-lock-badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F59E0B, #D97706);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.5rem;
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.35);
}
.pkg-lock-badge i { font-size: 1.35rem; color: #fff; }
.pkg-lock-title { font-size: 13px; font-weight: 700; color: var(--color-text-primary); }
.pkg-lock-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
