@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  /* Premium Design Tokens */
  --primary-gradient: linear-gradient(135deg, #ff2d55 0%, #ff5277 100%);
  --secondary-gradient: linear-gradient(135deg, #5856d6 0%, #7d7aff 100%);
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.4);

  --primary-color: #ff2d55;
  --secondary-color: #5856d6;
  --bg-color: #f2f2f7;
  --text-main: #1d1d1f;
  --text-muted: #86868b;

  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-thai: 'Sarabun', sans-serif;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-thai), var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(circle at 10% 20%, rgba(255, 45, 85, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(88, 86, 214, 0.05) 0%, transparent 40%);
}

.container {
  width: 92%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem 0;
}

.container-narrow {
  max-width: 480px;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1), box-shadow 0.3s ease;
}

.glass-card:hover {
  box-shadow: var(--shadow-lg);
}

/* Typography Enhancements */
h1 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 2.5rem;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0 0 1.5rem 0;
}

.hero-section {
  text-align: center;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.6;
}

/* Buttons */
.primary-btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(255, 45, 85, 0.3);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.primary-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 8px rgba(255, 45, 85, 0.3);
}

/* Input Styles */
.input-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.input-group label {
  display: block;
  margin-bottom: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  padding-left: 4px;
}

select,
input {
  width: 100%;
  padding: 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: white;
  font-size: 1rem;
  font-family: var(--font-thai);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

select:focus,
input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.1);
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-card {
  animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Dashboard Specific Redesign */
.score-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
  border-left: 6px solid var(--primary-color);
}

.score-card:hover {
  transform: translateX(5px);
}

.student-info h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.student-info p {
  margin: 4px 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.score-value {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--primary-color);
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--secondary-gradient);
  color: white;
  width: auto;
  padding: 1rem 1.8rem;
  border-radius: 50px;
  box-shadow: 0 10px 20px rgba(88, 86, 214, 0.4);
  border: none;
  font-weight: 600;
  z-index: 100;
  cursor: pointer;
  transition: all 0.3s ease;
}

.fab:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(88, 86, 214, 0.5);
}

/* Back Button */
.back-btn {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s ease;
}

.back-btn:hover {
  color: var(--primary-color);
}

/* ============================================
   PAGE HEADER (Dashboard)
   ============================================ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  margin-top: 1rem;
}

.page-title-group {
  text-align: right;
}

.page-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  background: none;
  -webkit-text-fill-color: var(--text-main);
}

.page-subtitle {
  margin: 3px 0 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============================================
   COLOR LEGEND CARD (Removed)
   ============================================ */

/* ============================================
   STATUS DOTS
   ============================================ */
.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-green {
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
}

.status-orange {
  background-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.18);
}

.status-red {
  background-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.18);
}

/* ============================================
   SCORE LIST & ROW ITEMS (Dashboard)
   ============================================ */
.score-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.score-row-item {
  background: white;
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  gap: 0;
}

