/* ===================================================================
   หน้า "ตารางเรียน" (schedule.html) — ตัวกรองดรอปดาวน์ + การ์ดคอร์สสีตามวิชา
   =================================================================== */
.sc-root {
  --navy: #0b1e3f;
  --muted: #64748b;
  --line: #e2e8f0;
  padding-bottom: 40px;
}

/* สีวิชา (เหมือนปกคอร์ส) */
.sc-s-math, .sc-tone-math { --t1: #e11d48; --t2: #fb7185; --tink: #be123c; }
.sc-s-sci, .sc-tone-sky { --t1: #0284c7; --t2: #38bdf8; --tink: #0369a1; }
.sc-s-eng, .sc-tone-eng { --t1: #059669; --t2: #34d399; --tink: #047857; }
.sc-s-phys, .sc-tone-phys { --t1: #7c3aed; --t2: #a78bfa; --tink: #6d28d9; }
.sc-s-chem, .sc-tone-chem { --t1: #1d4ed8; --t2: #60a5fa; --tink: #1d4ed8; }
.sc-s-royal, .sc-tone-royal { --t1: #1d3fae; --t2: #3b6cf0; --tink: #1d3fae; }
.sc-tone-private { --t1: #9f1239; --t2: #4338ca; --tink: #9f1239; }

/* สีประจำวัน */
.sc-sess { --d: #2a54d6; }
.sc-d0 { --d: #eab308; }
.sc-d1 { --d: #ec4899; }
.sc-d2 { --d: #16a34a; }
.sc-d3 { --d: #f97316; }
.sc-d4 { --d: #2563eb; }
.sc-d5 { --d: #9333ea; }
.sc-d6 { --d: #dc2626; }
.sc-dx { --d: #2a54d6; }

/* ---------- ตัวกรอง ---------- */
.sf {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(11, 30, 63, 0.08);
}

.sf-select { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sf-select span { color: var(--navy); font-weight: 800; font-size: 0.88rem; }
.sf-select span i { color: #e11d48; margin-right: 4px; }

.sf-select select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 12px 40px 12px 14px;
  border-radius: 14px;
  border: 1.5px solid #dbe3f0;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%230b1e3f' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--navy);
  font: 700 0.98rem/1.2 inherit;
  font-family: inherit;
  cursor: pointer;
}

.sf-select select:focus { outline: none; border-color: #2a54d6; box-shadow: 0 0 0 4px rgba(42, 84, 214, 0.12); }
.sf-select select:disabled { opacity: 0.75; cursor: default; }

.sf-share {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid #dbe3f0;
  background: #ffffff;
  color: var(--navy);
  font: 700 0.88rem/1.2 inherit;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.sf-share i { color: #2a54d6; }

/* ---------- การ์ดคอร์ส ---------- */
.sc-card { position: relative; border-radius: 28px; overflow: hidden; background: #ffffff; box-shadow: 0 20px 44px rgba(11, 30, 63, 0.1); }

.sc-head {
  position: relative;
  padding: 22px 28px 20px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--t1), var(--t2));
  overflow: hidden;
}

.sc-head::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -80px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 34px rgba(255, 255, 255, 0.07);
}

.sc-head-icons { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); display: flex; gap: 8px; z-index: 1; }
.sc-head-icons i { width: 42px; height: 42px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.2); font-size: 1.1rem; }
.sc-level { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; opacity: 0.92; }
.sc-head h2 { margin: 2px 0 2px; font-size: 1.8rem; font-weight: 800; line-height: 1.2; color: #ffffff; padding-right: 160px; }
.sc-head p { margin: 0; font-size: 0.9rem; opacity: 0.92; }

.sc-body { display: grid; grid-template-columns: 320px 1fr; gap: 26px; padding: 22px 28px 26px; }

.sc-cover { position: relative; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: #eef2f9; box-shadow: 0 10px 24px rgba(11, 30, 63, 0.12); }
.sc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.sc-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.sc-btn-detail, .sc-btn-apply {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 999px;
  font: 700 0.9rem/1.2 inherit;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.sc-btn-detail { border: 1.5px solid #dbe3f0; color: var(--navy); background: #ffffff; }
.sc-btn-detail:hover { border-color: var(--t1); color: var(--t1); }
.sc-btn-apply { border: none; color: #ffffff; background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 10px 20px rgba(225, 29, 72, 0.3); }

/* ---------- วันเรียน / คาบเรียน ---------- */
.sc-sessions { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sc-sess { padding: 14px 16px 6px; border-radius: 20px; background: #f8fafc; }
.sc-sess-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }

.sc-day { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 0.95rem; background: var(--d); color: #ffffff; box-shadow: 0 6px 14px color-mix(in srgb, var(--d) 35%, transparent); }
.sc-group { font-weight: 700; font-size: 0.82rem; color: var(--navy); background: #ffffff; padding: 4px 11px; border-radius: 999px; }
.sc-note-text { margin-left: auto; font-size: 0.8rem; color: var(--muted); }

/* เส้นเวลา: 1 จุด ต่อ 1 คาบ */
.sc-rows { list-style: none; margin: 0; padding: 0; }
.sc-row { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px 0 8px 26px; }
.sc-row::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: #e2e8f0; }
.sc-row:first-child::before { top: 22px; }
.sc-row:last-child::before { bottom: calc(100% - 22px); }
.sc-row:only-child::before { display: none; }
.sc-row::after { content: ''; position: absolute; left: 0; top: 17px; width: 14px; height: 14px; border-radius: 50%; background: #ffffff; border: 3px solid var(--d); box-sizing: border-box; }

/* 1 บรรทัด = เวลา | วิชา | ติวเตอร์ | ห้อง */
.sc-item {
  display: grid;
  /* ห้องกว้างคงที่ → คอลัมน์ติวเตอร์ตรงกันทุกบรรทัด */
  grid-template-columns: 116px minmax(0, 1.25fr) minmax(0, 1fr) 124px;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #ffffff;
  border-left: 4px solid var(--t1);
  box-shadow: 0 4px 10px rgba(11, 30, 63, 0.05);
}

.sc-time { color: var(--navy); font-weight: 800; font-size: 0.98rem; white-space: nowrap; }
.sc-subj { font-weight: 800; color: var(--tink); }
.sc-tutor { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.92rem; color: #1e293b; }
.sc-emoji { font-size: 1.05em; line-height: 1; }
.sc-room { justify-self: end; padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; color: #ffffff; background: linear-gradient(135deg, var(--t1), var(--t2)); }

.sc-alt { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; font-size: 0.78rem; font-weight: 800; color: #b45309; }

/* ---------- ตารางสรุปรวม (ทุกตารางกว้างเต็มการ์ด ขนาดเท่ากัน) ---------- */
.sc-body.is-summary { grid-template-columns: 1fr; }
.sc-summary .sc-sessions { gap: 18px; }
.sc-summary-table { padding: 16px 18px 8px; border-top: 4px solid var(--d); }
.sc-group-dark { background: var(--navy); color: #ffffff; font-size: 0.88rem; padding: 5px 13px; }
.sc-count { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.sc-dayline { list-style: none; padding: 8px 0 2px; }
.sc-dayline span { display: inline-block; padding: 3px 12px; border-radius: 999px; background: color-mix(in srgb, var(--d) 14%, #ffffff); color: var(--d); font-weight: 800; font-size: 0.85rem; }
.sc-summary-table .sc-dayline + .sc-row::before { top: 22px; }

.sc-none { color: var(--muted); font-size: 0.92rem; padding: 6px 0; }
.sc-free { margin: 0; padding: 22px; border-radius: 20px; background: #f8fafc; }

/* ===================================================================
   แท็บเล็ต / มือถือ
   =================================================================== */
@media (max-width: 980px) {
  .sc-body { grid-template-columns: 1fr; }
  .sc-side { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: center; }
  .sc-actions { margin-top: 0; flex-direction: column; }
  .sf { grid-template-columns: 1fr 1fr; }
  .sf-share { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .sf { grid-template-columns: 1fr; padding: 12px; border-radius: 18px; }
  .sc-card { border-radius: 22px; }
  .sc-head { padding: 18px 18px 16px; }
  .sc-head h2 { font-size: 1.4rem; padding-right: 0; }
  .sc-head-icons { top: 16px; right: 16px; transform: none; }
  .sc-head-icons i { width: 32px; height: 32px; font-size: 0.85rem; }
  .sc-head-icons i:nth-child(n + 4) { display: none; }
  .sc-level { display: block; padding-right: 120px; }
  .sc-body { padding: 16px 14px 18px; gap: 18px; }
  .sc-side { grid-template-columns: 1fr; gap: 14px; }
  .sc-actions { flex-direction: row; }
  .sc-sess { padding: 12px 12px 4px; }
  .sc-note-text { margin-left: 0; width: 100%; }

  /* มือถือ: เวลา + ห้อง บรรทัดแรก / วิชา / ติวเตอร์ */
  .sc-item { grid-template-columns: 1fr auto; gap: 3px 8px; padding: 9px 11px; }
  .sc-time { grid-column: 1; grid-row: 1; }
  .sc-room { grid-column: 2; grid-row: 1; }
  .sc-subj { grid-column: 1 / -1; }
  .sc-tutor { grid-column: 1 / -1; font-size: 0.88rem; }
}
