/* ==========================================================================
   Bladevel — THEME "FINALMENTE" (dashboard giáo dục hiện đại)
   Áp dụng từ mẫu finalmente-dashboard người dùng gửi: sidebar trắng 266px,
   nền #eff3f9, card trắng bo góc 16px, accent xanh #0f79f3, font Outfit,
   icon Material Symbols, nút FAB đổi màu nhấn.

   GHI CHÚ TÍCH HỢP (khác bản gốc mẫu):
   - Chỉ giữ nhánh LIGHT (bỏ dark mode) để không xung đột với các trang công
     cụ tw-* / rd-* vốn được thiết kế cho nền sáng.
   - Không dùng reset global cho a/button/img như bản gốc — reset đã được
     scope lại vào đúng component của theme, để KHÔNG đè lên style nội dung
     .tw-shell (teacher.css) và .rd-* (exam-page.css).
   - Khối .fm-main .tw-* dùng để néu khung nội dung cũ (tw-shell) vào layout
     mới: nền trong suốt để lộ nền theme, bỏ min-height:100vh lồng nhau.
   ========================================================================== */

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

/* ============ TOKENS ============ */
:root {
  --primary: #0f79f3;
  --primary-rgb: 15, 121, 243;
  --primary-soft: #f1f2fd;
  --violet: #796df6;
  --violet-2: #978bff;
  --cyan: #00cae3;
  --orange: #ffa500;
  --success: #2ed47e;
  --success-dark: #0eac5d;
  --success-soft: #eafbf2;
  --danger: #e74c3c;
  --danger-soft: #fdeaea;
  --body-bg: #eff3f9;
  --card-bg: #ffffff;
  --sidebar-bg: #ffffff;
  --heading: #2c3a4f;
  --body-text: #919aa3;
  --menu-text: #5f6c80;
  --border: #edf0f7;
  --input-bg: #f4f6fc;
  --grid-line: #e8ecf4;
  --tooltip-bg: #ffffff;
  --shadow-sm: 0 2px 12px rgba(30, 60, 114, .05);
  --shadow-md: 0 12px 32px rgba(30, 60, 114, .10);
  --shadow-lg: 0 20px 50px rgba(30, 60, 114, .16);
  --radius: 16px;
  --sidebar-w: 266px;
  --topbar-h: 72px;
  --trans: all .3s cubic-bezier(.4, 0, .2, 1);
}

html { scroll-behavior: smooth; }
body {
  margin: 0; /* trình duyệt mặc định 8px — làm lộ viền quanh toàn trang và khiến trang thuyết trình bị cuộn */
  font-family: 'Outfit', sans-serif;
  background: var(--body-bg);
  color: var(--body-text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Icon font Material Symbols — chỉ dùng trong chrome theme + dashboard */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block;
  white-space: nowrap; word-wrap: normal; direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased; user-select: none;
}
.msr {
  font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal;
  line-height: 1; display: inline-block; white-space: nowrap; user-select: none;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c9d2e3; border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::selection { background: rgba(var(--primary-rgb), .22); }

/* Link chỉ trong chrome theme (sidebar) — không đụng link nội dung công cụ */
.sidebar a { color: inherit; text-decoration: none; }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); z-index: 1050; display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1), background .4s ease;
}
.sidebar-head {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 0 24px; flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { width: 32px; height: 32px; display: block; }
.logo-name { font-size: 19px; font-weight: 700; color: var(--heading); letter-spacing: .01em; }
.burger {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: var(--menu-text); transition: var(--trans);
  background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit;
}
.burger:hover { background: var(--primary-soft); color: var(--primary); }
.burger .bars { display: flex; flex-direction: column; gap: 5px; width: 22px; }
.burger .bars i { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: var(--trans); }
.burger:hover .bars i:nth-child(2) { width: 70%; }
.burger.mobile-only { display: none; margin-bottom: 16px; }
.sidebar-menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 16px 30px; scrollbar-width: thin; }
.menu-label {
  display: flex; align-items: center; gap: 9px; margin: 20px 8px 9px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: #a3aebf;
}
.menu-label::before { content: ""; width: 15px; height: 2px; border-radius: 2px; background: currentColor; opacity: .75; }
.menu-item { list-style: none; margin: 0; padding: 0; }
.menu-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px; cursor: pointer;
  color: var(--menu-text); font-size: 15px; font-weight: 500;
  position: relative; transition: var(--trans); list-style: none;
}
.menu-link .msr { font-size: 21px; width: 24px; text-align: center; flex-shrink: 0; transition: var(--trans); }
.menu-link:hover { background: var(--primary-soft); color: var(--primary); }
.menu-link:hover .msr { transform: translateX(2px) scale(1.06); }
.menu-link.active {
  background: linear-gradient(92deg, rgba(var(--primary-rgb), .14), rgba(var(--primary-rgb), .03));
  color: var(--primary); font-weight: 600;
}
.menu-link.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--primary);
}
.count-badge { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.count-badge.pill { padding: 2.5px 9px; border-radius: 99px; font-size: 11.5px; }
.count-badge.green { background: var(--success-soft); color: var(--success-dark); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px);
  z-index: 1040; opacity: 0; visibility: hidden; transition: var(--trans);
}
body.sb-open .sidebar-backdrop { opacity: 1; visibility: visible; }

