/* ============================================================
   North Bangkok Care — Main Stylesheet
   Font: Prompt (Thai-friendly)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:     #1a3c6e;
  --primary-mid: #2563eb;
  --primary-lt:  #dbeafe;
  --accent:      #f5a623;
  --accent-dark: #d97706;
  --success:     #16a34a;
  --success-lt:  #dcfce7;
  --danger:      #dc2626;
  --danger-lt:   #fee2e2;
  --purple:      #7c3aed;
  --purple-lt:   #ede9fe;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-400:    #94a3b8;
  --gray-600:    #475569;
  --gray-800:    #1e293b;
  --white:       #ffffff;
  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 4px 20px rgba(0,0,0,0.08);
  --shadow-md:   0 8px 32px rgba(0,0,0,0.12);
}

html, body { font-family: 'Prompt', sans-serif; font-size: 15px; color: var(--gray-800); }

/* ============================================================
   LIFF LAYOUT
   ============================================================ */
.liff-body {
  min-height: 100vh;
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
}

.liff-header {
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  color: var(--white);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(26,60,110,0.4);
}

.logo-circle {
  width: 48px; height: 48px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.header-title { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.header-sub   { font-size: 0.75rem; opacity: 0.75; font-weight: 300; }

.back-btn {
  background: rgba(255,255,255,0.15);
  border: none; color: white; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.back-btn:hover { background: rgba(255,255,255,0.25); }

.liff-main {
  flex: 1;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.liff-footer {
  text-align: center;
  padding: 16px;
  color: var(--gray-400);
  font-size: 0.72rem;
}

/* ── Card ── */
.liff-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
}

.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.card-desc  { font-size: 0.83rem; color: var(--gray-600); margin-bottom: 20px; }

/* ── Loading ── */
.loading-spinner {
  width: 40px; height: 40px; margin: 0 auto 12px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { text-align: center; color: var(--gray-400); font-size: 0.85rem; }

/* ── Profile ── */
.profile-section {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.profile-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--gray-200);
}
.profile-name { font-weight: 600; font-size: 0.95rem; }
.profile-uuid { font-size: 0.7rem; color: var(--gray-400); font-family: monospace; }

/* ── User Type Buttons ── */
.section-title { font-size: 1.05rem; font-weight: 600; text-align: center; margin-bottom: 4px; }
.section-desc  { font-size: 0.8rem; color: var(--gray-600); text-align: center; margin-bottom: 18px; }

.type-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.type-btn {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 10px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.type-btn:hover, .type-btn:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.type-student:hover { border-color: var(--primary-mid); background: var(--primary-lt); }
.type-general:hover { border-color: var(--purple);      background: var(--purple-lt); }

.type-icon  { font-size: 2rem; margin-bottom: 6px; }
.type-label { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.type-desc  { font-size: 0.72rem; color: var(--gray-600); }

/* ── Status Card ── */
.status-card { text-align: center; padding: 32px 20px; }
.status-icon { font-size: 3rem; margin-bottom: 12px; }
.status-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.status-desc  { color: var(--gray-600); font-size: 0.85rem; line-height: 1.6; margin-bottom: 4px; }

/* ── Steps Indicator ── */
.steps {
  display: flex; align-items: center;
  justify-content: center;
  gap: 4px; padding: 4px 0;
}
.step { display: flex; align-items: center; gap: 4px; flex-direction: column; }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-400);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 600;
  transition: all .3s;
}
.step.active .step-dot { background: var(--primary-mid); color: white; }
.step.done  .step-dot  { background: var(--success);     color: white; }
.step span { font-size: 0.65rem; color: var(--gray-400); }
.step.active span { color: var(--primary-mid); }
.step-line {
  flex: 1; height: 2px; background: var(--gray-200); min-width: 24px; max-width: 40px; margin-bottom: 12px;
}
.step-line.active { background: var(--primary-mid); }

/* ── Form ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-weight: 500; font-size: 0.85rem; margin-bottom: 6px; color: var(--gray-800); }
.form-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 0.9rem;
  transition: border .2s, box-shadow .2s;
  outline: none;
}
.form-input:focus { border-color: var(--primary-mid); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-hint { font-size: 0.72rem; color: var(--gray-400); margin-top: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: var(--radius-sm); border: none;
  font-family: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer;
  transition: all .2s; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--primary-mid); color: white; }
.btn-primary:hover:not(:disabled)  { background: var(--primary); }
.btn-success  { background: var(--success); color: white; }
.btn-success:hover:not(:disabled)  { background: #15803d; }
.btn-danger   { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }
.btn-warning  { background: var(--accent); color: white; }
.btn-warning:hover:not(:disabled)  { background: var(--accent-dark); }
.btn-outline  { background: transparent; color: var(--primary-mid); border: 1.5px solid var(--primary-mid); }
.btn-outline:hover:not(:disabled)  { background: var(--primary-lt); }
.btn-block    { width: 100%; }
.btn-sm  { padding: 6px 12px; font-size: 0.78rem; }
.btn-xs  { padding: 3px 8px;  font-size: 0.72rem; border-radius: 4px; }

/* Spinner inside button */
.btn-spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Error Card ── */
.error-card { text-align: center; }
.error-icon-big { font-size: 2.5rem; margin-bottom: 12px; }
.error-title { font-size: 1.1rem; font-weight: 600; color: var(--danger); margin-bottom: 8px; }
.error-msg   { color: var(--gray-600); font-size: 0.85rem; margin-bottom: 20px; line-height: 1.6; }

/* ── Student Select ── */
.student-list { display: flex; flex-direction: column; gap: 12px; }
.student-card {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: border .2s;
}
.student-card:hover { border-color: var(--primary-mid); }
.student-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.student-badge {
  background: var(--primary-lt); color: var(--primary);
  border-radius: 4px; padding: 2px 8px; font-size: 0.72rem; font-weight: 600;
}
.student-code    { font-size: 1rem; font-weight: 700; }
.student-faculty { font-size: 0.82rem; font-weight: 500; color: var(--gray-800); margin-bottom: 2px; }
.student-dept    { font-size: 0.75rem; color: var(--gray-600); margin-bottom: 6px; }
.student-status-row { margin-bottom: 2px; }
.status-badge {
  border-radius: 999px; padding: 2px 10px; font-size: 0.72rem; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600);
}
.status-badge.status-40, .status-badge.status-41 { background: var(--purple-lt); color: var(--purple); }
.status-badge.status-10, .status-badge.status-00 { background: var(--success-lt); color: var(--success); }

/* ── Success Page ── */
.success-card { text-align: center; padding: 28px 20px; }
.success-animation { margin-bottom: 20px; }
.success-circle {
  width: 80px; height: 80px; margin: 0 auto;
  animation: scaleIn .4s ease;
}
@keyframes scaleIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.checkmark { width: 80px; height: 80px; }
.checkmark-circle {
  stroke: var(--success); stroke-width: 2;
  stroke-dasharray: 166; stroke-dashoffset: 166;
  animation: stroke .5s ease forwards;
}
.checkmark-check {
  stroke: var(--success); stroke-width: 3;
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: stroke .4s ease .4s forwards;
}
@keyframes stroke { to { stroke-dashoffset: 0; } }

.success-title { font-size: 1.4rem; font-weight: 700; color: var(--success); margin-bottom: 6px; }
.success-sub   { color: var(--gray-600); font-size: 0.85rem; margin-bottom: 20px; }

.info-box, .verified-info {
  background: var(--gray-50); border-radius: var(--radius-sm);
  padding: 14px 16px; text-align: left; margin-bottom: 18px;
}
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: 0.82rem;
}
.info-row:last-child { border-bottom: none; }
.info-row span { color: var(--gray-600); }
.info-row strong { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }

.success-note {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 0.78rem; color: #92400e; margin-bottom: 18px;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--gray-800); color: white;
  padding: 10px 20px; border-radius: 999px; font-size: 0.82rem;
  opacity: 0; transition: all .3s; pointer-events: none; white-space: nowrap;
  z-index: 9999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error   { background: var(--danger); }
.toast.toast-success { background: var(--success); }

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-body {
  display: flex; min-height: 100vh;
  background: var(--gray-100); font-size: 14px;
}

/* Sidebar */
.sidebar {
  width: 240px; min-height: 100vh;
  background: var(--primary);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 200; transition: width .3s;
  overflow: hidden;
}
.sidebar.collapsed { width: 68px; }

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; color: white;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo  { font-size: 1.5rem; flex-shrink: 0; }
.sidebar-title { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.sidebar-sub   { font-size: 0.7rem; opacity: 0.6; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7); text-decoration: none;
  transition: all .2s; font-size: 0.87rem; white-space: nowrap;
}
.nav-item:hover  { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; font-weight: 600; }
.nav-icon { font-size: 1.1rem; flex-shrink: 0; }
.nav-logout { color: rgba(255,100,100,0.8); }
.nav-logout:hover { background: rgba(255,50,50,0.15); color: #fca5a5; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.1); }

/* Main Content */
.admin-main {
  margin-left: 240px; flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh; transition: margin .3s;
}
.admin-main.expanded { margin-left: 68px; }

.topbar {
  background: white; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); position: sticky; top: 0; z-index: 100;
}
.menu-toggle {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  color: var(--gray-600); padding: 4px;
}
.topbar-title { flex: 1; font-size: 1rem; font-weight: 600; }
.badge-online { font-size: 0.75rem; color: var(--success); font-weight: 500; }

.content-wrap { padding: 24px; flex: 1; }

/* ── Admin Login ── */
.admin-login-body {
  min-height: 100vh; background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 36px 28px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon { font-size: 2.5rem; margin-bottom: 8px; }
.login-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.login-sub   { color: var(--gray-400); font-size: 0.8rem; margin-top: 4px; }
.login-form  { display: flex; flex-direction: column; gap: 16px; }

/* ── Stats Cards ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border-left: 4px solid transparent;
}
.stat-blue   { border-color: var(--primary-mid); }
.stat-green  { border-color: var(--success); }
.stat-purple { border-color: var(--purple); }
.stat-red    { border-color: var(--danger); }
.stat-icon   { font-size: 1.8rem; }
.stat-value  { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 0.75rem; color: var(--gray-600); margin-top: 2px; }

/* ── Charts ── */
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;
}
.chart-card {
  background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.chart-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 16px; }

.rm-breakdown { display: flex; flex-direction: column; gap: 10px; }
.rm-row  { display: flex; align-items: center; gap: 8px; }
.rm-label { width: 120px; font-size: 0.78rem; color: var(--gray-600); flex-shrink: 0; }
.rm-bar-wrap { flex: 1; background: var(--gray-100); border-radius: 999px; height: 8px; }
.rm-bar  { height: 8px; background: var(--primary-mid); border-radius: 999px; min-width: 2px; transition: width .5s ease; }
.rm-count { font-size: 0.72rem; color: var(--gray-600); white-space: nowrap; }

.daily-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 8px; }
.bar-col     { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 4px; }
.bar-label-top { font-size: 0.68rem; font-weight: 600; color: var(--primary); }
.bar         { width: 100%; background: var(--primary-mid); border-radius: 4px 4px 0 0; min-height: 4px; transition: height .5s ease; }
.bar-label   { font-size: 0.65rem; color: var(--gray-400); text-align: center; }

/* ── Table Card ── */
.table-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 24px;
}
.table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.table-header h3 { font-size: 0.95rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.82rem;
}
.data-table th {
  background: var(--gray-50); padding: 10px 14px; text-align: left;
  font-weight: 600; font-size: 0.75rem; color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
.data-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle;
}
.data-table tr:hover td { background: var(--gray-50); }
.data-table tr.row-cancelled td { opacity: 0.6; }
.empty-row { text-align: center; color: var(--gray-400); padding: 32px !important; }

