/* ===== VARIABLES CSS ===== */
:root {
  --primary: rgb(65, 66, 245);
  --accent: rgb(193, 250, 59);
  --bg-dark: rgba(0, 0, 0, 0.5);
  --bg-light: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==== ESTILOS BASE ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  background-attachment: fixed;
  color: #fff;
  line-height: 1.7;
  min-height: 100vh;
}

/* ==== HEADER ==== */
header {
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--bg-dark);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  border-bottom: 3px solid rgba(255, 255, 255, 0.3);
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.05) 50%, transparent 70%);
  animation: shine 3s infinite;
}

@keyframes shine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

header h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 700;
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: -0.5px;
}

/* Logo en el header */
header img {
  max-width: 120px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 4px solid rgba(255, 255, 255, 0.3);
  transition: var(--transition);
  animation: float 3s ease-in-out infinite;
}

header img:hover {
  transform: scale(1.05) rotate(5deg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

/* ==== NAV ==== */
nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--bg-light);
  backdrop-filter: blur(10px);
  padding: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

nav a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

nav a:hover::before {
  left: 100%;
}

nav a:hover {
  background: var(--accent);
  color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Iconos pequeños en el nav */
nav img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  box-shadow: none;
  display: inline-block;
  vertical-align: middle;
  filter: brightness(1.2);
}

/* ==== MAIN ==== */
main {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 2.5rem;
  background: var(--bg-dark);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h2 {
  color: var(--accent);
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin-bottom: 1rem;
  font-weight: 700;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
}

h3 {
  color: var(--accent);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  margin-top: 1.5rem;
  margin-bottom: 0.8rem;
  font-weight: 600;
}

p {
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.8;
}

/* ==== CODE BLOCKS ==== */
pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 1.5rem;
  border-radius: 12px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
  margin: 1.5rem 0;
}

code {
  font-family: "Fira Code", "Courier New", monospace;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Código inline */
:not(pre) > code {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ==== LISTAS ==== */
ul, ol {
  margin: 1rem 0 1rem 2rem;
}

li {
  margin-bottom: 0.5rem;
}

/* ==== ENLACES ==== */
a:not(nav a) {
  color: var(--accent);
  text-decoration: underline;
  transition: var(--transition);
}

a:not(nav a):hover {
  color: #fff;
  text-shadow: 0 0 8px var(--accent);
}

/* ==== IMÁGENES ==== */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: var(--transition);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

img:hover {
  transform: scale(1.03);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

/* Imágenes dentro de las secciones */
section img {
  max-width: 80px;
  margin-bottom: 1rem;
  border-radius: 12px;
}

/* ==== TABLAS ==== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
  background: rgba(0, 0, 0, 0.3);
  color: var(--accent);
  font-weight: 600;
}

tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ==== FOOTER ==== */
footer {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-dark);
  backdrop-filter: blur(10px);
  font-size: 0.9rem;
  border-top: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
  margin-top: 3rem;
}

footer p {
  margin: 0;
  opacity: 0.9;
}

/* ==== SCROLLBAR ==== */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ==== RESPONSIVIDAD ==== */

/* Tablets y pantallas medianas */
@media (max-width: 1024px) {
  main {
    max-width: 95%;
    margin: 2rem auto;
    padding: 2rem;
  }
}

/* Tablets pequeñas */
@media (max-width: 768px) {
  header {
    padding: 1.5rem 1rem;
  }

  header h1 {
    font-size: 1.8rem;
  }

  header img {
    max-width: 90px;
  }

  nav {
    gap: 0.6rem;
    padding: 0.8rem 0.5rem;
    position: relative;
    top: 0;
  }

  nav a {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    flex: 1;
    min-width: fit-content;
  }

  nav img {
    width: 18px;
    height: 18px;
  }

  main {
    margin: 1.5rem 0.8rem;
    padding: 1.8rem 1.2rem;
    border-radius: 16px;
  }

  h2 {
    font-size: 1.6rem;
  }

  h3 {
    font-size: 1.3rem;
  }

  pre {
    padding: 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  code {
    font-size: 0.85rem;
  }

  table {
    font-size: 0.9rem;
  }

  th, td {
    padding: 0.8rem;
  }
}

/* Móviles */
@media (max-width: 480px) {
  body {
    font-size: 0.95rem;
  }

  header {
    padding: 1.2rem 0.8rem;
  }

  header h1 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  header img {
    max-width: 80px;
    margin-bottom: 0.8rem;
  }

  nav {
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.6rem 0.4rem;
    position: relative;
  }

  nav a {
    flex: 1;
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 8px;
    justify-content: center;
    gap: 4px;
  }

  nav img {
    width: 16px;
    height: 16px;
    margin-right: 0;
  }

  main {
    margin: 1rem 0.5rem;
    padding: 1.2rem 1rem;
    border-radius: 12px;
  }

  h2 {
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
  }

  h3 {
    font-size: 1.2rem;
    margin-top: 1.2rem;
    margin-bottom: 0.6rem;
  }

  p {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 0.8rem;
  }

  pre {
    padding: 0.8rem;
    font-size: 0.8rem;
    border-radius: 8px;
    margin: 1rem 0;
  }

  code {
    font-size: 0.8rem;
  }

  :not(pre) > code {
    padding: 0.15rem 0.4rem;
    font-size: 0.85em;
  }

  ul, ol {
    margin: 0.8rem 0 0.8rem 1.5rem;
  }

  li {
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
  }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }

  img {
    margin: 1rem auto;
    border-radius: 12px;
  }

  section img {
    max-width: 60px;
  }

  footer {
    padding: 1.2rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Móviles muy pequeños */
@media (max-width: 360px) {
  header h1 {
    font-size: 1.3rem;
  }

  header img {
    max-width: 70px;
  }

  nav {
    padding: 0.5rem 0.3rem;
    gap: 0.3rem;
  }

  nav a {
    padding: 0.5rem 0.4rem;
    font-size: 0.7rem;
    gap: 3px;
  }

  nav img {
    width: 14px;
    height: 14px;
  }

  main {
    margin: 0.8rem 0.4rem;
    padding: 1rem 0.8rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.1rem;
  }

  pre {
    padding: 0.6rem;
    font-size: 0.75rem;
  }

  code {
    font-size: 0.75rem;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.5rem 0.4rem;
  }
}

/* Orientación horizontal en móviles */
@media (max-width: 768px) and (orientation: landscape) {
  header {
    padding: 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  header img {
    max-width: 70px;
    margin-bottom: 0.5rem;
  }

  nav {
    padding: 0.6rem;
  }

  nav a {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  main {
    margin: 1rem;
    padding: 1.5rem;
  }
}

/* Mejoras de accesibilidad táctil */
@media (hover: none) and (pointer: coarse) {
  nav a {
    min-height: 44px; /* Tamaño mínimo recomendado para táctil */
    display: flex;
    align-items: center;
  }

  a:not(nav a) {
    padding: 0.2rem 0;
    display: inline-block;
  }

  button, input, select, textarea {
    min-height: 44px;
  }
}

/* ==== NAV ==== */
nav {
  background: var(--bg-light);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
}

nav {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

nav a::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

nav a:hover::before {
  left: 100%;
}

nav a:hover {
  background: var(--accent);
  color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

nav a:active {
  transform: translateY(-1px);
}

/* Iconos en el nav */
nav img {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  box-shadow: none;
  display: inline-block;
  vertical-align: middle;
  filter: brightness(1.2);
  flex-shrink: 0;
}

/* ==== RESPONSIVIDAD NAV ==== */

/* Tablets */
@media (max-width: 768px) {
  nav {
    padding: 0.8rem 1rem;
    gap: 0.8rem;
  }

  nav a {
    padding: 0.65rem 1.2rem;
    font-size: 0.9rem;
  }

  nav img {
    width: 18px;
    height: 18px;
  }
}

/* Móviles */
@media (max-width: 480px) {
  nav {
    padding: 0.7rem 0.5rem;
    gap: 0.5rem;
  }

  nav a {
    flex: 1 1 auto;
    padding: 0.7rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 10px;
    gap: 6px;
    min-width: 0;
  }

  nav img {
    width: 18px;
    height: 18px;
  }
}

/* Móviles muy pequeños */
@media (max-width: 380px) {
  nav {
    padding: 0.6rem 0.4rem;
    gap: 0.4rem;
  }

  nav a {
    flex: 1 1 0;
    padding: 0.7rem 0.4rem;
    font-size: 0.75rem;
    gap: 4px;
    flex-direction: column;
  }

  nav img {
    width: 20px;
    height: 20px;
    margin: 0;
  }
}

/* Orientación horizontal en móviles */
@media (max-width: 768px) and (orientation: landscape) {
  nav {
    padding: 0.5rem 1rem;
  }

  nav a {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
}

/* Mejoras de accesibilidad táctil */
@media (hover: none) and (pointer: coarse) {
  nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}