/* ============================================================
   HomePua Premium UI — โรงเรียนปัว
   ============================================================ */
:root {
  --primary:      #4c1d95;
  --primary-lt:   #7c3aed;
  --primary-glow: rgba(124,58,237,.35);
  --secondary:    #e67e22;
  --success:      #059669;
  --danger:       #dc2626;
  --warning:      #d97706;
  --purple:       #7c3aed;
  --sidebar-w:    260px;
  --navbar-h:     60px;
  --font:         'Sarabun', sans-serif;
  --radius:       14px;
  --radius-sm:    8px;
  --shadow:       0 2px 20px rgba(76,29,149,.08);
  --shadow-md:    0 4px 30px rgba(76,29,149,.16);
  --bg:           #f5f3ff;
  --card-bg:      #ffffff;
  --border:       #ede9fe;
  --text:         #1a1033;
  --text-muted:   #6b7280;
}

/* ── Reset ─────────────────────────────────────────────── */
*,*::before,*::after { box-sizing:border-box; }
body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary-lt); text-decoration: none; }
a:hover { color: var(--primary); }

/* ── Navbar Top ─────────────────────────────────────────── */
.navbar-top {
  height: var(--navbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  z-index: 1040;
  padding: 0 1rem;
}
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.brand-name { font-size: 15px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.brand-sub  { font-size: 11px; color: var(--text-muted); }

.sidebar-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm);
  padding: 6px 10px; transition: all .2s;
}
.sidebar-toggle:hover { background: var(--bg); color: var(--primary); }

