/* ==========================================================================
   Material Design 3 (M3) Design System - Sede Electrónica AGE
   ========================================================================== */

:root {
  /* M3 Color Scheme (Basado en Azul Institucional #003366) */
  --md-sys-color-primary: #003366;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d9e2ff;
  --md-sys-color-on-primary-container: #001943;
  
  --md-sys-color-secondary: #ad1519; /* Rojo Oficial AGE */
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #ffdad6;
  --md-sys-color-on-secondary-container: #410002;

  --md-sys-color-surface: #fdfbff;
  --md-sys-color-on-surface: #1a1c1e;
  --md-sys-color-surface-variant: #e0e2ec;
  --md-sys-color-on-surface-variant: #43474e;
  --md-sys-color-surface-container: #f0f4f9;
  --md-sys-color-surface-container-high: #e9eef6;

  --md-sys-color-outline: #74777f;
  --md-sys-color-outline-variant: #c4c6d0;

  --md-sys-color-success: #198754;
  --md-sys-color-on-success: #ffffff;

  /* M3 Typography */
  --md-sys-typescale-font-main: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  
  /* M3 Shape System */
  --md-sys-shape-corner-small: 8px;
  --md-sys-shape-corner-medium: 12px;
  --md-sys-shape-corner-large: 16px;
  --md-sys-shape-corner-full: 9999px;

  /* M3 Elevation / Shadows */
  --md-sys-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
  --md-sys-elevation-2: 0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
  --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.30);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--md-sys-typescale-font-main);
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ==========================================================================
   Header Institucional
   ========================================================================== */
.header-institucional {
  background-color: var(--md-sys-color-surface);
  border-bottom: 3px solid var(--md-sys-color-secondary);
  padding: 1.25rem 0;
}
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.escudo-marca { display: flex; flex-direction: column; }
.gobierno-espana {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--md-sys-color-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
}
.ministerio-nombre {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}
.sede-subtitulo {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
}

/* M3 Surface Card: Hora Oficial */
.hora-oficial-box {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  padding: 0.75rem 1.25rem;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  text-align: right;
  font-size: 0.85rem;
}
.hora-oficial-box .clock {
  font-weight: 700;
  display: block;
  color: var(--md-sys-color-primary);
}

/* ==========================================================================
   Navegación M3 (Navigation Bar / Navigation Rail Pattern)
   ========================================================================== */
.nav-principal {
  background-color: var(--md-sys-color-surface-container-high);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.nav-menu {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.nav-link {
  display: block;
  padding: 0.6rem 1.2rem;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--md-sys-shape-corner-full);
  transition: background-color 0.2s, color 0.2s;
}
.nav-link:hover {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
}
.nav-item.active .nav-link {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 700;
}

/* ==========================================================================
   Hero & M3 Search Bar
   ========================================================================== */
.hero-home { padding: 2.5rem 0 1rem; }
.hero-home h1 { font-size: 2.25rem; color: var(--md-sys-color-primary); margin-bottom: 0.5rem; }
.hero-lead { font-size: 1.1rem; color: var(--md-sys-color-on-surface-variant); }

.buscador-sede-box { margin: 2rem 0; }
.buscador-sede-box form { display: flex; gap: 0.75rem; }

/* Input M3 Outlined */
.buscador-sede-box input {
  flex: 1;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.buscador-sede-box input:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

/* M3 Filled Button */
.btn-buscar {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 0.9rem 1.75rem;
  border: none;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--md-sys-shape-corner-full);
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-1);
  transition: box-shadow 0.2s, background-color 0.2s;
}
.btn-buscar:hover {
  box-shadow: var(--md-sys-elevation-2);
  background-color: #002244;
}

/* ==========================================================================
   Cards (Tarjetas M3 Contained y Elevated)
   ========================================================================== */
.grid-destacados, .grid-servicios-verificacion {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0 3rem;
}

/* Elevated Card Pattern */
.card-destacado, .item-tramite-card {
  background-color: var(--md-sys-color-surface);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.75rem;
  box-shadow: var(--md-sys-elevation-1);
  border: 1px solid var(--md-sys-color-outline-variant);
  transition: box-shadow 0.2s transform 0.2s;
}
.card-destacado:hover, .item-tramite-card:hover {
  box-shadow: var(--md-sys-elevation-2);
}
.card-destacado h3, .item-tramite-card h2 {
  font-size: 1.25rem;
  color: var(--md-sys-color-primary);
  margin-bottom: 0.5rem;
}

/* Filled Card Pattern */
.card-verificacion {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-large);
  padding: 1.75rem;
}

/* ==========================================================================
   Ficha de Trámites (M3 Surface & Actions)
   ========================================================================== */
.acceso-tramite-box {
  margin: 1.5rem 0;
  padding: 1.75rem;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: var(--md-sys-shape-corner-large);
}
.btn-acceso-tramite {
  display: inline-block;
  background-color: var(--md-sys-color-success);
  color: var(--md-sys-color-on-success);
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--md-sys-shape-corner-full);
  box-shadow: var(--md-sys-elevation-1);
}
.btn-acceso-tramite:hover {
  box-shadow: var(--md-sys-elevation-2);
}

/* M3 Badges & Chips */
.badge-sia, .badge-estado {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--md-sys-shape-corner-small);
  margin-right: 0.5rem;
}
.badge-sia {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
}
.badge-estado {
  background-color: #d1e7dd;
  color: #0f5132;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.footer-institucional {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  padding: 3rem 0 0;
  margin-top: 4rem;
}
.grid-footer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}
.footer-institucional h3 { color: var(--md-sys-color-primary); margin-bottom: 1rem; }
.footer-institucional a { color: var(--md-sys-color-primary); text-decoration: none; }
.footer-institucional a:hover { text-decoration: underline; }
.footer-bottom {
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  padding: 1.25rem 0;
  margin-top: 2.5rem;
  text-align: center;
  font-size: 0.85rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}