/* =====================================================================
   MHT Vocabulary Hub · Sistema visual Master Hub Training
   Paleta extraida del logotipo oficial:
     navy   #17264A   ·  azul cielo #5BA8E0  ·  gris wordmark #58585B
   Tipografia: Gotham (titulos) + Raleway (texto), como el resto de MHT.
   ===================================================================== */

/* ---------- Tipografias de marca ---------------------------------- */
@font-face {
  font-family: 'Gotham';
  src: url('../fonts/Gotham-Book.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Gotham';
  src: url('../fonts/Gotham-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Raleway';
  src: url('../fonts/Raleway-Italic-VariableFont_wght.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ------------------------------------------------- */
:root {
  /* Marca */
  --mht-navy-900: #0B1B34;
  --mht-navy:     #17264A;
  --mht-navy-700: #1F3A66;
  --mht-blue:     #5BA8E0;
  --mht-blue-600: #3F92CE;
  --mht-blue-300: #A5CFEE;
  --mht-blue-100: #E8F2FB;
  --mht-gray:     #58585B;
  --mht-orange:   #F97316;

  /* Superficies */
  --surface:      #F6F9FC;
  --card:         #FFFFFF;
  --line:         #E3EAF2;
  --line-soft:    #EFF4F9;
  --ink:          #17264A;
  --ink-soft:     #5A6B85;
  --ink-faint:    #8A99B0;

  /* Estados */
  --ok:      #1F9D55;
  --ok-bg:   #E4F6EC;
  --warn:    #B45309;
  --warn-bg: #FEF3C7;
  --bad:     #DC2626;
  --bad-bg:  #FEE9E9;

  /* Formas */
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(11, 27, 52, .06), 0 2px 8px rgba(11, 27, 52, .05);
  --shadow:    0 4px 14px rgba(11, 27, 52, .08), 0 12px 32px rgba(11, 27, 52, .06);
  --shadow-lg: 0 18px 48px rgba(11, 27, 52, .16);

  /* Tipografia */
  --font-display: 'Gotham', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:    'Raleway', 'Gotham', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Bootstrap override */
  --bs-primary: #17264A;
  --bs-body-font-family: var(--font-body);
  --bs-border-radius: var(--r);
}

/* ---------- Base --------------------------------------------------- */
* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.mht-display { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; color: var(--mht-navy); }

a { color: var(--mht-blue-600); text-decoration: none; }
a:hover { color: var(--mht-navy); }

.text-muted-mht { color: var(--ink-soft) !important; }
.text-faint     { color: var(--ink-faint) !important; }

::selection { background: var(--mht-blue-300); color: var(--mht-navy-900); }

/* Foco accesible y consistente */
:focus-visible {
  outline: 3px solid var(--mht-blue-300);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Marca -------------------------------------------------- */
.mht-logo { height: 42px; width: auto; display: block; }
.mht-logo-sm { height: 34px; }
.mht-logo-lg { height: 66px; }

.mht-brandline {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: .66rem;
  color: var(--mht-blue);
}

/* ---------- Botones ------------------------------------------------ */
.btn { font-family: var(--font-display); font-weight: 700; border-radius: var(--r-sm); padding: .55rem 1.05rem; transition: .16s ease; }
.btn:active { transform: translateY(1px); }

.btn-mht {
  background: var(--mht-navy);
  border: 1px solid var(--mht-navy);
  color: #fff;
}
.btn-mht:hover, .btn-mht:focus { background: var(--mht-navy-700); border-color: var(--mht-navy-700); color: #fff; }

.btn-mht-blue {
  background: var(--mht-blue);
  border: 1px solid var(--mht-blue);
  color: var(--mht-navy-900);
}
.btn-mht-blue:hover, .btn-mht-blue:focus { background: var(--mht-blue-600); border-color: var(--mht-blue-600); color: #fff; }

.btn-mht-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--mht-navy);
}
.btn-mht-ghost:hover { border-color: var(--mht-blue); background: var(--mht-blue-100); color: var(--mht-navy); }

.btn-mht-soft {
  background: var(--mht-blue-100);
  border: 1px solid transparent;
  color: var(--mht-navy);
}
.btn-mht-soft:hover { background: var(--mht-blue-300); color: var(--mht-navy-900); }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
}

/* ---------- Tarjetas ----------------------------------------------- */
.mht-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.mht-card-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
}
.mht-card-head h2, .mht-card-head h3 { margin: 0; font-size: 1.02rem; }
.mht-card-body { padding: 1.25rem; }

/* ---------- Formularios -------------------------------------------- */
.form-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .35rem;
}
.form-control, .form-select {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .6rem .8rem;
  font-size: .95rem;
  background: #fff;
  color: var(--ink);
}
.form-control:focus, .form-select:focus {
  border-color: var(--mht-blue);
  box-shadow: 0 0 0 4px rgba(91, 168, 224, .18);
}
.form-text { color: var(--ink-faint); font-size: .8rem; }

/* ---------- Insignias ---------------------------------------------- */
.mht-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--font-display);
  font-weight: 700; font-size: .72rem;
  padding: .26rem .6rem; border-radius: 999px;
  letter-spacing: .02em;
}
.mht-badge.is-ok   { background: var(--ok-bg);   color: var(--ok); }
.mht-badge.is-warn { background: var(--warn-bg); color: var(--warn); }
.mht-badge.is-bad  { background: var(--bad-bg);  color: var(--bad); }
.mht-badge.is-mute { background: #EEF2F7;        color: var(--ink-soft); }
.mht-badge.is-blue { background: var(--mht-blue-100); color: var(--mht-navy-700); }

.lang-chip {
  font-family: var(--font-display); font-weight: 700; font-size: .68rem;
  padding: .18rem .5rem; border-radius: 6px; letter-spacing: .04em;
}
.lang-en { background: var(--mht-blue-100); color: var(--mht-navy-700); }
.lang-fr { background: #F3E8FF; color: #6B21A8; }

/* ---------- Codigo monoespaciado ----------------------------------- */
.code-pill {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-weight: 700; letter-spacing: .08em;
  background: var(--mht-navy); color: #fff;
  padding: .3rem .65rem; border-radius: 8px;
  display: inline-block; font-size: .85rem;
}

/* =====================================================================
   PANEL DE ADMINISTRACION
   ===================================================================== */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 260px; flex: 0 0 260px;
  background: linear-gradient(178deg, var(--mht-navy) 0%, var(--mht-navy-900) 100%);
  color: #fff;
  padding: 1.15rem .9rem 1.5rem;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.admin-sidebar .brand-box {
  background: #fff; border-radius: var(--r);
  padding: .7rem .8rem; margin-bottom: 1.4rem;
}
.admin-nav { display: flex; flex-direction: column; gap: .18rem; }
.admin-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; border-radius: var(--r-sm);
  color: rgba(255,255,255,.78);
  font-family: var(--font-display); font-weight: 700; font-size: .88rem;
  transition: .15s ease;
}
.admin-nav a i { font-size: 1.05rem; width: 20px; text-align: center; }
.admin-nav a:hover { background: rgba(255,255,255,.09); color: #fff; }
.admin-nav a.active { background: var(--mht-blue); color: var(--mht-navy-900); }
.admin-nav .nav-sep {
  margin: 1rem .8rem .4rem;
  font-size: .66rem; letter-spacing: .16em; text-transform: uppercase;
  color: rgba(255,255,255,.4); font-family: var(--font-display); font-weight: 700;
}

.admin-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .85rem 1.4rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 20;
}
.admin-topbar h1 { font-size: 1.18rem; margin: 0; }
.admin-content { padding: 1.5rem 1.4rem 3rem; flex: 1 1 auto; }

.admin-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--mht-blue-100); color: var(--mht-navy);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: .85rem;
}