/* ============ LAYOUT ============ */
.main {
  margin-left: var(--sidebar-w); min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .35s cubic-bezier(.4, 0, .2, 1);
}
body.sb-collapsed .sidebar { transform: translateX(-100%); }
body.sb-collapsed .main { margin-left: 0; }
body.sb-collapsed .sidebar-backdrop { opacity: 0; visibility: hidden; }
/* Sidebar đang thu gọn: hiện lại nút mở menu cả trên desktop — trước đây nút
   mở chỉ tồn tại trên mobile nên thu gọn xong không còn cách nào mở lại. */
body.sb-collapsed .burger.mobile-only { display: grid; }
/* Riêng trang Thuyết trình: khung soạn slide cần đúng chiều cao khung nhìn
   (bố cục gốc dựa vào chuỗi flex full-height của layout cũ, layout mới đã bỏ
   chuỗi này) — trừ padding trên/dưới của .page-content; nhờ vậy trang không
   bị cuộn và trình soạn tự co giãn theo màn hình. */
.fm-main .tw-main-slide-editor { height: calc(100vh - 70px); }
/* Riêng trang Thuyết trình: nút mở menu nổi góc trên trái, KHÔNG chiếm chiều
   cao dòng — khung soạn slide tự focus vào ô tên bài giảng khi tải trang,
   nếu nút nằm trong dòng thì trang bị cuộn đi đúng chiều cao nút đó. */
.fm-main:has(.tw-main-slide-editor) .page-content { position: relative; }
.fm-main:has(.tw-main-slide-editor) .burger.mobile-only {
  position: absolute; top: 12px; left: 12px; margin-bottom: 0; z-index: 90;
  background: #ffffff; border: 1px solid #e5e9f2; border-radius: 10px;
  box-shadow: 0 1px 8px rgba(15, 23, 42, .10);
}
@media (max-width: 1200px) {
  body:not(.sb-open) .sidebar { transform: translateX(-100%); }
  body.sb-open .sidebar { transform: none; }
  .main { margin-left: 0 !important; }
  .burger.mobile-only { display: grid; }
}

/* Néu khung nội dung cũ (tw-shell) vào layout theme:
   - nền trong suốt để lộ --body-bg của theme (thay cho #ffffff khi đập)
   - bỏ min-height:100vh lồng nhau giữa .main và .tw-shell/.tw-app
   - .tw-main không cần padding riêng nữa (.page-content đã có) */
.fm-main .tw-shell { background: transparent; min-height: 0; }
.fm-main .tw-app { min-height: 0; }
.fm-main .tw-main { padding: 0; }
.fm-main .tw-content { display: block; }

/* ============ PAGE / GRID ============ */
.page-content { padding: 26px 28px 44px; flex: 1; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-title { font-size: 16.5px; font-weight: 600; color: var(--heading); letter-spacing: .01em; margin: 0; }
.select-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 500; color: var(--heading);
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border);
  transition: var(--trans); cursor: default; background: transparent;
}
.select-chip .msr { font-size: 18px; color: var(--body-text); }
/* grid placements */
.card-total-sales { grid-column: 1/3; grid-row: 1/3; }
.card-orders { grid-column: 3; grid-row: 1; }
.card-revenue { grid-column: 4; grid-row: 1; }
.card-customers { grid-column: 3; grid-row: 2; }
.card-sales-overview { grid-column: 4; grid-row: 2; }
.card-profit { grid-column: 1; grid-row: 3; }
.card-avg-sales { grid-column: 2; grid-row: 3; }
.card-top-products { grid-column: 3/5; grid-row: 3/5; }
.card-best-seller { grid-column: 1; grid-row: 4; }
.card-new-customers { grid-column: 2; grid-row: 4; }
@media (max-width: 1399px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
  .card-total-sales { grid-column: 1/3; grid-row: auto; }
  .card-top-products { grid-column: 1/3; grid-row: auto; }
  .card-orders, .card-revenue, .card-customers, .card-sales-overview,
  .card-profit, .card-avg-sales, .card-best-seller, .card-new-customers { grid-column: auto; grid-row: auto; }
}
@media (max-width: 760px) {
  .dashboard-grid { grid-template-columns: 1fr; gap: 18px; }
  .card-total-sales, .card-top-products { grid-column: auto; }
  .page-content { padding: 20px 16px 90px; }
}

