/* ─── CSS Variables (Claymorphism 暖橘風 — 與 pet-grooming STYLE-GUIDE 對齊) ─── */
:root {
  --c-bg:        #FFF8F0;
  --c-primary:   #FF6B47;
  --c-primary-d: #E8502F;
  --c-secondary: #FFB84D;
  --c-green:     #4DC88A;
  --c-pink:      #FF7BAC;
  --c-purple:    #A78BFA;
  --c-text:      #2A1800;
  --c-mid:       #7C5B3F;
  --c-light:     #B89B80;
  --c-white:     #FFFFFF;
  --radius-card: 28px;
  --radius-xl:   40px;
  --clay-sm: 6px 6px 18px rgba(0,0,0,.08), -3px -3px 10px rgba(255,255,255,.85),
             inset 0 1px 2px rgba(255,255,255,.9);
  --clay:    8px 8px 24px rgba(0,0,0,.10), -5px -5px 14px rgba(255,255,255,.90),
             inset 0 1px 3px rgba(255,255,255,.9);
  --clay-lg: 12px 16px 36px rgba(0,0,0,.13), -6px -6px 18px rgba(255,255,255,.95),
             inset 0 2px 4px rgba(255,255,255,.95);
  --trans:   all .3s cubic-bezier(.34,1.56,.64,1);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Nunito', "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img, video { display: block; max-width: 100%; }
ul { list-style: none; }
button { font-family: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ─── Nav ─── */
nav.topbar {
  position: sticky; top: 0; z-index: 100;
  padding: 14px 0;
  background: rgba(255,248,240,.88);
  backdrop-filter: blur(20px);
  border-bottom: 1.5px solid rgba(255,184,77,.18);
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.nav-logo {
  display: flex; align-items: center; gap: 10px; font-weight: 900;
  font-size: 1.3rem; color: var(--c-primary);
}
.nav-logo .logo-icon {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, var(--c-primary), #FF8C42);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; box-shadow: 0 6px 18px rgba(255,107,71,.35);
  color: #fff;
}
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
  padding: 8px 18px; border-radius: 50px; font-weight: 700; font-size: .95rem;
  color: var(--c-mid); transition: var(--trans); cursor: pointer;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,107,71,.1); color: var(--c-primary);
}
.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 16px; border-radius: 50px;
  background: var(--c-white); box-shadow: var(--clay-sm);
  font-weight: 700; font-size: .9rem; color: var(--c-mid);
}
.nav-user .role-badge {
  display: inline-block; padding: 3px 10px; border-radius: 50px;
  font-size: .72rem; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--c-secondary), #FF8C42);
  color: #fff;
}
.nav-user .role-badge.admin { background: linear-gradient(135deg, var(--c-primary), #FF8C42); }
.nav-user .role-badge.manager { background: linear-gradient(135deg, var(--c-purple), #8B6FE8); }
.nav-user .logout-btn {
  border: none; padding: 8px 16px; border-radius: 50px;
  background: rgba(255,107,71,.1); color: var(--c-primary); font-weight: 800;
  cursor: pointer; transition: var(--trans);
}
.nav-user .logout-btn:hover { background: var(--c-primary); color: #fff; }

/* ─── Page ─── */
main.page { padding: 40px 0 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 40px; flex-wrap: wrap; }
.page-head h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem); font-weight: 900;
  line-height: 1.2; color: var(--c-text);
}
.page-head .subtitle { font-size: 1.05rem; color: var(--c-mid); font-weight: 600; margin-top: 8px; }
.badge {
  display: inline-block; padding: 6px 18px; border-radius: 50px;
  font-weight: 800; font-size: .82rem; letter-spacing: .5px;
  background: linear-gradient(135deg, #FFECD2, #FCB69F);
  color: var(--c-primary-d); margin-bottom: 16px;
}

.breadcrumb { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--c-mid); font-weight: 700; font-size: .92rem; margin-bottom: 24px; }
.breadcrumb a { cursor: pointer; padding: 4px 14px; border-radius: 50px; transition: var(--trans); }
.breadcrumb a:hover { background: rgba(255,107,71,.1); color: var(--c-primary); }
.breadcrumb .sep { color: var(--c-light); }
.breadcrumb .current { color: var(--c-text); }

/* ─── Cards Grid ─── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
.card {
  padding: 28px 24px; background: var(--c-white);
  border-radius: var(--radius-card);
  box-shadow: var(--clay);
  border: 1.5px solid rgba(255,255,255,.7);
  transition: var(--trans); cursor: pointer; text-align: center;
  display: flex; flex-direction: column; gap: 10px;
}
.card:hover { transform: translateY(-8px) scale(1.02); box-shadow: var(--clay-lg); }
.card .icon-wrap {
  width: 80px; height: 80px; border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; margin: 0 auto 8px;
  transition: var(--trans);
}
.card:hover .icon-wrap { transform: scale(1.12) rotate(-5deg); }
.si-orange { background: linear-gradient(135deg, #FFE4DA, #FFCFB8); }
.si-yellow { background: linear-gradient(135deg, #FFF3D6, #FFE4A8); }
.si-green  { background: linear-gradient(135deg, #D4F5E4, #A8EAC8); }
.si-pink   { background: linear-gradient(135deg, #FFE0EE, #FFB8D4); }
.si-purple { background: linear-gradient(135deg, #E4E0FF, #C8C0FF); }
.si-blue   { background: linear-gradient(135deg, #D4F0FF, #A8DCFF); }

.card .title { font-size: 1.15rem; font-weight: 800; color: var(--c-text); }
.card .desc { font-size: .9rem; color: var(--c-mid); font-weight: 600; line-height: 1.6; min-height: 2.4em; }
.card .meta {
  display: inline-flex; gap: 8px; align-self: center;
  padding: 5px 14px; border-radius: 50px;
  font-size: .8rem; font-weight: 800;
  background: rgba(255,107,71,.1); color: var(--c-primary);
}
.card .meta + .meta { background: rgba(77,200,138,.12); color: #1A8A50; }

.empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--c-light); font-weight: 700;
}
.empty-state .emoji { font-size: 4rem; margin-bottom: 16px; opacity: .6; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: 50px;
  font-weight: 800; font-size: .95rem; cursor: pointer; border: none;
  font-family: inherit; transition: var(--trans);
}
.btn-primary {
  background: linear-gradient(135deg, var(--c-primary), #FF8C42); color: #fff;
  box-shadow: 0 8px 24px rgba(255,107,71,.40);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(255,107,71,.50); }
.btn-outline {
  background: rgba(255,255,255,.8); color: var(--c-primary);
  border: 2px solid var(--c-primary); box-shadow: var(--clay-sm);
}
.btn-outline:hover { background: var(--c-primary); color: #fff; }
.btn-ghost {
  background: rgba(255,107,71,.08); color: var(--c-primary); border: 2px solid transparent;
}
.btn-ghost:hover { background: rgba(255,107,71,.15); }
.btn-danger {
  background: rgba(232,80,47,.08); color: var(--c-primary-d); border: 2px solid rgba(232,80,47,.2);
}
.btn-danger:hover { background: var(--c-primary-d); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: var(--clay-sm) !important; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: .88rem; font-weight: 800; color: var(--c-mid); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; border-radius: 16px;
  border: 2px solid rgba(255,107,71,.15);
  background: rgba(255,248,240,.6);
  font-family: inherit; font-size: 1rem; font-weight: 600;
  color: var(--c-text); transition: var(--trans); outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--c-primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(255,107,71,.1);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-help { font-size: .8rem; color: var(--c-light); font-weight: 600; margin-top: 2px; }
.form-error {
  background: rgba(232,80,47,.1); color: var(--c-primary-d); border: 1.5px solid rgba(232,80,47,.25);
  padding: 12px 16px; border-radius: 14px; font-weight: 700; font-size: .9rem;
}
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(255,248,240,.6); border: 2px solid rgba(255,107,71,.12);
  font-weight: 700; cursor: pointer; transition: var(--trans);
}
.checkbox-item:hover { border-color: rgba(255,107,71,.4); }
.checkbox-item input[type=checkbox] {
  width: 18px; height: 18px; accent-color: var(--c-primary);
  cursor: pointer;
}

/* ─── Login page ─── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #FFF0E6 0%, #FFF8F0 60%, #FFE6CC 100%);
  padding: 24px;
  position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ''; position: absolute; border-radius: 50%; opacity: .35;
  filter: blur(40px);
}
.login-wrap::before { width: 360px; height: 360px; background: #FFB84D; top: -80px; left: -80px; }
.login-wrap::after { width: 420px; height: 420px; background: #FF6B47; bottom: -120px; right: -120px; }
.login-card {
  width: 100%; max-width: 420px;
  padding: 44px 38px;
  background: var(--c-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--clay-lg);
  border: 2px solid rgba(255,255,255,.8);
  position: relative; z-index: 1;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 28px;
}
.login-logo .icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, var(--c-primary), #FF8C42);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff;
  box-shadow: 0 10px 28px rgba(255,107,71,.4);
}
.login-logo h1 { font-size: 1.4rem; font-weight: 900; color: var(--c-text); margin-top: 4px; }
.login-logo .sub { font-size: .9rem; color: var(--c-mid); font-weight: 700; }
.login-card .btn { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }

/* ─── Player ─── */
.player-layout {
  display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start;
}
.player-main {
  background: var(--c-white);
  border-radius: var(--radius-card);
  box-shadow: var(--clay);
  border: 1.5px solid rgba(255,255,255,.7);
  overflow: hidden;
}
.player-main video {
  width: 100%; aspect-ratio: 16/9; background: #000;
  display: block;
}
.player-info { padding: 24px 26px; }
.player-info h2 { font-size: 1.4rem; font-weight: 900; margin-bottom: 6px; color: var(--c-text); }
.player-info .meta { color: var(--c-mid); font-weight: 700; font-size: .9rem; }
.player-info .desc { margin-top: 14px; color: var(--c-mid); font-weight: 600; line-height: 1.7; }

.playlist {
  background: var(--c-white);
  border-radius: var(--radius-card);
  box-shadow: var(--clay);
  border: 1.5px solid rgba(255,255,255,.7);
  padding: 18px;
  max-height: 80vh; overflow-y: auto;
}
.playlist h3 {
  font-size: 1rem; font-weight: 900; color: var(--c-text);
  padding: 4px 8px 12px; border-bottom: 1.5px dashed rgba(255,107,71,.18); margin-bottom: 10px;
}
.playlist-item {
  display: flex; gap: 12px; padding: 12px;
  border-radius: 16px; cursor: pointer; transition: var(--trans);
  align-items: center;
}
.playlist-item:hover { background: rgba(255,107,71,.06); }
.playlist-item.active {
  background: linear-gradient(135deg, rgba(255,107,71,.12), rgba(255,184,77,.08));
  box-shadow: var(--clay-sm);
}
.playlist-item .num {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background: rgba(255,107,71,.12); color: var(--c-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .9rem;
}
.playlist-item.active .num {
  background: linear-gradient(135deg, var(--c-primary), #FF8C42); color: #fff;
}
.playlist-item.done .num { background: rgba(77,200,138,.18); color: #1A8A50; }
.playlist-item .meta-line { font-size: .78rem; color: var(--c-light); font-weight: 700; margin-top: 2px; display: flex; gap: 8px; align-items: center; }
.playlist-item .title-line { font-size: .92rem; font-weight: 800; color: var(--c-text); line-height: 1.35; }
.playlist-item .progress-bar {
  height: 4px; border-radius: 99px; background: rgba(255,107,71,.12); margin-top: 6px; overflow: hidden;
}
.playlist-item .progress-bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--c-primary), #FF8C42);
}

/* ─── Admin ─── */
.admin-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--c-white); padding: 10px;
  border-radius: 50px; box-shadow: var(--clay-sm);
  margin-bottom: 28px; width: fit-content;
}
.admin-tab {
  padding: 10px 22px; border-radius: 50px; cursor: pointer;
  font-weight: 800; font-size: .92rem; color: var(--c-mid);
  transition: var(--trans);
}
.admin-tab:hover { background: rgba(255,107,71,.08); color: var(--c-primary); }
.admin-tab.active {
  background: linear-gradient(135deg, var(--c-primary), #FF8C42); color: #fff;
  box-shadow: 0 6px 18px rgba(255,107,71,.35);
}
.admin-section { display: none; }
.admin-section.active { display: block; animation: fadeSlide .35s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.panel {
  background: var(--c-white);
  border-radius: var(--radius-card);
  box-shadow: var(--clay);
  border: 1.5px solid rgba(255,255,255,.7);
  padding: 26px;
  margin-bottom: 20px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 1.2rem; font-weight: 900; color: var(--c-text); }
.panel-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead th {
  text-align: left; font-size: .82rem; font-weight: 800;
  color: var(--c-mid); padding: 10px 14px; border-bottom: 2px solid rgba(255,107,71,.12);
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.tbl tbody td {
  padding: 14px; font-size: .92rem; font-weight: 600; color: var(--c-text);
  border-bottom: 1px dashed rgba(124,91,63,.12);
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: rgba(255,107,71,.04); }
.tbl .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tbl .pill {
  display: inline-block; padding: 3px 12px; border-radius: 50px;
  font-size: .76rem; font-weight: 800;
}
.pill-admin { background: rgba(255,107,71,.12); color: var(--c-primary); }
.pill-manager { background: rgba(167,139,250,.18); color: #6645D6; }
.pill-user { background: rgba(77,200,138,.15); color: #1A8A50; }
.pill-off { background: rgba(180,160,140,.18); color: var(--c-light); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  padding: 22px 24px;
  background: var(--c-white);
  border-radius: 22px;
  box-shadow: var(--clay-sm);
  border: 1.5px solid rgba(255,255,255,.7);
}
.stat-card .lbl { font-size: .8rem; font-weight: 800; color: var(--c-mid); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .val { font-size: 2rem; font-weight: 900; color: var(--c-primary); margin-top: 4px; }
.stat-card .sub { font-size: .8rem; color: var(--c-light); font-weight: 700; margin-top: 4px; }

/* ─── Modal ─── */
.modal-mask {
  position: fixed; inset: 0; background: rgba(42,24,0,.45);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-mask.show { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--c-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--clay-lg);
  border: 2px solid rgba(255,255,255,.8);
  padding: 32px 30px;
  width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h3 { font-size: 1.2rem; font-weight: 900; color: var(--c-text); }
.modal .close-btn {
  background: rgba(255,107,71,.08); border: none;
  width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer; font-size: 1.2rem; color: var(--c-primary); font-weight: 900;
}
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  padding: 14px 24px; border-radius: 50px;
  background: var(--c-text); color: #fff; font-weight: 700; font-size: .95rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
  opacity: 0; transition: all .3s; z-index: 300;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--c-primary-d); }
.toast.success { background: var(--c-green); }

/* ─── Notes panel (player 下方) ─── */
.notes-panel {
  margin-top: 24px;
  background: var(--c-white);
  border-radius: var(--radius-card);
  box-shadow: var(--clay);
  border: 1.5px solid rgba(255,255,255,.7);
  padding: 24px 26px;
}
.notes-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 14px;
}
.notes-head h3 { font-size: 1.1rem; font-weight: 900; color: var(--c-text); }
.notes-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notes-status {
  font-size: .82rem; font-weight: 800; padding: 4px 14px; border-radius: 50px;
  background: rgba(180,160,140,.18); color: var(--c-light);
}
.notes-status.dirty { background: rgba(255,184,77,.2); color: #B86F00; }
.notes-status.saved { background: rgba(77,200,138,.16); color: #1A8A50; }
.notes-status.saving { background: rgba(255,107,71,.12); color: var(--c-primary); }
.notes-area {
  width: 100%; min-height: 200px;
  padding: 16px 18px; border-radius: 16px;
  border: 2px solid rgba(255,107,71,.15);
  background: rgba(255,248,240,.6);
  font-family: inherit; font-size: 1rem; font-weight: 600; line-height: 1.7;
  color: var(--c-text); resize: vertical; outline: none; transition: var(--trans);
}
.notes-area:focus {
  border-color: var(--c-primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(255,107,71,.1);
}
.notes-help {
  margin-top: 8px; font-size: .8rem; color: var(--c-light); font-weight: 700;
  display: flex; gap: 14px; flex-wrap: wrap;
}

/* ─── 講師資訊卡 ─── */
.lecturer-card {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 22px;
  background: linear-gradient(135deg, rgba(255,236,210,.7), rgba(255,182,153,.4));
  border: 1.5px solid rgba(255,107,71,.18);
  border-radius: 22px;
  margin-top: 16px;
}
.lecturer-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), #FF8C42);
  color: #fff; font-size: 1.6rem; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(255,107,71,.35);
  flex-shrink: 0;
}
.lecturer-text .name { font-size: 1.05rem; font-weight: 900; color: var(--c-text); }
.lecturer-text .meta { font-size: .88rem; font-weight: 700; color: var(--c-mid); margin-top: 2px; }

/* ─── Upload progress ─── */
.upload-progress {
  margin-top: 12px; display: none;
}
.upload-progress.show { display: block; }
.upload-progress .bar {
  height: 12px; border-radius: 99px; background: rgba(255,107,71,.12); overflow: hidden;
}
.upload-progress .bar > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--c-primary), #FF8C42);
  transition: width .2s;
}
.upload-progress .pct {
  font-size: .85rem; color: var(--c-mid); font-weight: 800; margin-top: 6px;
}

/* ─── Loading ─── */
.loading {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,107,71,.2); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RWD ─── */
@media (max-width: 1024px) {
  .player-layout { grid-template-columns: 1fr; }
  .playlist { max-height: 480px; }
}
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-user { padding: 6px; }
  .nav-user .uname-text { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .tbl { font-size: .85rem; }
  .tbl thead th, .tbl tbody td { padding: 10px 8px; }
}
