/* ================================================================
   School Connect – Main Stylesheet
   Design: Professional Navy-Blue Dashboard
   ================================================================ */

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

:root {
  --bedford-blue:   #B8D4E3;   /* #023-4 ฟ้าอ่อน */
  --secrets-sea:    #7BAFC9;   /* #026-4 ฟ้าเทา */
  --moonlight-bay:  #3A7DA8;   /* #025-5 ฟ้าเข้ม */
  --sapphire-gem:   #1A4F7A;   /* #022-6 น้ำเงินเข้ม */
  --bon-voyage:     #0D2D4E;   /* #137-6 กรมท่าเข้ม */
  --gold:           #BF932A;   /* ทอง */
  --gold-light:     #F0C84A;
  --white:          #FFFFFF;
  --light-bg:       #F0F5FA;
  --card-bg:        #FFFFFF;
  --sidebar-bg:     #0D2D4E;
  --sidebar-hover:  #1A4F7A;
  --sidebar-active: #3A7DA8;
  --text-dark:      #0D1F35;
  --text-mid:       #4A6280;
  --text-light:     #8FA8C0;
  --border:         #D4E3EE;
  --danger:         #D94040;
  --success:        #2A9D5C;
  --warning:        #E6A817;
  --info:           #3A7DA8;
  --shadow-sm:      0 2px 8px rgba(13, 45, 78, 0.08);
  --shadow-md:      0 4px 20px rgba(13, 45, 78, 0.12);
  --shadow-lg:      0 8px 40px rgba(13, 45, 78, 0.18);
  --radius:         12px;
  --radius-sm:      8px;
  --font-main:      'Sarabun', sans-serif;
  --font-head:      'Prompt', sans-serif;
  --sidebar-width:  260px;
  --topbar-height:  64px;
  --transition:     all 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: 15px;
  color: var(--text-dark);
  background: var(--light-bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
  box-shadow: 4px 0 24px rgba(0,0,0,0.18);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 46px; height: 46px;
  background: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25), 0 2px 8px rgba(0,0,0,0.25);
  padding: 3px;
}
.brand-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.brand-text {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  color: var(--white);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--bedford-blue);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-light);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0 24px 24px 0;
  margin: 2px 12px 2px 0;
  transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
  padding-left: 24px;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(58, 125, 168, 0.4);
}

.nav-item .icon { font-size: 18px; min-width: 22px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--bon-voyage);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--moonlight-bay), var(--bedford-blue));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; font-weight: 600;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--bedford-blue); }
.logout-btn { color: rgba(255,255,255,0.5); font-size: 18px; cursor: pointer; transition: var(--transition); text-decoration: none; }
.logout-btn:hover { color: #ff6b6b; }

/* ----------------------------------------------------------------
   Main Content
   ---------------------------------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------
   Topbar
   ---------------------------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  color: var(--bon-voyage);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-mid);
  transition: var(--transition);
  text-decoration: none;
  background: var(--white);
  font-size: 18px;
}
.notif-btn:hover { background: var(--light-bg); color: var(--sapphire-gem); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

/* ----------------------------------------------------------------
   Page Content
   ---------------------------------------------------------------- */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-family: var(--font-head);
  font-size: 24px;
  font-weight: 700;
  color: var(--bon-voyage);
  line-height: 1.3;
}
.page-subtitle { font-size: 14px; color: var(--text-mid); margin-top: 4px; }

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 600;
  color: var(--bon-voyage);
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 24px; }

