/* === PAT Score Tracker — Stylesheet === */

:root {
  /* AIS Indonesia Brand Palette */
  --teal-900: #003D32;
  --teal-800: #004A3D;
  --teal-700: #005C4B;
  --teal-600: #007A63;
  --teal-500: #009878;
  --teal-400: #33B396;
  --teal-100: #CCE8E0;
  --teal-50:  #E8F4F0;
  --gold-500: #F5B731;
  --gold-400: #F7C85A;
  --gold-300: #FAD983;
  --gold-200: #FCE9B1;
  --gold-100: #FEF4D8;
  --gold-50:  #FFFAEB;
  --grey-900: #1c2833;
  --grey-700: #2c3e50;
  --grey-500: #5d6d7e;
  --grey-400: #7f8c8d;
  --grey-300: #aeb6bf;
  --grey-200: #d5d8dc;
  --grey-100: #eaecee;
  --grey-50:  #f8f9fa;
  --white:    #ffffff;
  --green:    #27ae60;
  --green-bg: #eafaf1;
  --yellow:   #f39c12;
  --yellow-bg:#fef9e7;
  --orange:   #e67e22;
  --orange-bg:#fdf2e9;
  --red:      #c0392b;
  --red-bg:   #fdedec;
  --radius:   8px;
  --shadow:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--grey-50);
  color: var(--grey-900);
  line-height: 1.5;
  min-height: 100vh;
}

/* === HEADER === */
.header {
  background: linear-gradient(135deg, var(--teal-900), var(--teal-700));
  color: var(--white);
  padding: 0 1.5rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--gold-500);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 64px;
  flex-wrap: wrap;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header-logo { height: 48px; width: auto; flex-shrink: 0; }
.header-brand-text { display: flex; flex-direction: column; }
.header-brand-text h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.header-school { font-size: 0.72rem; font-weight: 500; opacity: 0.9; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-300); }
.header-subtitle { font-size: 0.72rem; color: rgba(255,255,255,0.6); letter-spacing: 0.01em; }
.header-nav { display: flex; gap: 0.25rem; }
.nav-btn {
  background: transparent;
  color: rgba(255,255,255,0.75);
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.nav-btn:hover { background: rgba(245,183,49,0.12); color: var(--white); }
.nav-btn.active { background: rgba(245,183,49,0.18); color: var(--gold-400); font-weight: 600; border-bottom: 2px solid var(--gold-500); }

/* === FILTERS === */
.filters-bar {
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  padding: 0.75rem 1.5rem;
}
.filters-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey-500);
}
.filter-group select, .filter-group input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--white);
  color: var(--grey-900);
  min-width: 140px;
}
.filter-group select:focus, .filter-group input:focus {
  outline: none;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(0,92,75,0.15);
}
.filter-search { flex: 1; min-width: 200px; }
.filter-search input { width: 100%; }

/* === MAIN === */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* === VIEWS === */
.view { display: none; }
.view.active { display: block; }

/* === CARDS === */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--teal-700);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--gold-200);
}

/* === KPI ROW === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--teal-700);
}
.kpi-card.green  { border-left-color: var(--green); }
.kpi-card.orange { border-left-color: var(--orange); }
.kpi-card.red    { border-left-color: var(--red); }
.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey-500);
  margin-bottom: 0.25rem;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--grey-900);
  line-height: 1.2;
}
.kpi-sub {
  font-size: 0.75rem;
  color: var(--grey-400);
  margin-top: 0.15rem;
}

/* === GRID === */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* === TABLES === */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--grey-50);
  color: var(--grey-700);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--grey-200);
  white-space: nowrap;
}
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { color: var(--teal-600); }
.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--grey-100);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gold-50); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* === FLAGS === */
.flag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.flag-strong     { background: var(--green-bg);  color: var(--green); }
.flag-expected   { background: var(--yellow-bg); color: var(--yellow); }
.flag-minimal    { background: var(--orange-bg); color: var(--orange); }
.flag-regression { background: var(--red-bg);    color: var(--red); }

/* === YEAR LEVEL VIEW === */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.view-header h2 { font-size: 1.1rem; color: var(--teal-700); }
.yl-selector { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.yl-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--grey-200);
  background: var(--white);
  border-radius: var(--radius);
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.yl-btn:hover { border-color: var(--teal-400); color: var(--teal-600); }
.yl-btn.active { background: var(--teal-700); color: var(--white); border-color: var(--teal-700); }

/* === STUDENT VIEW === */
.student-select-area { max-width: 500px; }
.search-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(0,92,75,0.15);
}
.search-results {
  max-height: 300px;
  overflow-y: auto;
}
.search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-result-item:hover { background: var(--gold-50); }
.search-result-item .yr {
  font-size: 0.75rem;
  color: var(--grey-400);
  background: var(--grey-100);
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
}

.student-detail.hidden { display: none; }
.student-info-card { border-left: 4px solid var(--teal-700); }
.student-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}
.student-info-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--grey-500);
}
.student-info-field span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--grey-900);
}

/* === FOOTER === */
.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--grey-500);
  border-top: 2px solid var(--teal-100);
  margin-top: 2rem;
  background: var(--teal-50);
}

/* === AUTH / LOGIN OVERLAY === */
.login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: linear-gradient(135deg, var(--teal-900), var(--teal-700));
  justify-content: center;
  align-items: center;
}
.login-overlay.active {
  display: flex;
}
.login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.login-logo {
  height: 72px;
  width: auto;
  margin-bottom: 1rem;
}
.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--teal-700);
  margin-bottom: 0.25rem;
}
.login-subtitle {
  font-size: 0.9rem;
  color: var(--grey-500);
  margin-bottom: 1.5rem;
}
.login-google-btn {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.login-setup-msg {
  font-size: 0.85rem;
  color: var(--grey-500);
  line-height: 1.6;
  padding: 1rem;
  background: var(--gold-50);
  border: 1px solid var(--gold-200);
  border-radius: var(--radius);
}
.login-error {
  font-size: 0.85rem;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid #f5c6cb;
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-top: 0.75rem;
}
.auth-hidden {
  display: none !important;
}

/* === USER INFO (header) === */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  margin-right: 1rem;
}
.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
}
.sign-out-btn {
  background: rgba(245,183,49,0.15);
  color: var(--gold-400);
  border: 1px solid rgba(245,183,49,0.3);
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.sign-out-btn:hover {
  background: rgba(245,183,49,0.25);
  color: var(--gold-300);
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; padding: 0.75rem 0; }
  .header-nav { width: 100%; overflow-x: auto; padding-bottom: 0.25rem; }
  .filters-inner { flex-direction: column; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .main-content { padding: 0.75rem; }
  .kpi-row { grid-template-columns: 1fr; }
  .nav-btn { padding: 0.4rem 0.6rem; font-size: 0.8rem; }
}
