/* =========================================================================
   ระบบคาดการณ์ผลการเรียน — สไตล์หลัก (mobile-first)
   วิทยาลัยนานาชาติการท่องเที่ยว ม.ราชภัฏสุราษฎร์ธานี
   ========================================================================= */

:root {
  --brand:        #6f42c1;
  --brand-dark:   #4a2c8f;
  --brand-light:  #ede4ff;
  --brand-grad:   linear-gradient(135deg, #8a5cff 0%, #6f42c1 55%, #4a2c8f 100%);

  --good:   #16a34a;
  --warn:   #d97706;
  --danger: #dc2626;

  --ink:    #1f2330;
  --muted:  #6b7280;
  --line:   #e7e7ef;
  --bg:     #f5f4fb;
  --card:   #ffffff;

  --radius: 18px;
  --shadow: 0 10px 30px rgba(79, 44, 143, 0.10);
  --shadow-sm: 0 4px 14px rgba(31, 35, 48, 0.06);
}

* { box-sizing: border-box; }

body {
  font-family: 'Anuphan', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 92px; /* เผื่อพื้นที่ให้แถบสรุปด้านล่างบนมือถือ */
}

/* ---- Hero ---------------------------------------------------------------- */
.hero {
  background: var(--brand-grad);
  color: #fff;
  border-radius: 0 0 28px 28px;
  padding: 1.6rem 1.1rem 1.4rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px; top: -60px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.12);
  border-radius: 50%;
}
.hero h1 {
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: .2px;
}
.hero .subtitle { opacity: .92; font-size: .92rem; margin-top: .25rem; }
.hero .badge-soft {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-weight: 400;
  border-radius: 999px;
  padding: .25rem .7rem;
  font-size: .78rem;
}
.hero-logo {
  width: 88px; height: 88px;
  border-radius: 22px;
  background: #fff;
  padding: 7px;
  object-fit: contain;
  box-shadow: 0 8px 22px rgba(0,0,0,.20);
}

/* ---- Card / steps -------------------------------------------------------- */
.gcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem;
  margin-bottom: 1rem;
}
.step-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
.step-num {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  display: grid; place-items: center;
  font-size: .95rem;
}
.step-title { font-weight: 600; font-size: 1.05rem; color: var(--brand-dark); margin: 0; }
.step-desc  { color: var(--muted); font-size: .85rem; margin: .1rem 0 0; }

/* ---- Form --------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: .9rem; margin-bottom: .3rem; }
.form-control, .form-select {
  border-radius: 12px;
  border: 1.5px solid var(--line);
  padding: .6rem .8rem;
  font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(111, 66, 193, .15);
}
.input-hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

.info-dot {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-dark);
  font-size: .72rem; font-weight: 700;
  cursor: help;
  margin-left: .25rem;
  vertical-align: middle;
}

/* ---- Course rows -------------------------------------------------------- */
.course-row {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: .8rem .8rem .65rem;
  margin-bottom: .7rem;
  position: relative;
  transition: border-color .15s, background .15s;
}
.course-row.is-active { border-color: var(--brand); background: #fcfbff; }
.course-row .row-no {
  position: absolute; top: -10px; left: 12px;
  background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 600;
  border-radius: 999px; padding: .05rem .55rem;
}
.course-row .btn-remove {
  position: absolute; top: -10px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  border: none; background: #fff; color: var(--danger);
  box-shadow: var(--shadow-sm); line-height: 1;
  font-size: 1rem; display: grid; place-items: center;
}
.grade-chip {
  display: inline-block;
  font-size: .8rem; font-weight: 600;
  border-radius: 8px; padding: .15rem .5rem;
  background: var(--brand-light); color: var(--brand-dark);
}
.grade-chip.no-count { background: #f1f1f4; color: var(--muted); }

.btn-add {
  width: 100%;
  border: 1.5px dashed var(--brand);
  color: var(--brand-dark);
  background: #faf8ff;
  border-radius: 14px;
  padding: .7rem;
  font-weight: 600;
  transition: background .15s;
}
.btn-add:hover { background: var(--brand-light); }

/* ---- Result panel ------------------------------------------------------- */
.result-card {
  background: var(--brand-grad);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.gpa-big {
  font-size: 3rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.gpa-big small { font-size: 1rem; font-weight: 400; opacity: .85; }
.result-card .label { opacity: .9; font-size: .85rem; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-top: .9rem; }
.metric {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px;
  padding: .55rem .7rem;
}
.metric .v { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .k { font-size: .76rem; opacity: .9; }

.status-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  border-radius: 999px; padding: .3rem .8rem;
  font-weight: 600; font-size: .85rem;
  background: #fff;
}
.status-pill.good   { color: var(--good); }
.status-pill.warn   { color: var(--warn); }
.status-pill.danger { color: var(--danger); }

.sticky-side { position: sticky; top: 14px; }

/* ---- Compare / percentile ---------------------------------------------- */
.compare-box { margin-top: .9rem; }
.gauge {
  position: relative;
  height: 12px; border-radius: 999px;
  background: linear-gradient(90deg, #fca5a5, #fde68a, #86efac);
  margin: 1.6rem 0 .6rem;
}
.gauge .marker {
  position: absolute; top: 50%;
  width: 4px; height: 26px;
  background: var(--ink);
  border-radius: 4px;
  transform: translate(-50%, -50%);
  transition: left .5s cubic-bezier(.2,.8,.2,1);
}
.gauge .marker::after {
  content: attr(data-label);
  position: absolute; bottom: 130%; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--ink); color: #fff;
  font-size: .72rem; font-weight: 600;
  padding: .1rem .45rem; border-radius: 6px;
}
.gauge-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }

/* ---- Sticky bottom bar (มือถือ) ---------------------------------------- */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(31,35,48,.08);
  padding: .6rem .9rem;
  display: flex; align-items: center; gap: .8rem;
}
.bottom-bar .bb-gpa { font-size: 1.5rem; font-weight: 700; color: var(--brand-dark); line-height: 1; font-variant-numeric: tabular-nums; }
.bottom-bar .bb-k { font-size: .72rem; color: var(--muted); }
.bottom-bar .btn { border-radius: 12px; }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline-brand { border: 1.5px solid var(--brand); color: var(--brand-dark); font-weight: 600; }
.btn-outline-brand:hover { background: var(--brand-light); }

/* ---- Reference image collapse ------------------------------------------ */
.ref-toggle { color: var(--brand-dark); font-weight: 500; cursor: pointer; font-size: .88rem; text-decoration: none; }
.ref-img { border-radius: 12px; border: 1px solid var(--line); }

/* ---- Toast ------------------------------------------------------------- */
.toast-container { z-index: 1090; }

/* ---- Desktop tweaks ----------------------------------------------------- */
@media (min-width: 992px) {
  body { padding-bottom: 1rem; }
  .hero h1 { font-size: 1.8rem; }
}

/* ---- Small count-up animation ------------------------------------------ */
.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.96); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
