/* ============================================================
   Progress New — Professional UI Theme
   ปรับปรุงโดย Claude · ไม่กระทบ PHP logic ใดๆ
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&family=IBM+Plex+Sans+Thai:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Palette */
  --bg:          #f0f4f8;
  --bg2:         #e8edf5;
  --card:        #ffffff;
  --text:        #0f172a;
  --text2:       #334155;
  --muted:       #64748b;
  --line:        #dde3ed;
  --line2:       #e8edf5;

  /* Brand */
  --blue:        #1d4ed8;
  --blue-mid:    #2563eb;
  --blue-light:  #eff6ff;
  --blue-dark:   #0f2f78;
  --navy:        #0a1f5c;

  /* Semantic */
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --amber:       #d97706;
  --amber-bg:    #fffbeb;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --purple:      #6d28d9;
  --purple-bg:   #faf5ff;
  --teal:        #0f766e;
  --teal-bg:     #f0fdfa;
  --pink:        #db2777;
  --pink-bg:     #fdf2f8;

  /* Elevation */
  --shadow-sm:   0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.05);
  --shadow:      0 4px 16px rgba(15,23,42,.09), 0 1px 4px rgba(15,23,42,.06);
  --shadow-lg:   0 10px 32px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.07);

  /* Shape */
  --radius:      18px;
  --radius-sm:   10px;
  --radius-xs:   7px;

  /* Topbar gradient */
  --topbar-start: #0a1f5c;
  --topbar-end:   #1d4ed8;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }

/* ── Topbar ──────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--topbar-start) 0%, var(--topbar-end) 100%);
  color: #fff;
  padding: 0 22px;
  box-shadow: 0 2px 20px rgba(10,31,92,.30);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1200px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  object-fit: contain;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.20);
}
.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.2px;
}
.brand-sub {
  font-size: 12px;
  opacity: .75;
  font-weight: 500;
  margin-top: 1px;
}
.user-pill {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.user-pill a { color: #fff; text-decoration: underline; }

/* ── Layout ──────────────────────────────────────── */
.wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .2s;
}
.card:hover {
  box-shadow: var(--shadow-lg);
}
.card-pad { padding: 20px 22px; }

/* ── Grid ────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

/* ── Hero bar ────────────────────────────────────── */
.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.stat-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  min-width: 80px;
  text-align: center;
  transition: box-shadow .15s;
}
.stat:hover { box-shadow: var(--shadow); }
.stat b {
  font-size: 24px;
  font-weight: 900;
  color: var(--blue);
  display: block;
  line-height: 1.1;
}
.stat span { font-size: 12px; color: var(--muted); }

/* ── Toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.3px;
}

/* ── Search input ────────────────────────────────── */
.search {
  width: 100%;
  max-width: 400px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.search:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.search::placeholder { color: var(--muted); }

/* ── Subject card elements ───────────────────────── */
.subject-code {
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.subject-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  margin: 5px 0 4px;
  color: var(--text);
}
.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

/* ── Chips ───────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-light);
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip.ok  { background: var(--green-bg);  color: var(--green); }
.chip.warn{ background: var(--amber-bg);  color: var(--amber); }

/* ── Group list ─────────────────────────────────── */
.group-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.group-link {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  transition: background .15s, border-color .15s;
}
.group-link:hover { background: var(--blue-light); border-color: var(--blue-mid); color: var(--blue); }

/* ── Buttons ────────────────────────────────────── */
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--blue-mid), var(--blue-dark));
  color: #fff;
  box-shadow: 0 3px 10px rgba(29,78,216,.30);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d5ae8, var(--blue-mid));
  box-shadow: 0 5px 16px rgba(29,78,216,.38);
  transform: translateY(-1px);
}

.btn-soft {
  background: var(--blue-light);
  color: var(--blue-dark);
}
.btn-soft:hover { background: #dbeafe; }

.btn-green  { background: var(--green-bg); color: var(--green); }
.btn-green:hover { background: #dcfce7; }

.btn-amber  { background: var(--amber-bg); color: var(--amber); }
.btn-amber:hover { background: #fde68a; color: #92400e; }

.btn-gray   { background: var(--bg); color: var(--text2); border: 1px solid var(--line); }
.btn-gray:hover { background: var(--line2); }

/* ── Login page ─────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, #dce8fb 0%, #f0f4ff 40%, #e8f5e9 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .4s ease both;
}
@keyframes fadeUp {
  from { opacity:0; transform:translateY(18px); }
  to   { opacity:1; transform:translateY(0); }
}
.login-title {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--navy), var(--blue-mid));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Form controls ───────────────────────────────── */
.form-group { margin: 14px 0; }
.form-group label { font-size: 13px; font-weight: 700; color: var(--text2); display: block; margin-bottom: 5px; }
.form-control {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Alert ───────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--red-bg);
  color: var(--red);
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid #fecaca;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert::before { content: '⚠️'; }

/* ── Frame page (legacy iframe) ──────────────────── */
.frame-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.frame-top {
  background: linear-gradient(135deg, var(--navy), var(--blue-mid));
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(10,31,92,.25);
}
.frame-title { font-weight: 800; font-size: 15px; }
.frame-actions { display: flex; gap: 8px; }
.frame-actions a {
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.frame-actions a:hover { background: rgba(255,255,255,.24); }
.legacy-frame { width: 100%; flex: 1; border: 0; background: #fff; }

/* ── course.php — Modern action cards ───────────── */
.course-page-wrap { margin-top: 16px; }
.course-group-card { }

.course-modern-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line2);
  margin-bottom: 2px;
}
.course-modern-icon {
  width: 44px; height: 44px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue-light), #dbeafe);
  color: var(--blue);
  font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,.12);
  flex-shrink: 0;
}
.course-modern-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.course-modern-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.course-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 16px;
}

