/* ══════════════════════════════════════════════════════════════════
   YLE Worksheets — Theme
   Ngôn ngữ thiết kế lấy từ mockup /library (nền kem, cam đất, bo tròn).
   Load SAU bootstrap.min.css để override token của Bootstrap.
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Token riêng của YLE ── */
  --yle-bg:        #fffdf9;
  --yle-panel:     #ffffff;
  --yle-ink:       #1c1917;
  --yle-muted:     #78716c;
  --yle-line:      #ece8e1;
  --yle-brand:     #c2410c;
  --yle-brand-dk:  #9a3412;
  --yle-brand-soft:#fff2e8;
  --yle-teal:      #0f766e;
  --yle-r:         14px;
  --yle-shadow:    0 10px 26px rgba(28,25,23,.09);

  /* ── Override token Bootstrap ── */
  --bs-primary: #c2410c;
  --bs-primary-rgb: 194, 65, 12;
  --bs-body-bg: var(--yle-bg);
  --bs-body-color: var(--yle-ink);
  --bs-border-color: var(--yle-line);
  --bs-border-radius: 12px;
  --bs-border-radius-sm: 8px;
  --bs-border-radius-lg: 16px;
  --bs-link-color: var(--yle-brand);
  --bs-link-hover-color: var(--yle-brand-dk);
  --bs-font-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                        "Helvetica Neue", Arial, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────────── */
body {
  background: var(--yle-bg);
  color: var(--yle-ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--yle-brand); text-decoration: none; }
a:hover { color: var(--yle-brand-dk); text-decoration: underline; }

/* ── Header / Nav ─────────────────────────────────────────────── */
nav.yle-nav {
  background: #fff;
  border-bottom: 1px solid var(--yle-line);
  padding: .8rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.6rem;
  position: sticky;
  top: 0;
  z-index: 40;
}
nav.yle-nav .brand {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -.3px;
  color: var(--yle-ink);
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}
nav.yle-nav .brand:hover { text-decoration: none; }
nav.yle-nav .brand .mark {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: var(--yle-brand);
  display: grid; place-items: center;
  font-size: .9rem;
  flex: 0 0 auto;
}
nav.yle-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: .875rem;
  flex-wrap: wrap;
}
nav.yle-nav .nav-links a { color: var(--yle-muted); }
nav.yle-nav .nav-links a:hover { color: var(--yle-ink); text-decoration: none; }
nav.yle-nav .nav-links a.active { color: var(--yle-ink); font-weight: 600; }
nav.yle-nav .nav-spacer { flex: 1; }

.credit-badge {
  display: inline-block;
  background: var(--yle-brand-soft);
  color: var(--yle-brand-dk);
  border: 1px solid #fdba74;
  font-weight: 700;
  font-size: .8rem;
  padding: .28rem .7rem;
  border-radius: 20px;
  white-space: nowrap;
}
.nav-user { color: var(--yle-muted); font-size: .85rem; }
.nav-user:hover { color: var(--yle-ink); text-decoration: none; }