/* ----------------------------------------------------------------
   Stat Cards
   ---------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--accent, var(--moonlight-bay));
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  background: var(--icon-bg, rgba(58, 125, 168, 0.12));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-value {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--bon-voyage);
  line-height: 1;
}
.stat-label { font-size: 13px; color: var(--text-mid); margin-top: 4px; }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--moonlight-bay), var(--sapphire-gem));
  color: white;
  box-shadow: 0 4px 12px rgba(26, 79, 122, 0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(26, 79, 122, 0.5); transform: translateY(-1px); color: white; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), #8a6a1a);
  color: white;
  box-shadow: 0 4px 12px rgba(191, 147, 42, 0.35);
}
.btn-gold:hover { box-shadow: 0 6px 20px rgba(191, 147, 42, 0.5); transform: translateY(-1px); color: white; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--moonlight-bay);
  color: var(--moonlight-bay);
}
.btn-outline:hover { background: var(--moonlight-bay); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 7px;
}
.form-label .req { color: var(--danger); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 14px;
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--moonlight-bay);
  box-shadow: 0 0 0 3px rgba(58, 125, 168, 0.15);
}
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 12px; color: var(--text-mid); margin-top: 5px; }

/* ----------------------------------------------------------------
   Table
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  background: var(--bon-voyage);
  color: white;
  font-weight: 600;
  padding: 13px 16px;
  text-align: left;
  font-family: var(--font-head);
  font-size: 13px;
  white-space: nowrap;
}
.data-table thead th:first-child { border-radius: 8px 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 8px 0 0; }
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(58, 125, 168, 0.05); }
.data-table tbody td { padding: 12px 16px; color: var(--text-dark); vertical-align: middle; }

/* ----------------------------------------------------------------
   Badges / Status
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(42, 157, 92, 0.12); color: var(--success); }
.badge-warning { background: rgba(230, 168, 23, 0.12); color: var(--warning); }
.badge-danger  { background: rgba(217, 64, 64, 0.12); color: var(--danger); }
.badge-info    { background: rgba(58, 125, 168, 0.12); color: var(--info); }
.badge-gold    { background: rgba(191, 147, 42, 0.15); color: var(--gold); }
.badge-neutral { background: rgba(74, 98, 128, 0.1); color: var(--text-mid); }

/* ----------------------------------------------------------------
   Alert
   ---------------------------------------------------------------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  margin-bottom: 20px;
  font-size: 14px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-success { background: rgba(42,157,92,0.08); border-color: var(--success); color: #1a6b3c; }
.alert-danger   { background: rgba(217,64,64,0.08);  border-color: var(--danger);  color: #8b1a1a; }
.alert-warning  { background: rgba(230,168,23,0.08); border-color: var(--warning); color: #7a5100; }
.alert-info     { background: rgba(58,125,168,0.08); border-color: var(--info);    color: var(--sapphire-gem); }

/* ----------------------------------------------------------------
   Grid helpers
   ---------------------------------------------------------------- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ----------------------------------------------------------------
   Auth / Login Page
   ---------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bon-voyage) 0%, var(--sapphire-gem) 40%, var(--moonlight-bay) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(191, 147, 42, 0.15) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(58, 125, 168, 0.3) 0%, transparent 50%);
}

.auth-card {
  background: white;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.35);
  width: 100%; max-width: 460px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.auth-header {
  background: linear-gradient(135deg, var(--bon-voyage), var(--sapphire-gem));
  padding: 36px 40px 28px;
  text-align: center;
}

.auth-logo {
  width: 100px; height: 100px;
  background: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
  margin: 0 auto 18px;
  box-shadow: 0 0 0 5px rgba(255,255,255,0.25), 0 8px 32px rgba(0,0,0,0.3);
  overflow: hidden;
  padding: 6px;
}
.auth-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.auth-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.auth-subtitle { font-size: 14px; color: var(--bedford-blue); }
.auth-body { padding: 36px 40px; }

.auth-footer {
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 14px;
  color: var(--text-mid);
  background: var(--light-bg);
}

.auth-footer a { color: var(--moonlight-bay); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------
   Progress Steps
   ---------------------------------------------------------------- */
.steps {
  display: flex; align-items: center; margin-bottom: 32px;
}
.step { display: flex; align-items: center; flex: 1; }
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: var(--text-light);
  background: white;
  flex-shrink: 0;
  transition: var(--transition);
}
.step.active .step-num { background: var(--moonlight-bay); border-color: var(--moonlight-bay); color: white; }
.step.done .step-num   { background: var(--success); border-color: var(--success); color: white; }
.step-label { font-size: 12px; color: var(--text-mid); margin-left: 8px; white-space: nowrap; }
.step.active .step-label { color: var(--moonlight-bay); font-weight: 600; }
.step-line { flex: 1; height: 2px; background: var(--border); margin: 0 8px; }
.step.done .step-line { background: var(--success); }

/* ----------------------------------------------------------------
   Activity Card
   ---------------------------------------------------------------- */
.activity-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}
.activity-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }

.activity-card-header {
  background: linear-gradient(135deg, var(--sapphire-gem), var(--bon-voyage));
  padding: 20px 22px;
  position: relative;
}
.activity-year-badge {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: white;
}
.activity-name {
  font-family: var(--font-head);
  font-size: 18px; font-weight: 700;
  color: white; margin-bottom: 4px;
}
.activity-theme { font-size: 13px; color: var(--bedford-blue); }
.activity-card-body { padding: 18px 22px; }
.activity-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-mid); }
.activity-meta-item { display: flex; align-items: center; gap: 5px; }
.activity-progress-wrap { margin-top: 14px; }
.activity-progress-label {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-mid); margin-bottom: 5px;
}
.progress-bar { height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--moonlight-bay), var(--gold));
  border-radius: 10px;
  transition: width 0.8s ease;
}
.activity-card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}

/* ----------------------------------------------------------------
   Award Display
   ---------------------------------------------------------------- */
.award-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--light-bg);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  transition: var(--transition);
}
.award-icon-wrap {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.award-info { flex: 1; }
.award-name { font-weight: 600; font-size: 14px; }
.award-activity { font-size: 12px; color: var(--text-mid); margin-top: 2px; }

/* ----------------------------------------------------------------
   Charts placeholder
   ---------------------------------------------------------------- */
.chart-container { position: relative; }

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .auth-body, .auth-header { padding: 24px; }
}

/* ----------------------------------------------------------------
   Utilities
   ---------------------------------------------------------------- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.w-100 { width: 100%; }
.font-head { font-family: var(--font-head); }
.text-gold   { color: var(--gold); }
.text-mid    { color: var(--text-mid); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--secrets-sea); }