.score-row-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.col-no,
.col-no-header {
  width: 40px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.col-name,
.col-name-header {
  flex: 1;
  font-weight: 600;
  color: var(--text-main);
  font-size: 1rem;
  padding-left: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-no-header,
.col-name-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.score-row-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.score-row-values {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 55%;
  flex-shrink: 0;
}

/* ============================================
   COLUMN HEADERS ROW (Dashboard)
   ============================================ */
.score-col-header-row {
  display: flex;
  align-items: flex-end;
  padding: 0 1.2rem 0.5rem;
  gap: 0;
}

.score-dots-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.col-label {
  width: 20px;
  font-size: 0.62rem;
  color: var(--text-muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 72px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.3;
  font-weight: 500;
}

.col-dot-cell {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Dashboard table: number + name columns */
.col-no-header,
.col-no {
  width: 32px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.col-no-header {
  font-weight: 600;
  font-size: 0.72rem;
}

.col-name-header,
.col-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-name-header {
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============================================
   PROGRESS BAR (Check Score Page)
   ============================================ */
.score-row-progress {
  flex: 1;
  padding: 0 1rem;
}

.progress-container {
  height: 6px;
  background: #f2f2f7;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-green {
  background: var(--success);
}

.progress-orange {
  background: var(--warning);
}

.progress-red {
  background: var(--danger);
}

.score-row-value {
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.score-row-max {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 45, 85, 0.15);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   REPORT CARD (Check Score Result)
   ============================================ */
.report-card {
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  padding: 1.6rem 1.8rem;
  color: white;
  margin-bottom: 1rem;
  box-shadow: 0 12px 32px rgba(255, 45, 85, 0.28);
  position: relative;
  overflow: hidden;
}

.report-class-chip {
  display: inline-block;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 0.22rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  letter-spacing: 0.03em;
}

.report-student-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.report-student-meta {
  font-size: 0.83rem;
  opacity: 0.75;
  margin-bottom: 1.2rem;
}

.report-score-display {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 1rem 1.2rem 0.8rem;
  text-align: center;
}

.report-score-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.report-score-number {
  font-family: var(--font-main);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
}

.report-score-denom {
  font-size: 1.05rem;
  opacity: 0.65;
  font-weight: 500;
}

.report-score-label {
  font-size: 0.75rem;
  opacity: 0.75;
  letter-spacing: 0.05em;
  font-weight: 500;
  text-transform: uppercase;
}

.report-grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 0.28rem 0.9rem;
  font-size: 0.88rem;
  margin-top: 0.9rem;
}

/* ============================================
   CHECK SCORE ICON
   ============================================ */
.check-score-icon {
  background: var(--primary-gradient);
  width: 72px;
  height: 72px;
  border-radius: 22px;
  margin: 0 auto 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 20px rgba(255, 45, 85, 0.25);
}

/* ============================================
   PROFILE CARD (Check Score Page)
   ============================================ */
.profile-card {
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  padding: 1.6rem 1.8rem;
  color: white;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(255, 45, 85, 0.25);
}

.student-name-large {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.student-info-row {
  display: flex;
  gap: 1rem;
  font-size: 0.88rem;
  opacity: 0.9;
  flex-wrap: wrap;
}

.total-score {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: var(--font-main);
  margin-top: 1rem;
}

/* ============================================
   SCORE SUMMARY FOOTER (Check Score Page)
   ============================================ */
.score-summary-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 2px solid var(--primary-color);
  box-shadow: 0 4px 16px rgba(255, 45, 85, 0.12);
  margin-top: 0.3rem;
}

.score-summary-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.score-summary-value {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.score-summary-number {
  font-family: var(--font-main);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary-color);
}

.score-summary-max {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================
   REPORT CARD SCORES ROW (v1.7)
   ============================================ */
.report-scores-row {
  display: flex;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 0.85rem 0.75rem;
  margin-top: 1rem;
  gap: 0;
}

.report-score-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  text-align: center;
  padding: 0 0.3rem;
}

.report-score-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.25);
  margin: 0.3rem 0;
  align-self: stretch;
  flex-shrink: 0;
}

.report-grade-big {
  font-family: var(--font-main);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}

.report-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.report-progress-track {
  flex: 1;
  height: 5px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 3px;
  overflow: hidden;
}

.report-progress-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.report-progress-label {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.8;
  min-width: 32px;
  text-align: right;
}

/* ============================================
   SCORE SECTION LABEL (v1.7)
   ============================================ */
.score-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 1rem 0.4rem 0.35rem;
}

/* ============================================
   GRAND TOTAL CARD (v1.7)
   ============================================ */
.score-grand-total-card {
  background: linear-gradient(135deg, #1d1d1f 0%, #3a3a3c 100%);
  border-radius: var(--radius-sm);
  padding: 1.2rem 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  color: white;
}

.grand-total-label {
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0.85;
  margin-bottom: 0.35rem;
}

.grand-grade-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.18rem 0.65rem;
  font-size: 0.82rem;
}

/* ============================================
   HOME PAGE (v1.7)
   ============================================ */
.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 3rem;
}

.home-hero {
  width: 100%;
  background: var(--primary-gradient);
  color: white;
  text-align: center;
  padding: 3rem 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 0 0 32px 32px;
  box-shadow: 0 8px 32px rgba(255, 45, 85, 0.22);
}

.home-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  padding: 8px;
  margin-bottom: 1.1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.home-title {
  font-family: var(--font-main);
  font-size: 2rem;
  font-weight: 700;
  background: none;
  -webkit-text-fill-color: white;
  color: white;
  line-height: 1.2;
  margin: 0 0 0.6rem;
}

.home-school {
  font-size: 0.85rem;
  opacity: 0.82;
  margin: 0;
  line-height: 1.5;
  font-weight: 400;
}

.home-card {
  width: 92%;
  max-width: 420px;
  margin-top: -1.2rem;
}

.home-meta {
  margin-bottom: 1.2rem;
  text-align: center;
}

.home-subject {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 0 0 0.2rem;
}

.home-teacher {
  font-size: 0.85rem;
  color: var(--primary-color);
  font-weight: 500;
  margin: 0;
}

.home-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.4rem;
}

/* ============================================
   FAB BUTTON (override for compact layout)
   ============================================ */
.fab {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-thai);
  font-size: 0.95rem;
}

/* ============================================
   RESPONSIVE OVERRIDES
   ============================================ */
@media (max-width: 600px) {
  h1 {
    font-size: 2rem;
  }

  .glass-card {
    padding: 1.8rem;
  }

  .container {
    width: 94%;
  }

  .score-row-item {
    padding: 0.8rem 1rem;
  }

  .score-row-values {
    max-width: 50%;
  }

  .page-title {
    font-size: 1.2rem;
  }

  .legend-items {
    gap: 1rem;
  }

  .fab {
    bottom: 1.2rem;
    right: 1.2rem;
    padding: 0.85rem 1.4rem;
    font-size: 0.9rem;
  }
}