@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700;800&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Paleta principal: energética pero legible, pensada para pantalla + pizarra digital */
  --primary: #6d28d9;        /* violeta */
  --primary-dark: #4c1d95;
  --primary-light: #ede9fe;
  --secondary: #0891b2;      /* cian/teal */
  --accent: #f59e0b;         /* ámbar */
  --accent-pink: #ec4899;
  --ok: #16a34a;

  --bg: #f4f5fb;
  --surface: #ffffff;
  --texto: #1e1b2e;
  --texto-suave: #635f77;
  --borde: #e6e3f2;

  --radius: 14px;
  --sombra: 0 4px 14px rgba(76, 29, 149, 0.08);
  --sombra-fuerte: 0 10px 30px rgba(76, 29, 149, 0.18);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.5;
}

/* ---------- Cabecera ---------- */
header {
  flex: 0 0 auto;
  background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 55%, var(--accent-pink) 130%);
  color: white;
  padding: 1.4rem 1.75rem;
  box-shadow: var(--sombra-fuerte);
  position: relative;
  overflow: hidden;
}

header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% -20%, rgba(255,255,255,0.25), transparent 55%);
  pointer-events: none;
}

.titulo-link {
  color: inherit;
  text-decoration: none;
  position: relative;
  z-index: 1;
}

header h1 {
  margin: 0 0 0.2rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  opacity: 0.92;
  font-size: 0.92rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.app-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- Menú lateral ---------- */
#menu-container {
  flex: 0 0 310px;
  max-width: 310px;
  padding: 1.1rem;
  overflow-y: auto;
  border-right: 1px solid var(--borde);
  background: var(--surface);
}

#buscador {
  width: 100%;
  padding: 0.7rem 1rem;
  margin-bottom: 1.2rem;
  border: 2px solid var(--borde);
  border-radius: 999px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

#buscador:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  background: white;
}

#menu ul {
  list-style: none;
  margin: 0;
  padding-left: 1.05rem;
  border-left: 2px solid var(--borde);
}

#menu ul.menu-root {
  padding-left: 0;
  border-left: none;
}

#menu li { margin: 0.25rem 0; }

#menu summary {
  cursor: pointer;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  list-style: revert;
  color: var(--primary-dark);
  transition: background 0.15s;
}

#menu summary:hover { background: var(--primary-light); }

#menu a {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  color: var(--secondary);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

#menu a:hover {
  background: #ecfeff;
  color: #0e7490;
}

#menu a.active {
  background: linear-gradient(120deg, var(--primary), var(--accent-pink));
  color: white;
  font-weight: 700;
  box-shadow: var(--sombra);
}

.folder-link {
  color: inherit;
  text-decoration: none;
}

.folder-link:hover { text-decoration: underline; }

.loading { color: var(--texto-suave); font-style: italic; }

/* ---------- Área de contenido ---------- */
#content-area {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#content-toolbar {
  flex: 0 0 auto;
  padding: 0.6rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--borde);
  text-align: right;
}

#content-toolbar a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: white;
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  transition: transform 0.12s, box-shadow 0.12s;
}

#content-toolbar a:hover {
  transform: translateY(-1px);
  box-shadow: var(--sombra);
}

#content-frame {
  flex: 1 1 auto;
  width: 100%;
  border: 0;
  display: block;
  background: white;
}

/* Colores de acento rotativos para las carpetas de nivel superior (cursos/asignaturas) */
#menu > ul.menu-root > li:nth-child(5n+1) > details > summary { color: var(--primary); }
#menu > ul.menu-root > li:nth-child(5n+2) > details > summary { color: #0e7490; }
#menu > ul.menu-root > li:nth-child(5n+3) > details > summary { color: #b45309; }
#menu > ul.menu-root > li:nth-child(5n+4) > details > summary { color: #be185d; }
#menu > ul.menu-root > li:nth-child(5n+5) > details > summary { color: #15803d; }

@media (max-width: 720px) {
  .app-layout { flex-direction: column; }
  #menu-container {
    flex: 0 0 auto;
    max-width: none;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--borde);
  }
}