/* Metricas del dashboard */
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.15rem 1.25rem; height: 100%;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; inset: auto -30px -40px auto;
  width: 120px; height: 120px; border-radius: 50%;
  background: var(--mht-blue-100); opacity: .55;
}
.stat-card > * { position: relative; z-index: 1; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem;
  background: var(--mht-navy); color: #fff; margin-bottom: .75rem;
}
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; line-height: 1; color: var(--mht-navy); }
.stat-label { font-size: .8rem; color: var(--ink-soft); margin-top: .3rem; }

/* Tablas */
.mht-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.mht-table th {
  font-family: var(--font-display); font-weight: 700;
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); background: var(--line-soft);
  padding: .65rem .85rem; text-align: left; white-space: nowrap;
}
.mht-table th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.mht-table th:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.mht-table td { padding: .8rem .85rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.mht-table tbody tr:hover td { background: #FAFCFE; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Fila de grupo con orden */
.order-btns { display: inline-flex; flex-direction: column; gap: 2px; }
.order-btns button {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  width: 26px; height: 20px; line-height: 1; border-radius: 6px; font-size: .7rem;
  display: grid; place-items: center; cursor: pointer;
}
.order-btns button:hover { background: var(--mht-blue-100); color: var(--mht-navy); border-color: var(--mht-blue-300); }
.order-btns button:disabled { opacity: .35; cursor: default; }

/* Estado vacio */
.empty-state {
  text-align: center; padding: 2.75rem 1.25rem;
  border: 1.5px dashed var(--line); border-radius: var(--r-lg);
  background: #FCFDFF; color: var(--ink-soft);
}
.empty-state i { font-size: 2.1rem; color: var(--mht-blue-300); display: block; margin-bottom: .6rem; }
.empty-state strong { display: block; font-family: var(--font-display); color: var(--mht-navy); margin-bottom: .25rem; }

/* Acordeon de grupos */
.group-row {
  border: 1px solid var(--line); border-radius: var(--r);
  background: #fff; margin-bottom: .6rem; overflow: hidden;
}
.group-row-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; }
.group-icon {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
  display: grid; place-items: center; color: #fff; font-size: 1.05rem;
}
.group-title { font-family: var(--font-display); font-weight: 700; color: var(--mht-navy); }
.subgroup-list { border-top: 1px solid var(--line-soft); background: #FAFCFE; padding: .5rem .75rem .75rem; }
.subgroup-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .7rem; border-radius: var(--r-sm);
  background: #fff; border: 1px solid var(--line-soft); margin-top: .4rem;
}

/* Login administrador */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background:
    radial-gradient(1100px 520px at 15% -10%, rgba(91,168,224,.30), transparent 60%),
    radial-gradient(900px 480px at 110% 110%, rgba(31,58,102,.35), transparent 55%),
    var(--mht-navy-900);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: var(--r-xl); padding: 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
}