/* ── Language switcher ────────────────────────────────────────── */
.lang-switch {
  display: inline-flex;
  border: 1.5px solid var(--yle-line);
  border-radius: 9px;
  overflow: hidden;
  font-size: .78rem;
  font-weight: 700;
}
.lang-switch a {
  padding: .26rem .6rem;
  color: var(--yle-muted);
  background: #fff;
}
.lang-switch a:hover { background: #faf7f2; color: var(--yle-ink); text-decoration: none; }
.lang-switch a.on { background: var(--yle-ink); color: #fff; }

/* ── Buttons (override Bootstrap) ─────────────────────────────── */
.btn {
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
  padding: .55rem 1.2rem;
}
.btn-primary {
  --bs-btn-bg: var(--yle-brand);
  --bs-btn-border-color: var(--yle-brand);
  --bs-btn-hover-bg: var(--yle-brand-dk);
  --bs-btn-hover-border-color: var(--yle-brand-dk);
  --bs-btn-active-bg: var(--yle-brand-dk);
  --bs-btn-active-border-color: var(--yle-brand-dk);
  --bs-btn-disabled-bg: #e7a58c;
  --bs-btn-disabled-border-color: #e7a58c;
}
.btn-outline-primary {
  --bs-btn-color: var(--yle-brand);
  --bs-btn-border-color: var(--yle-brand);
  --bs-btn-hover-bg: var(--yle-brand);
  --bs-btn-hover-border-color: var(--yle-brand);
  --bs-btn-active-bg: var(--yle-brand-dk);
}
.btn-secondary {
  --bs-btn-bg: #f3efe9;
  --bs-btn-border-color: var(--yle-line);
  --bs-btn-color: var(--yle-ink);
  --bs-btn-hover-bg: #e9e3da;
  --bs-btn-hover-border-color: #ddd5c9;
  --bs-btn-hover-color: var(--yle-ink);
}
.btn-danger {
  --bs-btn-bg: #b91c1c;
  --bs-btn-border-color: #b91c1c;
  --bs-btn-hover-bg: #991b1b;
  --bs-btn-hover-border-color: #991b1b;
}

/* ── Card / badge / alert ─────────────────────────────────────── */
.card {
  border: 1px solid var(--yle-line);
  border-radius: var(--yle-r);
  background: var(--yle-panel);
}
.badge { font-weight: 700; letter-spacing: .01em; }
.alert { border-radius: 12px; border-width: 1px; }

/* ── Flash messages ───────────────────────────────────────────── */
.flash-msg {
  padding: .7rem 1.2rem;
  margin: .6rem 2rem 0;
  border-radius: 10px;
  font-size: .9rem;
}
.flash-msg.info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.flash-msg.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-msg.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash-msg.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Container ────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 2rem; }
.container-wide { max-width: 1280px; }

/* ── Footer ───────────────────────────────────────────────────── */
footer.yle-footer {
  text-align: center;
  padding: 1.6rem;
  color: var(--yle-muted);
  font-size: .8rem;
  border-top: 1px solid var(--yle-line);
  margin-top: 2.5rem;
}

/* ── Tiện ích dùng chung ──────────────────────────────────────── */
.page-title { font-size: 1.55rem; font-weight: 750; letter-spacing: -.4px; }
.page-sub   { color: var(--yle-muted); font-size: .92rem; margin-top: .25rem; }
.muted      { color: var(--yle-muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  nav.yle-nav { padding: .7rem 1.1rem; gap: 1rem; flex-wrap: wrap; }
  nav.yle-nav .nav-links { gap: .9rem; font-size: .82rem; }
  .container { padding: 1.1rem 1.1rem; }
  .flash-msg { margin: .5rem 1.1rem 0; }
}
@media (max-width: 620px) {
  nav.yle-nav .brand span.brand-text { display: none; }
  .page-title { font-size: 1.3rem; }
}

/* ══════════════════════════════════════════════════════════════════
   Kho bài tập — thẻ worksheet (dùng chung: trang chủ + trang danh mục)
   ══════════════════════════════════════════════════════════════════ */

.lib-wrap { max-width: 1180px; margin: 0 auto; padding: 1.3rem 1rem 0; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }

.ws-card {
  background: #fff; border: 1px solid var(--yle-line); border-radius: var(--yle-r);
  overflow: hidden; display: flex; flex-direction: column;
  transition: .18s; text-decoration: none; color: inherit;
}
.ws-card:hover {
  box-shadow: var(--yle-shadow); transform: translateY(-3px);
  border-color: #e0d9cf; text-decoration: none; color: inherit;
}
.ws-thumb {
  height: 118px; background: #fff; border-bottom: 1px solid var(--yle-line);
  padding: .7rem .8rem; position: relative; overflow: hidden;
}
.ws-thumb .tline { height: 5px; border-radius: 3px; background: #efeae2; margin-bottom: 5px; }
.ws-thumb .tline.w55 { width: 55%; }
.ws-thumb .tline.w80 { width: 80%; }
.ws-thumb .tline.w35 { width: 35%; }
.ws-thumb .tbox {
  height: 23px; border: 1px dashed #e2dcd2; border-radius: 6px; margin: 6px 0;
  display: flex; align-items: center; padding: 0 7px; gap: 5px;
}
.ws-thumb .dot { width: 9px; height: 9px; border-radius: 50%; background: #efeae2; }
.ws-pin {
  position: absolute; top: .55rem; right: .55rem;
  font-size: .6rem; font-weight: 800; padding: .14rem .42rem; border-radius: 6px;
}
.p1 { background: #dcfce7; color: #166534; }
.p2 { background: #dbeafe; color: #1e40af; }
.p3 { background: #fef3c7; color: #92400e; }
.ws-body { padding: .7rem .8rem .8rem; display: flex; flex-direction: column; flex: 1; }
.ws-body h4 { font-size: .86rem; font-weight: 650; line-height: 1.35; margin-bottom: .3rem; }
.ws-meta { font-size: .71rem; color: var(--yle-muted); margin-top: auto; }

.lib-empty { text-align: center; padding: 3.5rem 1rem; }
.lib-empty .icon { font-size: 2.6rem; opacity: .45; margin-bottom: .7rem; }
.lib-empty h2 { font-size: 1.15rem; font-weight: 750; margin-bottom: .4rem; }
.lib-empty p { color: var(--yle-muted); font-size: .9rem; margin-bottom: 1.2rem; }

@media (max-width: 900px) {
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .75rem; }
  .ws-thumb { height: 100px; }
}
@media (max-width: 620px) {
  .lib-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
}