.user-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 50px; padding: 4px 12px 4px 4px;
  display: flex; align-items: center; gap: 8px;
  transition: all .2s;
}
.user-btn:hover { background: var(--bg); }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--navbar-h); left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--navbar-h));
  background: linear-gradient(180deg, #1a0533 0%, #2d0b5f 50%, #3b0f75 100%);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  transition: transform .3s ease;
  z-index: 1030;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-inner { flex: 1; padding: 16px 12px; }

.sidebar-section { margin-bottom: 8px; }
.sidebar-heading {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: rgba(255,255,255,.35);
  padding: 12px 12px 4px;
}

.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7); font-size: 14px; font-weight: 500;
  transition: all .2s; margin-bottom: 2px;
}
.nav-link:hover {
  background: rgba(255,255,255,.1); color: #fff;
  transform: translateX(4px);
}
.nav-link.active {
  background: linear-gradient(135deg, rgba(124,58,237,.9), rgba(139,92,246,.9));
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 15px rgba(124,58,237,.45);
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-label { flex: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.btn-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  color: rgba(255,255,255,.6); font-size: 14px;
  border-radius: var(--radius-sm); transition: all .2s;
  background: none; border: none; cursor: pointer;
}
.btn-logout:hover { background: rgba(231,76,60,.2); color: #ff6b6b; }
.sidebar-version { text-align: center; font-size: 11px; color: rgba(255,255,255,.2); margin-top: 8px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 1029;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  padding: calc(var(--navbar-h) + 20px) 24px 40px;
  min-height: 100vh;
  transition: margin .3s ease;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px; font-weight: 700; color: var(--primary);
  margin: 0 0 4px;
}
.breadcrumb { font-size: 13px; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ── Premium Card ─────────────────────────────────────────── */
.card-premium {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-premium .card-body { padding: 20px; }

.card-header-premium {
  background: linear-gradient(135deg, #faf5ff, #fff);
  border-bottom: 2px solid var(--border);
  border-top: 3px solid var(--primary-lt);
  padding: 14px 20px;
  font-weight: 700; font-size: 14px; color: var(--primary);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
  border: none; overflow: hidden; position: relative;
}
.stat-card::after {
  content: ''; position: absolute;
  right: -20px; top: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,.1); border-radius: 50%;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-blue   { background: linear-gradient(135deg, #4c1d95, #7c3aed); color: #fff; }
.stat-green  { background: linear-gradient(135deg, #064e3b, #059669); color: #fff; }
.stat-orange { background: linear-gradient(135deg, #92400e, #d97706); color: #fff; }
.stat-purple { background: linear-gradient(135deg, #5b21b6, #8b5cf6); color: #fff; }
.stat-red    { background: linear-gradient(135deg, #991b1b, #dc2626); color: #fff; }

.stat-icon {
  width: 56px; height: 56px;
  background: rgba(255,255,255,.2); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; opacity: .85; margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────────── */
.table th { font-size: 12px; font-weight: 700; text-transform: uppercase;
             letter-spacing: .5px; color: var(--text-muted); }
.table td { font-size: 14px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { font-family: var(--font); font-weight: 600; border-radius: var(--radius-sm); }
.btn-primary   { background: linear-gradient(135deg, var(--primary), var(--primary-lt)); border-color: var(--primary); }
.btn-primary:hover { background: linear-gradient(135deg, #3b1678, #6d28d9); border-color: #3b1678; }
.btn-xs {
  padding: 3px 8px; font-size: 12px;
  border-radius: 6px; line-height: 1.5;
}

/* ── Mini Avatar ──────────────────────────────────────────── */
.mini-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0;
}
.admin-bg   { background: linear-gradient(135deg,#991b1b,#dc2626); }
.teacher-bg { background: linear-gradient(135deg,#92400e,#d97706); }
.student-bg { background: linear-gradient(135deg,#4c1d95,#7c3aed); }

/* ── Nav Tabs ─────────────────────────────────────────────── */
.nav-tabs-premium { border-bottom: 2px solid var(--border); gap: 4px; }
.nav-tabs-premium .nav-link {
  color: var(--text-muted); font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid transparent; background: none;
  transition: all .2s;
}
.nav-tabs-premium .nav-link:hover { color: var(--primary); background: var(--bg); }
.nav-tabs-premium .nav-link.active {
  color: var(--primary); background: var(--card-bg);
  border-color: var(--border) var(--border) var(--card-bg);
  border-bottom-color: #fff;
}

/* ── Info Fields ──────────────────────────────────────────── */
.info-field { padding: 10px; background: var(--bg); border-radius: var(--radius-sm); }
.info-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
               letter-spacing: .5px; color: var(--text-muted); margin-bottom: 3px; }
.info-val   { font-size: 14px; font-weight: 500; color: var(--text); }

/* ── Health Stat ──────────────────────────────────────────── */
.health-stat-card {
  text-align: center; padding: 20px;
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.health-stat-icon { font-size: 28px; margin-bottom: 8px; }
.health-stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.health-stat-value { font-size: 22px; font-weight: 800; color: var(--text); }

/* ── Map ──────────────────────────────────────────────────── */
.coord-display {
  background: #f0f8ff; border: 1px solid #bde0fe;
  border-radius: var(--radius-sm); padding: 12px;
}
.coord-display-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0;
}
.coord-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.coord-value { font-size: 14px; font-weight: 700; color: var(--primary); font-family: monospace; }
.map-thumb-card { background: var(--bg); border-radius: var(--radius); padding: 12px; }

/* ── Student Avatar ───────────────────────────────────────── */
.student-avatar-lg {
  width: 80px; height: 80px; border-radius: 20px; overflow: hidden;
  border: 3px solid var(--border); flex-shrink: 0;
}
.student-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initials-lg {
  width: 100%; height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 32px; font-weight: 700;
}

/* ── Section Cards (Student Dashboard) ───────────────────── */
.section-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); transition: all .2s;
  color: var(--text); text-decoration: none;
}
.section-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--text); }
.section-card-icon {
  width: 50px; height: 50px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff; flex-shrink: 0;
}
.section-blue   .section-card-icon { background: linear-gradient(135deg,#4c1d95,#7c3aed); }
.section-green  .section-card-icon { background: linear-gradient(135deg,#064e3b,#059669); }
.section-orange .section-card-icon { background: linear-gradient(135deg,#92400e,#d97706); }
.section-purple .section-card-icon { background: linear-gradient(135deg,#5b21b6,#8b5cf6); }
.section-red    .section-card-icon { background: linear-gradient(135deg,#991b1b,#dc2626); }
.section-card-body { flex: 1; min-width: 0; }
.section-card-label { font-weight: 700; font-size: 15px; line-height: 1.2; }
.section-card-sub   { font-size: 12px; color: var(--text-muted); }
.section-card-status { font-size: 12px; margin-top: 4px; font-weight: 600; }
.section-card-status.done    { color: var(--success); }
.section-card-status.pending { color: var(--danger); }
.section-card-arrow { color: var(--text-muted); }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.empty-icon {
  width: 80px; height: 80px; border-radius: 20px;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 32px; color: var(--text-muted);
  margin: 0 auto 16px;
}

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #0d0520; overflow: hidden;
}
.login-bg { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.login-blob {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,.35), transparent 70%);
  animation: blobFloat 8s ease-in-out infinite alternate;
}
.blob-1 { width: 600px; height: 600px; top: -200px; left: -200px; animation-delay: 0s; }
.blob-2 { width: 400px; height: 400px; bottom: -100px; right: -100px; animation-delay: 3s; }
.blob-3 { width: 300px; height: 300px; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: 1.5s; }
@keyframes blobFloat { from { transform: scale(1) rotate(0deg); } to { transform: scale(1.2) rotate(15deg); } }

.login-container {
  position: relative; z-index: 10; width: 100%;
  max-width: 440px; padding: 20px;
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px; padding: 40px;
  box-shadow: 0 25px 80px rgba(0,0,0,.5);
  backdrop-filter: blur(10px);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-icon-wrap {
  width: 70px; height: 70px;
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff; margin: 0 auto 12px;
  box-shadow: 0 10px 30px rgba(124,58,237,.5);
}
.login-school   { font-size: 22px; font-weight: 800; color: var(--primary); margin: 0 0 4px; }
.login-subtitle { font-size: 14px; color: var(--text-muted); margin: 0; }
.login-label    { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 6px; }

.input-group-login .input-group-text {
  background: var(--bg); border-color: var(--border); color: var(--text-muted);
}
.input-group-login .form-control {
  border-left: none; border-color: var(--border);
  font-size: 15px; padding: 12px;
}
.input-group-login .form-control:focus { box-shadow: none; border-color: var(--primary-lt); }

.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  border: none; color: #fff; padding: 14px;
  font-size: 16px; font-weight: 700; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(124,58,237,.4); transition: all .2s;
}
.btn-login:hover {
  transform: translateY(-2px); box-shadow: 0 10px 30px rgba(124,58,237,.55);
  color: #fff; background: linear-gradient(135deg, #3b1678, #6d28d9);
}
.btn-toggle-pwd { background: var(--bg); border-color: var(--border); border-left: none; }
.login-footer { text-align: center; margin-top: 20px; }
.login-help    { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.login-copyright {
  text-align: center; color: rgba(255,255,255,.4); font-size: 12px; margin-top: 20px;
}

/* ── Flash ────────────────────────────────────────────────── */
.flash-message { margin: 16px 24px 0; border-radius: var(--radius-sm); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,.3);
  }
  .sidebar-overlay.show { display: block; }
  .main-wrapper { margin-left: 0; padding: calc(var(--navbar-h) + 16px) 16px 32px; }
}

@media (max-width: 575.98px) {
  .page-title  { font-size: 18px; }
  .stat-value  { font-size: 24px; }
  .section-card { padding: 14px; gap: 12px; }
  .section-card-icon { width: 40px; height: 40px; font-size: 18px; }
  .login-card  { padding: 28px 20px; }
}

/* ── Utility ──────────────────────────────────────────────── */
.text-sm   { font-size: 13px; }
.card-sm   { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sticky-top { top: calc(var(--navbar-h) + 20px) !important; }

/* Pagination */
.page-link { color: var(--primary); font-size: 13px; }
.page-item.active .page-link {
  background: var(--primary); border-color: var(--primary);
}
