/* =====================================================================
   Taekwondo Juche Argentina — estilos de cuenta y panel
   ===================================================================== */

:root {
  --gold: #BDA236;
  --gold-dark: #9c8529;
  --gold-soft: #f6f1dc;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #e4e1d8;
  --bg: #f7f6f2;
  --card: #ffffff;
  --ok: #2e7d4f;
  --ok-soft: #e6f4ec;
  --err: #b3261e;
  --err-soft: #fdecea;
  --info: #2b5c8a;
  --info-soft: #e8f0f8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}

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

body {
  margin: 0;
  font-family: "Merriweather Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--gold-dark); }
img { max-width: 100%; display: block; }

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 32px; padding-bottom: 48px; }
main.narrow { max-width: 760px; }

/* ---------- Barra superior ---------- */
.topbar { background: #111; color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { color: var(--gold); text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.brand span { color: #fff; font-weight: 400; }
.topnav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topnav a, .topnav .link { color: #e9e9e9; text-decoration: none; font-size: .95rem; }
.topnav a:hover, .topnav .link:hover { color: var(--gold); }
.topnav .btn { color: #fff; }

.site-footer { padding: 24px 0; color: var(--muted); font-size: .85rem; text-align: center; border-top: 1px solid var(--line); }

/* ---------- Tipografía ---------- */
h1 { font-size: 1.75rem; margin: 0 0 .5rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 2rem 0 1rem; }
.lead { color: var(--muted); margin: 0 0 1.75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card { margin-top: 20px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; text-decoration: none; color: inherit; }
.stat strong { display: block; font-size: 2rem; line-height: 1.1; color: var(--ink); }
.stat span { color: var(--muted); font-size: .9rem; }
a.stat:hover { border-color: var(--gold); }
.stat.highlight { border-color: var(--gold); background: var(--gold-soft); }

/* ---------- Formularios ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 28px; }
legend { font-weight: 700; font-size: 1.05rem; margin-bottom: 14px; padding-bottom: 6px; border-bottom: 2px solid var(--gold); width: 100%; }
/* Fieldset con estilo de card: el título (legend) va adentro de la card */
fieldset.card { padding: 0 24px 24px; border: 1px solid var(--line); margin: 0 0 20px; overflow: hidden; }
fieldset.card > legend {
  float: left; box-sizing: border-box; width: calc(100% + 48px); margin: 0 -24px 18px;
  padding: 14px 24px 12px; background: var(--bg); border-bottom: 2px solid var(--gold);
  font-size: 1rem; line-height: 1.3; letter-spacing: .2px;
}
fieldset.card > legend + * { clear: both; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.req { color: var(--err); }

input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel],
input[type=number], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #cfcbc0;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
input[type=file] { font: inherit; font-size: .9rem; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--gold); flex-shrink: 0; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.foto-preview { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; background: var(--gold-soft); border: 3px solid var(--gold); margin-bottom: 10px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; font-size: .95rem;
  padding: 11px 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--gold); color: #fff; text-decoration: none;
  transition: background .15s ease, transform .15s ease;
}
.btn:hover { background: var(--gold-dark); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 16px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid #cfcbc0; }
.btn-ghost:hover { background: #efede6; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #24643f; }
.btn-danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.btn-danger:hover { background: var(--err-soft); }
button.link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
form.inline { display: inline; margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; border-left: 4px solid; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert-success { background: var(--ok-soft); border-color: var(--ok); }
.alert-error { background: var(--err-soft); border-color: var(--err); }
.alert-info { background: var(--info-soft); border-color: var(--info); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #eee; color: #444; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: #fff4d6; color: #8a6100; }
.badge-err { background: var(--err-soft); color: var(--err); }

/* ---------- Perfil ---------- */
.perfil { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.perfil img { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--gold); }
.perfil h1 { margin: 0; }
.datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 24px; margin: 0; }
.datos dt { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.datos dd { margin: 2px 0 0; font-weight: 600; }

/* ---------- Solicitudes ---------- */
.solicitud { display: grid; grid-template-columns: 96px 1fr; gap: 20px; }
.solicitud img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.solicitud h3 { margin: 0 0 4px; font-size: 1.1rem; }
@media (max-width: 540px) { .solicitud { grid-template-columns: 1fr; } }

.auth-links { margin-top: 18px; font-size: .9rem; text-align: center; }
.auth-links a { display: inline-block; margin: 0 8px; }

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { opacity: .7; }

/* ---------- Tablas ---------- */
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th, .tabla td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla th { font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #faf9f5; white-space: nowrap; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: #fcfbf7; }

/* ---------- Panel: piezas comunes ---------- */
.crud-thumb { max-width: 220px; max-height: 140px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 8px; background: #fff; }
.crud-mini { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.crud-mini.avatar { border-radius: 50%; width: 40px; height: 40px; }
/* Filtros de los listados: columnas de igual ancho; .filtros-fin agrupa el último filtro y el botón
   y ocupa el resto de la fila (el select se estira y «Filtrar» queda a la derecha) */
.filtros { --cols: 3; --gap: 16px; display: flex; flex-wrap: wrap; gap: 14px var(--gap); align-items: center; padding: 20px; margin-bottom: 20px; }
.filtros > input, .filtros > select, .filtros-fin { --w: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); flex: 1 1 var(--w); min-width: 0; }
.filtros > input, .filtros > select { max-width: var(--w); }
.filtros input, .filtros select { width: 100%; padding: 12px 14px; }
.filtros-fin { display: flex; gap: var(--gap); align-items: center; }
.filtros-fin > input, .filtros-fin > select { flex: 1; min-width: 0; }
.filtros-fin > .btn { flex: 0 0 auto; margin-left: auto; padding-top: 12px; padding-bottom: 12px; }
@media (max-width: 900px) { .filtros { --cols: 2; } }
@media (max-width: 560px) { .filtros { --cols: 1; } }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form select, .inline-form input { width: auto; padding: 6px 8px; font-size: .88rem; }
.fila-link { cursor: pointer; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .9rem; font-weight: 600; }
.tabs a:hover { border-color: var(--gold); }
textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid #cfcbc0; border-radius: 8px; resize: vertical; }
input[type=month], input[type=time], input[type=datetime-local] { font: inherit; padding: 10px 12px; border: 1px solid #cfcbc0; border-radius: 8px; background: #fff; width: 100%; }
code { background: #f1efe8; padding: 1px 6px; border-radius: 4px; font-size: .9em; }

.modulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.modulo { display: block; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.modulo:hover { border-color: var(--gold); transform: translateY(-1px); }
.modulo strong { display: block; }
.modulo span { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }

.progreso { height: 10px; background: #eee9da; border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
.progreso-barra { height: 100%; width: 0; background: var(--gold); transition: width .3s; }

.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 20px; }
.foto-item { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.foto-item img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.foto-item figcaption { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; font-size: .8rem; }
.foto-item.es-portada { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }

/* ---------- Mi cuenta ---------- */
.aviso { border-left: 4px solid var(--gold); padding: 4px 0 4px 16px; margin-bottom: 18px; }
.aviso h3 { margin: 0 0 4px; font-size: 1.05rem; }
.aviso img { max-width: 100%; border-radius: 8px; margin-top: 10px; }
.lista-material { list-style: none; padding: 0; margin: 0; }
.lista-material li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lista-material li:last-child { border-bottom: 0; }
.torneo { padding: 14px 0; border-bottom: 1px solid var(--line); }
.torneo:last-child { border-bottom: 0; }

/* =====================================================================
   Panel de administración: menú lateral
   ===================================================================== */
body.admin { flex-direction: row; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; width: 250px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: #111; color: #ddd; overflow-y: auto;
}
.sidebar-brand { display: block; padding: 22px 22px 18px; color: var(--gold); font-weight: 700; text-decoration: none; font-size: 1.05rem; border-bottom: 1px solid #262626; }
.sidebar-brand span { display: block; color: #8d8d8d; font-weight: 400; font-size: .8rem; letter-spacing: .5px; text-transform: uppercase; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 10px 0 18px; }
.sidebar-group { margin: 18px 22px 6px; font-size: .7rem; text-transform: uppercase; letter-spacing: .8px; color: #7a7a7a; font-weight: 700; }
.sidebar-nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 22px; color: #d6d6d6; text-decoration: none; font-size: .93rem;
  border-left: 3px solid transparent; transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: #1c1c1c; color: #fff; }
.sidebar-nav a.active { background: #1f1c12; color: var(--gold); border-left-color: var(--gold); font-weight: 700; }
.sidebar-count { background: var(--gold); color: #111; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.sidebar-foot { padding: 16px 22px 20px; border-top: 1px solid #262626; color: #8d8d8d; }
.sidebar-foot span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.sidebar-foot-links { display: flex; justify-content: space-between; gap: 10px; font-size: .88rem; }
.sidebar-foot a, .sidebar-foot .link { color: #d6d6d6; text-decoration: none; }
.sidebar-foot a:hover, .sidebar-foot .link:hover { color: var(--gold); }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar { display: none; }
.admin-content { width: 100%; max-width: none; padding: 32px 32px 56px; }   /* listados a todo el ancho */
.admin-content.narrow { max-width: 820px; }

/* Celular / tablet: el menú se abre como cajón */
@media (max-width: 991.98px) {
  body.admin { flex-direction: column; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000; transform: translateX(-100%); transition: transform .25s ease; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; }
  .admin-topbar { display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50; background: #111; color: #fff; padding: 12px 16px; }
  .admin-topbar-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-toggle { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 34px; padding: 0 8px; background: transparent; border: 1px solid #444; border-radius: 6px; cursor: pointer; }
  .sidebar-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; }
  .admin-content { padding: 22px 16px 48px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
.examen { padding: 14px 0; border-bottom: 1px solid var(--line); }
.examen:last-of-type { border-bottom: 0; }

/* Campo «multi» del CRUD: lista de checkboxes con buscador */
.multi-buscar { margin-bottom: 6px; }
.multi-box { max-height: 260px; overflow-y: auto; border: 1px solid var(--line, #e5e5e5); border-radius: 8px; padding: 8px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 16px; }
.multi-box .check { margin: 4px 0; }
