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

:root {
  --primary: #2563EB;       /* Blue 600 - สีฟ้ามาตรฐานองค์กร */
  --primary-hover: #1D4ED8;
  
  --bg-app: #F8FAFC;        /* Slate 50 - ปรับพื้นหลังพื้นที่ทำงานให้สว่างขึ้นนิดนึง เพื่อให้เมนูดูเด่นแบบละมุน */
  --bg-surface: #FFFFFF;    /* สีการ์ดและพื้นที่หลัก */
  
  /* --- สีสำหรับ Sidebar (เทา-ฟ้าพาสเทล) --- */
  --bg-sidebar: #F0F4F8;    /* สีฟ้าอมเทาพาสเทล สบายตามาก */
  --text-sidebar: #475569;  /* Slate 600 - สีตัวหนังสือเมนู */
  --border-sidebar: #E2E8F0;/* Slate 200 - สีเส้นขอบเมนู */

  --text-main: #111827;     /* Gray 900 */
  --text-muted: #6B7280;    /* Gray 500 */
  --border-light: #E5E7EB;  /* Gray 200 */
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Prompt', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
}

/* ==================
   Sidebar (Pastel Blue-Gray)
================== */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  transition: transform 0.3s ease;
  z-index: 1000;
}

.sidebar-header {
  padding: 24px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.sidebar-header .logo-dot {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.nav-menu {
  list-style: none;
  padding: 12px;
  margin: 0 16px; 
  background: #FFFFFF;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-light);
}

.nav-menu li a {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all 0.2s;
}

.nav-menu li:last-child a {
  margin-bottom: 0;
}

.nav-menu li a:hover {
  background-color: #F8FAFC;
  color: var(--primary);
}

.nav-menu li a.active {
  background-color: #EFF6FF; 
  color: var(--primary);
  font-weight: 600;
}

/* แยกปุ่ม Sign Out ไว้ด้านล่าง */
.sidebar-footer {
  padding: 24px 16px;
  margin-top: auto; 
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--text-sidebar); /* เปลี่ยนเป็นสีเทาฟ้าให้กลมกลืน */
  background-color: rgba(71, 85, 105, 0.05); /* พื้นหลังสีฟ้าเทาบางๆ */
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
  transition: all 0.2s;
}

.sidebar-footer a:hover {
  color: #EF4444; /* เปลี่ยนข้อความเป็นสีแดงเมื่อชี้ */
  background-color: rgba(239, 68, 68, 0.08); /* เปลี่ยนพื้นหลังเป็นสีแดงบางๆเมื่อชี้ */
}

/* ==================
   Main Layout & Topbar
================== */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--bg-surface);
  height: 70px;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 16px;
  border: 1px solid var(--border-light);
  border-radius: 20px;
  background: var(--bg-surface);
}

.content-area {
  padding: 32px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ==================
   Cards & Stats
================== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-surface);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s;
}

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

.stat-label { 
  color: var(--text-muted); 
  font-size: 13px; 
  font-weight: 600; 
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px; 
}

.stat-value { 
  font-size: 32px; 
  font-weight: 700; 
  color: var(--text-main); 
  letter-spacing: -1px;
}

/* ==================
   Buttons & Inputs
================== */
.btn-primary {
  background-color: var(--primary);
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

/* ==================
   Mobile Responsive
================== */
.mobile-nav {
  display: none;
  background: var(--bg-sidebar);
  color: var(--text-main);
  height: 64px;
  padding: 0 20px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-sidebar);
  position: sticky;
  top: 0;
  z-index: 1100;
}

.menu-toggle {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 24px;
  cursor: pointer;
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-nav { display: flex; }
  .topbar { display: none; }
  .content-area { padding: 20px; }
}

/* ==================
   Animations & Status
================== */
@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.dot, .logo-dot, .mobile-status-dot {
  animation: pulse-glow 2s infinite;
}

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

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s ease-in-out infinite;
  margin-right: 8px;
  vertical-align: middle;
}