/* =====================================================================
   ZONA DEL ALUMNO
   ===================================================================== */
.student-gate {
  min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
  background:
    radial-gradient(1000px 500px at 50% -15%, rgba(91,168,224,.35), transparent 62%),
    linear-gradient(170deg, #0E2340 0%, var(--mht-navy-900) 100%);
}
.gate-card {
  width: 100%; max-width: 440px; background: #fff;
  border-radius: var(--r-xl); padding: 2.1rem 1.8rem;
  box-shadow: var(--shadow-lg); text-align: center;
}
.gate-card .form-control { text-align: center; }
#code {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 1.35rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; padding: .8rem;
}

.student-header {
  background: linear-gradient(120deg, var(--mht-navy) 0%, var(--mht-navy-700) 100%);
  color: #fff; padding: .8rem 0;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 2px 12px rgba(11,27,52,.18);
}
.student-header .brand-box {
  background: #fff; border-radius: 10px; padding: .35rem .55rem; display: inline-flex;
}
.student-level {
  font-family: var(--font-display); font-weight: 700;
  font-size: .95rem; line-height: 1.2;
}
.student-sub { font-size: .78rem; color: var(--mht-blue-300); }

/* Navegacion por unidades */
.unit-scroller {
  display: flex; gap: .5rem; overflow-x: auto; padding: .85rem 0 .35rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.unit-scroller::-webkit-scrollbar { display: none; }
.unit-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 700; font-size: .84rem;
  color: var(--mht-navy); cursor: pointer; transition: .15s ease;
}
.unit-chip:hover { border-color: var(--mht-blue); background: var(--mht-blue-100); }
.unit-chip.active { background: var(--mht-navy); border-color: var(--mht-navy); color: #fff; }
.unit-chip .count {
  background: rgba(23,38,74,.09); color: var(--mht-navy);
  border-radius: 999px; padding: 0 .42rem; font-size: .72rem;
}
.unit-chip.active .count { background: rgba(255,255,255,.2); color: #fff; }

/* Rejilla tipo mamposteria: las tarjetas con imagen no dejan huecos
   debajo de las que solo tienen texto. */
.vocab-grid { column-gap: 1rem; columns: 1; }
@media (min-width: 768px)  { .vocab-grid { columns: 2; } }
@media (min-width: 1200px) { .vocab-grid { columns: 3; } }
.vocab-col {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: block;
  margin-bottom: 1rem;
}

/* Tarjeta de vocabulario */
.vocab-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.vocab-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.vocab-card.is-playing { border-color: var(--mht-blue); box-shadow: 0 0 0 4px rgba(91,168,224,.18), var(--shadow); }

.vocab-media {
  aspect-ratio: 16 / 9; background: var(--mht-blue-100);
  display: grid; place-items: center; overflow: hidden;
}
.vocab-media img { width: 100%; height: 100%; object-fit: cover; }

.vocab-body { padding: 1.1rem 1.15rem 1.15rem; }
.vocab-term {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.45rem; line-height: 1.2; color: var(--mht-navy);
  margin: 0 0 .2rem;
}
.vocab-translation { color: var(--ink-soft); font-size: 1rem; margin-bottom: .5rem; }
.vocab-example {
  font-style: italic; color: var(--ink-soft); font-size: .9rem;
  border-left: 3px solid var(--mht-blue-300); padding-left: .7rem; margin-top: .65rem;
}

.fav-btn {
  border: none; background: transparent; color: var(--ink-faint);
  font-size: 1.25rem; line-height: 1; padding: .15rem; cursor: pointer;
}
.fav-btn.is-fav { color: var(--mht-orange); }

/* Reproductor */
.player {
  margin-top: .9rem; background: #FAFCFE;
  border: 1px solid var(--line-soft); border-radius: var(--r);
  padding: .8rem;
}
.player-row { display: flex; align-items: center; gap: .75rem; }
.play-btn {
  flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--mht-navy); color: #fff;
  font-size: 1.5rem; display: grid; place-items: center; cursor: pointer;
  transition: .16s ease; box-shadow: 0 4px 12px rgba(23,38,74,.28);
}
.play-btn:hover  { background: var(--mht-blue-600); }
.play-btn:active { transform: scale(.95); }
.play-btn[disabled] { background: #C7D2E0; box-shadow: none; cursor: not-allowed; }

.player-track { flex: 1 1 auto; min-width: 0; }
.progress-bar-wrap {
  height: 8px; background: #DFE8F2; border-radius: 999px;
  cursor: pointer; position: relative; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--mht-blue) 0%, var(--mht-blue-600) 100%);
  transition: width .1s linear;
}
.player-time {
  display: flex; justify-content: space-between;
  font-size: .74rem; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; margin-top: .35rem;
}
.player-tools { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; }
.tool-btn {
  border: 1px solid var(--line); background: #fff; color: var(--mht-navy);
  border-radius: 8px; padding: .3rem .6rem; font-size: .8rem;
  font-family: var(--font-display); font-weight: 700; cursor: pointer;
}
.tool-btn:hover { background: var(--mht-blue-100); border-color: var(--mht-blue-300); }
.tool-btn.active { background: var(--mht-navy); color: #fff; border-color: var(--mht-navy); }
.tool-btn[disabled] { opacity: .45; cursor: not-allowed; }

.no-audio {
  font-size: .82rem; color: var(--ink-faint);
  display: flex; align-items: center; gap: .4rem;
}

/* Barra fija de reproduccion global */
.play-all-bar {
  position: sticky; bottom: 0; z-index: 25;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: .6rem 0;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 991.98px) {
  .admin-sidebar {
    position: fixed; left: 0; top: 0; z-index: 1045;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(11,27,52,.5);
    z-index: 1040; display: none;
  }
  .sidebar-backdrop.show { display: block; }
}
@media (min-width: 992px) {
  .sidebar-toggle { display: none !important; }
}
@media (max-width: 575.98px) {
  .admin-content { padding: 1rem .85rem 3rem; }
  .vocab-term { font-size: 1.28rem; }
  .play-btn { flex-basis: 50px; width: 50px; height: 50px; font-size: 1.35rem; }
  .stat-value { font-size: 1.6rem; }
  .gate-card, .login-card { padding: 1.6rem 1.2rem; }
}

/* Impresion: hoja de vocabulario para clase */
@media print {
  .student-header, .play-all-bar, .player, .unit-scroller, .no-print { display: none !important; }
  .vocab-card { break-inside: avoid; box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
}

/* Respeto por reduccion de movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Utilidad: formulario transparente dentro de un contenedor flex */
.d-contents { display: contents; }

/* Selector de icono / color activo */
.icon-pick.selected, .btn-mht-ghost:has(> input:checked) {
  background: var(--mht-navy) !important; color: #fff !important; border-color: var(--mht-navy) !important;
}
label:has(> input[name="color"]:checked) > span {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--mht-navy);
}
