/* =========================================================================
   DZR Kodenkan — Sistema de Academia
   Dirección visual: "el tatami al anochecer" — fondo carbón azulado como
   el mat de entrenamiento después de horas, acentos tomados directo del
   sistema de cinturones (no son decoración, son el propio dato) y un
   titular estilo mincho japonés para dar carácter de rótulo de dojo.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@500;700;800&family=Work+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Paleta */
  --bg:            #12151b;
  --bg-elevated:   #181c24;
  --surface:       #1e232c;
  --surface-2:     #262c37;
  --border:        #323a47;
  --text:          #edeff2;
  --text-muted:    #9aa3b2;
  --text-faint:    #5f6878;

  --accent:        #b8452f;   /* vermellón "obi rojo" — color de marca */
  --accent-hover:  #cc5138;
  --accent-soft:   rgba(184, 69, 47, .14);
  --gold:          #c9a227;   /* bronce "medalla" — logros / destacados */
  --gold-soft:     rgba(201, 162, 39, .14);

  --success:       #4c9a6a;
  --success-soft:  rgba(76, 154, 106, .14);
  --danger:        #c1463a;
  --danger-soft:   rgba(193, 70, 58, .14);

  /* Colores reales de cinturón — se usan como dato, no como paleta libre */
  --belt-blanco:    #f5f5f0;
  --belt-amarillo:  #e7c53e;
  --belt-naranja:   #e08a3c;
  --belt-azul:      #3c72c9;
  --belt-verde:     #4c9a4f;
  --belt-marron:    #7a4a2b;
  --belt-negro:     #1a1a1a;
  --belt-rojoblanco: linear-gradient(90deg, #c1463a 50%, #f5f5f0 50%);
  --belt-rojo:      #c1463a;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,.28);
  --font-display: "Shippori Mincho", serif;
  --font-body: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
  margin: 0 0 .5rem;
  color: var(--text);
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .75rem; color: var(--text-muted); }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Layout general con sidebar ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar__brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }
.sidebar__brand span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.15;
}

.sidebar__section-label {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 1rem 1.1rem .35rem;
}

.sidebar nav { flex: 1; overflow-y: auto; padding-bottom: 1rem; }

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .62rem 1.1rem;
  color: var(--text-muted);
  font-size: .92rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar a.nav-link:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.sidebar a.nav-link.active {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.sidebar__user {
  border-top: 1px solid var(--border);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: .72rem; color: var(--text-faint); text-transform: capitalize; }
.sidebar__logout { color: var(--text-faint); }
.sidebar__logout:hover { color: var(--danger); }

.main {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2rem 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; }
.topbar__meta { color: var(--text-faint); font-size: .85rem; }

/* Botón hamburguesa (solo visible en móvil) */
.menu-toggle {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
  cursor: pointer;
}

/* ---------- Cards / superficies ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.stat-card .value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.stat-card .label { color: var(--text-faint); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stat-card.accent { border-color: var(--accent); }
.stat-card.accent .value { color: var(--accent); }
.stat-card.gold .value { color: var(--gold); }

/* ---------- Formularios ---------- */
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 .3rem;
}
input, select, textarea {
  width: 100%;
  padding: .62rem .75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .92rem;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field { margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .62rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: filter .15s, background .15s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left;
  background: var(--surface-2);
  color: var(--text-faint);
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .06em;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }

/* ---------- Insignia de cinturón (elemento firma) ---------- */
.obi {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
}
.obi__swatch {
  width: 26px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.35);
  flex-shrink: 0;
}
.obi-strip {
  display: flex;
  height: 8px;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
  margin: .4rem 0 .1rem;
}
.obi-strip__fill { height: 100%; transition: width .4s ease; }

/* ---------- Badges / etiquetas ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); }

/* ---------- Alertas / flash messages ---------- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: .88rem;
  margin-bottom: 1rem;
}
.alert-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: var(--danger); color: #e08277; }
.alert-info { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }

/* ---------- Avatares ---------- */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.avatar-lg { width: 96px; height: 96px; font-size: 1.6rem; }

/* ---------- Login ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 10%, rgba(184,69,47,.10), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(201,162,39,.08), transparent 45%),
    var(--bg);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
}
.auth-card__brand { text-align: center; margin-bottom: 1.5rem; }
.auth-card__brand img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; margin-bottom: .75rem; }
.auth-card__brand h1 { font-size: 1.25rem; }
.auth-card__brand p { font-size: .8rem; margin: 0; }

/* ---------- Perfil de estudiante ---------- */
.profile-hero {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.profile-hero__details { flex: 1; min-width: 200px; }
.profile-hero__belt { color: var(--text-faint); font-size: .85rem; margin-top: .15rem; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
}
.detail-grid dt { color: var(--text-faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; margin-top: .8rem; }
.detail-grid dd { margin: .15rem 0 0; font-size: .95rem; }

/* ---------- Técnicas ---------- */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.tech-category h3 {
  color: var(--gold);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-family: var(--font-body);
  font-weight: 700;
  margin-bottom: .6rem;
}
.tech-list { list-style: none; margin: 0; padding: 0; }
.tech-list li {
  padding: .55rem .1rem;
  border-bottom: 1px dashed var(--border);
  font-size: .88rem;
}
.tech-list li:last-child { border-bottom: none; }
.tech-list a { color: var(--text); font-weight: 600; }
.tech-list .desc { display: block; color: var(--text-muted); font-size: .82rem; margin-top: .1rem; }

/* ---------- Utilidades ---------- */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 1rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 1rem !important; }
.flex { display: flex; }
.gap-1 { gap: .6rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-faint);
}
.search-bar { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.search-bar input[type="text"] { flex: 1; min-width: 220px; }
.search-bar select { width: auto; min-width: 160px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 40;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .main { padding: 1.1rem 1rem 3rem; }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 30;
  }
  .sidebar-backdrop.open { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
