/* VARIABLES CSS GLOBALES */
:root {
  --color-principal: #004080;
  --color-secundario: #0066cc;
  --color-fondo: #f8f9fa;
  --color-texto: #222;
  --color-destacado: #ff6600;
  --color-fondo-seccion: #ffffff;
}

/* ESTILOS GENERALES */
body {
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  background-color: var(--color-fondo);
  color: var(--color-texto);
  margin: 1em;
  font-size: 1rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

h1, h2, h3 {
  color: var(--color-principal);
}

a {
  color: var(--color-secundario);
  text-decoration: none;
}

a:hover {
  color: var(--color-destacado);
  text-decoration: underline;
}

/* CABECERA */
header {
  background-color: var(--color-principal);
  color: white;
  padding: 1em;
  border-radius: 8px;
  text-align: center;
}

/* NAVEGACIÓN PRINCIPAL */
nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
  padding: 0;
}

nav ul li a {
  display: inline-block;
  background-color: var(--color-secundario);
  color: white;
  padding: 0.6em 1em;
  border-radius: 5px;
  transition: background 0.3s;
  font-size: 1em;
}

nav ul li a:hover {
  background-color: var(--color-destacado);
}

/* CONTENIDO PRINCIPAL */
main, section {
  padding: 1em;
  background-color: var(--color-fondo-seccion);
  border-radius: 8px;
  margin: 1em 0;
}

/* PIE DE PÁGINA */
footer {
  background-color: var(--color-principal);
  color: white;
  text-align: center;
  padding: 1em;
  border-radius: 8px;
}

/* BOTONES Y ENLACES INTERACTIVOS */
button, input[type="submit"] {
  display: block;
  margin: 1em auto;
  font-size: 1em;
  padding: 0.6em 1.2em;
  background-color: var(--color-secundario);
  color: white;
  border: none;
  border-radius: 5px;
  transition: background 0.3s;
}

button:hover, input[type="submit"]:hover {
  background-color: var(--color-destacado);
  cursor: pointer;
}

/* FORMULARIOS */
form {
  max-width: 40em;
  margin: 0 auto;
  padding: 1.5em;
  background-color: var(--color-fondo-seccion);
  border: 1px solid #ccc;
  border-radius: 8px;
}

fieldset {
  border: 2px solid var(--color-secundario);
  border-radius: 6px;
  padding: 1em;
  margin-bottom: 1.5em;
}

legend {
  font-weight: bold;
  color: var(--color-principal);
  padding: 0 0.5em;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 12em;
  text-align: right;
  margin-right: 1em;
  font-weight: bold;
  vertical-align: middle;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="color"],
input[type="range"],
select,
textarea {
  width: 60%;
  padding: 0.4em;
  font-size: 1em;
  border: 1px solid #aaa;
  border-radius: 5px;
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: 0.5em;
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--color-destacado);
  background-color: #f0faff;
}

form:focus-within {
  border: 2px solid var(--color-secundario);
  background-color: #f9fcff;
  padding: 10px;
}

/* TABLAS */
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 1em;
  display: block;
  overflow-x: auto;
  border-radius: 6px;
  background-color: #e6f9ff;
}

thead th, tfoot th, caption {
  font-family: Arial, Helvetica, sans-serif;
  color: white;
  text-shadow: 1px 1px 1px black;
}

thead th, tfoot th, tfoot td {
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.5));
}

th, td {
  border: 3px solid #00bfff;
  padding: 10px;
  text-align: center;
}

th {
  letter-spacing: 2px;
}

td {
  letter-spacing: 1px;
}

tfoot th {
  text-align: right;
}

caption {
  font-variant: small-caps;
  margin-bottom: 10px;
}

tbody tr:nth-child(odd) {
  background-color: #c7f2ff;
}

tbody tr:nth-child(even) {
  background-color: #ffffff;
}

tbody tr:hover {
  background-color: white;
}

/* ICONOS */
label::before,
a::before {
  margin-right: 6px;
}

a[href*="index.html"]::before { content: "🏠 "; }
a[href*="contacto"]::before { content: "✉️ "; }
a[href*="buscador"]::before { content: "🔍 "; }
footer a[href*="accesibilidad"]::before { content: "🔒 "; }

.icono {
  font-size: 1.1em;
  margin-right: 6px;
  vertical-align: middle;
}

nav ul li a .icono,
footer a .icono {
  color: inherit;
}

/* Enlace “Saltar al contenido” */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-principal);
  color: white;
  padding: 8px 12px;
  z-index: 100;
  text-decoration: none;
  border-radius: 5px;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 10px;
}

/* DISEÑO ADAPTATIVO */
@media (max-width: 768px) {
  label {
    width: 100%;
    text-align: left;
    margin-bottom: 0.3em;
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="color"],
  input[type="range"],
  select,
  textarea {
    width: 100%;
  }

  fieldset {
    padding: 1em;
  }

  nav ul {
    flex-direction: column;
    align-items: center;
  }

  nav ul li a {
    width: 100%;
    text-align: center;
  }

  main {
    padding: 0.8em;
  }

  table {
    font-size: 0.9em;
  }

  form {
    width: 95%;
  }
}

@media (min-width: 1025px) {
  main {
    padding: 2em;
  }

  table {
    font-size: 1em;
  }
}

/* ==========================
   Layout de dos columnas
   ========================== */
.layout-dos-columnas {
  display: grid;
  grid-template-columns: 1fr 320px; /* principal flexible + lateral fija */
  gap: 1.5rem;
  align-items: start;
  margin: 1em 0;
}

.col-principal {
  min-width: 0; /* evita overflow por contenido largo */
}

.col-lateral {
  background: #f2fbff;
  padding: 1rem;
  border-radius: 8px;
}

/* Asegurar que iframes y figuras se adapten a la columna */
.col-principal iframe,
.col-principal img,
.col-principal figure {
  max-width: 100%;
  height: auto;
}

/* Responsive: pasar a una columna en pantallas pequeñas */
@media (max-width: 900px) {
  .layout-dos-columnas {
    grid-template-columns: 1fr;
  }
  .col-lateral {
    order: 2;
  }
  .col-principal {
    order: 1;
  }
}