/* ============ STAT CARDS ============ */
.stat-card { display: flex; flex-direction: column; min-height: 126px; justify-content: space-between; }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stat-icon {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
}
.stat-icon .msr { font-size: 27px; font-variation-settings: 'FILL' 1, 'wght' 500; }
.stat-icon.blue { background: linear-gradient(135deg, #3f9bff, #0f6ef0); box-shadow: 0 9px 20px rgba(15, 121, 243, .38); }
.stat-icon.orange { background: linear-gradient(135deg, #ffc25e, #ff9502); box-shadow: 0 9px 20px rgba(255, 165, 0, .38); }
.stat-icon.cyan { background: linear-gradient(135deg, #2fdcf0, #00b5d8); box-shadow: 0 9px 20px rgba(0, 202, 227, .38); }
.stat-value { font-size: 27px; font-weight: 600; color: var(--heading); margin: 4px 0 10px; letter-spacing: .01em; }
.stat-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; flex-wrap: wrap; }
.stat-note { font-size: 13.5px; color: var(--body-text); line-height: 1.35; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12.5px; font-weight: 600; padding: 3.5px 9px; border-radius: 8px;
  border: 1px solid; white-space: nowrap;
}
.chip .msr { font-size: 14px; font-variation-settings: 'FILL' 1, 'wght' 600; }
.chip.up { color: var(--success-dark); background: var(--success-soft); border-color: rgba(46, 212, 126, .4); }

/* ============ TỔNG QUAN CHẤM BÀI (card tím) ============ */
.card-sales-overview {
  background: linear-gradient(135deg, #8f7cf8 0%, #7561ea 52%, #8a5df0 100%);
  border: 0; color: #fff; display: flex; flex-direction: column;
}
.card-sales-overview .card-title { color: #fff; }
.card-sales-overview::before, .card-sales-overview::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 68%);
}
.card-sales-overview::before { width: 190px; height: 190px; top: -85px; right: -55px; }
.card-sales-overview::after { width: 130px; height: 130px; bottom: -70px; left: -40px; }
.so-stats { display: flex; justify-content: space-between; gap: 10px; margin: 16px 0 18px; position: relative; z-index: 1; }
.so-stat .lbl { font-size: 13px; opacity: .85; font-weight: 400; margin: 0; }
.so-stat .val { font-size: 23px; font-weight: 600; margin-top: 3px; letter-spacing: .01em; }
.progress { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, .28); overflow: hidden; position: relative; z-index: 1; }
.progress > i {
  display: block; height: 100%; width: 0; border-radius: 99px; background: #fff;
  transition: width 1.3s cubic-bezier(.22, 1, .36, 1) .5s; box-shadow: 0 0 10px rgba(255, 255, 255, .7);
}
.so-note { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 11px; opacity: .94; position: relative; z-index: 1; }
.so-note .msr { font-size: 16px; font-variation-settings: 'FILL' 1; }

/* ============ CHART CARDS ============ */
.legend { display: flex; align-items: center; gap: 20px; margin-left: 20px; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 500; color: var(--body-text); }
.legend i { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(0, 0, 0, .04); }
.chart-box { margin-top: 10px; }
#fmMainChart { height: 252px; }
#fmScoreChart { height: 148px; }
#fmWorkChart { height: 172px; }
#fmSpark { height: 64px; margin-top: 14px; }
.profit-value { font-size: 28px; font-weight: 600; color: var(--heading); margin: 6px 0 4px; }

/* ============ ĐỀ THI GẦN ĐÂY (product-list) ============ */
.product-list { margin-top: 10px; }
a.product-row { display: grid; }
.product-row {
  grid-template-columns: 24px 48px minmax(150px, 1.35fr) 1fr auto;
  align-items: center; gap: 14px; padding: 11.5px 0;
  border-bottom: 1px dashed var(--border); border-radius: 10px;
  color: inherit;
}
.product-list .product-row:last-of-type { border-bottom: 0; }
.product-row:hover { background: rgba(var(--primary-rgb), .04); }
.rank { font-weight: 600; color: var(--heading); font-size: 14.5px; }
.p-thumb {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden; position: relative; flex-shrink: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, var(--tint1, #eef4ff), var(--tint2, #e2ecff));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}
.p-thumb .msr { font-size: 23px; color: rgba(var(--primary-rgb), .75); font-variation-settings: 'FILL' 1; }
.p-name { font-weight: 600; color: var(--heading); font-size: 15px; margin: 0; }
.p-sold { font-size: 13px; color: var(--body-text); margin-top: 1px; }
.p-code { color: var(--body-text); font-size: 14px; }
.p-price { font-weight: 600; color: var(--heading); font-size: 15px; white-space: nowrap; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.table-foot .info { font-size: 14px; }
.fm-link-more {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; color: var(--primary);
  padding: 8px 14px; border-radius: 99px; transition: var(--trans);
}
.fm-link-more:hover { background: var(--primary-soft); }
.fm-link-more .msr { font-size: 17px; }
.fm-empty {
  padding: 26px 10px; text-align: center; font-size: 14.5px; color: var(--body-text);
}

/* ============ PHIẾU CHẤM MỚI NHẤT (best seller) ============ */
.card-best-seller {
  background: linear-gradient(135deg, #eef0ff 0%, #e6e1fb 100%);
  border: 0; display: flex; flex-direction: column;
}
.card-best-seller .card-title { font-size: 17px; }
.bs-name { color: var(--violet); font-weight: 600; font-size: 17.5px; margin: 12px 0 10px; }
.bs-sales { font-size: 26px; font-weight: 600; color: var(--heading); }
.bs-sales small { font-size: 14px; color: var(--body-text); font-weight: 400; margin-left: 4px; }
.btn-details {
  margin-top: auto; padding-top: 20px;
  display: inline-flex; align-items: center; gap: 8px; width: max-content;
  background: linear-gradient(135deg, #8f7cf8, #6e5ce8); color: #fff;
  font-weight: 600; font-size: 14px; padding: 10px 20px; border-radius: 99px;
  box-shadow: 0 9px 20px rgba(121, 109, 246, .42); transition: var(--trans);
  border: 0; cursor: pointer; font-family: inherit;
}
.btn-details .msr { font-size: 17px; transition: transform .3s; }
.btn-details:hover { transform: translateY(-3px); box-shadow: 0 13px 26px rgba(121, 109, 246, .55); }
.btn-details:hover .msr { transform: translateX(4px); }
.bs-photo {
  position: absolute; right: 16px; bottom: 0; width: 112px; height: 128px;
  border-radius: 16px 16px 0 0; overflow: hidden; flex-shrink: 0;
  box-shadow: 0 10px 24px rgba(70, 60, 180, .25);
}
.bs-photo .fallback {
  position: absolute; inset: 0; border-radius: inherit; display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 34px; letter-spacing: .02em;
  background: linear-gradient(135deg, #796df6, #0f79f3);
}
@media (max-width: 480px) { .bs-photo { display: none; } }

/* ============ NHỊP TẠO ĐỀ (new customers) ============ */
.card-new-customers { display: flex; flex-direction: column; }
.nc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

/* ============ FAB / CUSTOMIZER ============ */
.fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 1120;
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, #3f9bff, #0f6ef0); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(15, 121, 243, .5);
  transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
  border: 0; cursor: pointer; padding: 0; font-family: inherit;
}
.fab .msr { font-size: 26px; transition: transform .45s; }
.fab:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 16px 34px rgba(15, 121, 243, .6); }
.fab-panel {
  position: fixed; right: 26px; bottom: 94px; z-index: 1120; width: 236px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 18px;
  opacity: 0; visibility: hidden; transform: translateY(14px) scale(.95);
  transform-origin: bottom right; transition: var(--trans);
}
.fab-panel.show { opacity: 1; visibility: visible; transform: none; }
.fp-title { font-size: 14.5px; font-weight: 600; color: var(--heading); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.fp-title .msr { font-size: 18px; color: var(--primary); }
.fp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--border); }
.fp-row:first-of-type { border-top: 0; }
.fp-row .lbl { font-size: 14px; color: var(--body-text); }
.swatches { display: flex; gap: 9px; }
.swatch {
  width: 28px; height: 28px; border-radius: 9px; border: 2.5px solid transparent;
  cursor: pointer; transition: var(--trans); position: relative; padding: 0;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--heading); transform: scale(1.12); }

/* toast theme (dùng cho FAB đổi màu) */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 80px);
  background: var(--heading); color: #fff; font-size: 14px; font-weight: 500;
  padding: 11px 22px; border-radius: 99px; box-shadow: var(--shadow-lg);
  opacity: 0; transition: var(--trans); z-index: 1200; pointer-events: none;
  display: flex; align-items: center; gap: 8px;
}
.toast .msr { font-size: 17px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