/* Action card base */
.course-action-card {
  position: relative;
  min-height: 90px;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 14px;
  text-decoration: none !important;
  border-radius: 14px !important;
  padding: 16px 44px 16px 16px !important;
  border: 1px solid rgba(148,163,184,.18) !important;
  box-shadow: 0 2px 8px rgba(15,23,42,.05) !important;
  transition: transform .15s ease, box-shadow .15s ease;
  overflow: hidden;
}
.course-action-card::before {
  content:'';
  position:absolute;
  inset:0;
  opacity:0;
  background: rgba(255,255,255,.35);
  transition: opacity .15s;
  border-radius:14px;
}
.course-action-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(15,23,42,.13) !important;
}
.course-action-card:hover::before { opacity: 1; }
.course-action-card:active { transform: scale(.98); }

.course-action-card .ca-icon {
  flex: 0 0 50px;
  width: 50px; height: 50px;
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 6px 16px rgba(15,23,42,.18);
  flex-shrink: 0;
}
.course-action-card .ca-text { min-width: 0; flex: 1; }
.course-action-card .ca-title {
  display: block;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 3px;
  line-height: 1.2;
}
.course-action-card .ca-desc {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
  opacity: .75;
}
.course-action-card .ca-arrow {
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  font-weight: 300;
  opacity: .55;
}

/* Color variants */
.ca-green  { background: linear-gradient(135deg, #f0fdf4, #dcfce7) !important; color: #15803d !important; }
.ca-green  .ca-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.ca-green  .ca-arrow { color: #16a34a; }

.ca-blue   { background: linear-gradient(135deg, #eff6ff, #dbeafe) !important; color: #1d4ed8 !important; }
.ca-blue   .ca-icon { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.ca-blue   .ca-arrow { color: #2563eb; }

.ca-amber  { background: linear-gradient(135deg, #fffbeb, #fef3c7) !important; color: #d97706 !important; }
.ca-amber  .ca-icon { background: linear-gradient(135deg, #fbbf24, #d97706); }
.ca-amber  .ca-arrow { color: #d97706; }

.ca-purple { background: linear-gradient(135deg, #faf5ff, #ede9fe) !important; color: #6d28d9 !important; }
.ca-purple .ca-icon { background: linear-gradient(135deg, #a78bfa, #6d28d9); }
.ca-purple .ca-arrow { color: #6d28d9; }

.ca-teal   { background: linear-gradient(135deg, #f0fdfa, #ccfbf1) !important; color: #0f766e !important; }
.ca-teal   .ca-icon { background: linear-gradient(135deg, #2dd4bf, #0f766e); }
.ca-teal   .ca-arrow { color: #0f766e; }

.ca-pink   { background: linear-gradient(135deg, #fdf2f8, #fce7f3) !important; color: #db2777 !important; }
.ca-pink   .ca-icon { background: linear-gradient(135deg, #f472b6, #db2777); }
.ca-pink   .ca-arrow { color: #db2777; }

.ca-slate  { background: linear-gradient(135deg, #f8fafc, #e2e8f0) !important; color: #475569 !important; }
.ca-slate  .ca-icon { background: linear-gradient(135deg, #94a3b8, #475569); }
.ca-slate  .ca-arrow { color: #475569; }

/* ── Subject card hover lift ─────────────────────── */
.subject-card {
  transition: transform .18s ease, box-shadow .18s ease;
}
.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg) !important;
}

/* ── Fade-in animation for cards ─────────────────── */
@keyframes cardIn {
  from { opacity:0; transform:translateY(12px); }
  to   { opacity:1; transform:translateY(0); }
}
.card {
  animation: cardIn .3s ease both;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 760px) {
  .course-menu-grid { grid-template-columns: 1fr; }
  .course-action-card {
    min-height: 78px;
    padding: 13px 38px 13px 13px !important;
  }
  .course-action-card .ca-icon { width: 44px; height: 44px; flex-basis: 44px; font-size: 22px; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .topbar-inner { height: 56px; }
  .brand-title { font-size: 15px; }
  .user-pill { font-size: 12px; padding: 5px 11px; }
  .hero { padding: 16px; gap: 14px; }
  .stat b { font-size: 20px; }
  .page-title { font-size: 19px; }
  .actions { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .wrap { padding: 0 12px; margin: 16px auto; }
  .card-pad { padding: 16px; }
}