.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--gray-200);
  vertical-align: middle; margin-right: 6px;
}
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 500; }
.user-uuid { font-size: 0.68rem; color: var(--gray-400); font-family: monospace; }
.cancel-info, .cancel-reason { font-size: 0.68rem; color: var(--gray-400); margin-top: 2px; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-student  { background: var(--primary-lt); color: var(--primary); }
.badge-general  { background: var(--purple-lt);  color: var(--purple); }
.badge-active   { background: var(--success-lt); color: var(--success); }
.badge-cancelled{ background: var(--danger-lt);  color: var(--danger); }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; }
.page-btn { padding: 6px 14px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); text-decoration: none; color: var(--primary-mid); font-size: 0.82rem; }
.page-btn:hover { background: var(--primary-lt); border-color: var(--primary-mid); }
.page-info { font-size: 0.82rem; color: var(--gray-600); }

/* ── Filter ── */
.filter-card {
  background: white; border-radius: var(--radius); padding: 16px 20px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.filter-form  { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.form-select  { padding: 9px 12px; border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm); font-family: inherit; font-size: 0.85rem; background: white; }
.filter-result { font-size: 0.78rem; color: var(--gray-600); }

/* ── Config Page ── */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.config-section {
  background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.config-section.full-width { grid-column: 1 / -1; }
.config-section-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.config-desc { font-size: 0.78rem; color: var(--gray-600); margin-bottom: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head .config-section-title { margin-bottom: 0; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.flex-1   { flex: 1; min-width: 200px; }
.font-mono { font-family: monospace; font-size: 0.82rem; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-item { background: var(--gray-50); border-radius: var(--radius-sm); padding: 12px 14px; }
.info-key  { display: block; font-size: 0.72rem; color: var(--gray-400); margin-bottom: 4px; }
.info-val  { font-size: 0.82rem; word-break: break-all; }
.rm-list   { display: flex; flex-direction: column; gap: 8px; }
.rm-item   { background: var(--gray-50); border-radius: var(--radius-sm); padding: 10px 14px; }
.rm-item-id   { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rm-item-name { font-weight: 500; font-size: 0.85rem; margin-bottom: 2px; }
.rm-item-areas { font-size: 0.72rem; color: var(--gray-400); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: white; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-md);
}
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ── Alert ── */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.83rem; margin-bottom: 12px;
}
.alert-success { background: var(--success-lt); color: var(--success); }
.alert-error   { background: var(--danger-lt);  color: var(--danger); }
.alert-info    { background: var(--primary-lt); color: var(--primary); }
.mx-20 { margin: 12px 24px; }

/* ── Utilities ── */
.mt-12 { margin-top: 12px; }
.empty-text { color: var(--gray-400); font-size: 0.82rem; padding: 12px 0; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-240px); }
  .sidebar.mobile-open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .charts-row { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: 1fr; }
}
