/* ============================================================
   HEADER STYLES — Ayuntamiento de Zitácuaro
   ============================================================ */

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

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

:root {
  --color-vino:      #7B1034;
  --color-vino-dark: #5a0b25;
  --color-white:     #ffffff;
  --color-bg:        #ffffff;
  --nav-height:      70px;
  --ease:            0.22s ease;
}

body { padding-top: var(--nav-height); }

/* ── Header ── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--color-bg);
  border-bottom: 3px solid var(--color-vino);
  box-shadow: 0 2px 12px rgba(123,16,52,.10);
  font-family: 'Montserrat', sans-serif;
}
.header-inner {
  display: flex; align-items: center;
  height: var(--nav-height);
  max-width: 1280px; margin: 0 auto; padding: 0 24px; gap: 8px;
}

/* ── Logo ── */
.header-logo {
  display: flex; align-items: center;
  flex-shrink: 0; margin-right: auto; text-decoration: none;
}
.header-logo img { height: 62px; width: auto; display: block; }

/* ── Nav escritorio ── */
.nav-main {
  display: flex; align-items: center;
  list-style: none; height: 100%; gap: 0;
}
.nav-main > li {
  position: relative; height: 100%;
  display: flex; align-items: center;
}
.nav-main > li > a {
  display: flex; align-items: center; gap: 5px;
  padding: 0 13px; height: 100%;
  color: var(--color-vino); text-decoration: none;
  font-size: 12px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -3px;
  transition: background var(--ease), border-color var(--ease);
}
.nav-main > li > a:hover,
.nav-main > li.active > a {
  background: rgba(123,16,52,.06);
  border-bottom-color: var(--color-vino);
}

/* Caret */
.caret {
  display: inline-block; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--ease); flex-shrink: 0;
}
.nav-main > li:hover > a .caret,
.nav-main > li.open  > a .caret { transform: rotate(180deg); }

/* ── Dropdowns ── */
/* SIEMPRE oculto por defecto */
.dropdown-menu {
  display: none;
  list-style: none;
  /* escritorio: absoluto */
  position: absolute;
  top: calc(var(--nav-height) - 3px); left: 0;
  min-width: 240px;
  background: var(--color-white);
  border-top: 3px solid var(--color-vino);
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
  border-radius: 0 0 4px 4px;
  z-index: 9999;
  animation: fadeDown .17s ease;
}
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Submenú nivel 2 */
.dropdown-submenu { position: relative; }
.dropdown-submenu > .dropdown-menu {
  top: 0; left: 100%; margin-left: 2px;
  border-radius: 0 4px 4px 4px;
}

/* ESCRITORIO: hover abre el menú */
@media (min-width: 992px) {
  .nav-main > li:hover    > .dropdown-menu { display: block; }
  .dropdown-submenu:hover > .dropdown-menu { display: block; }
}

/* MÓVIL: clase .open (añadida por JS) abre el menú */
.nav-main > li.open    > .dropdown-menu { display: block; }
.dropdown-submenu.open > .dropdown-menu { display: block; }

/* Items del dropdown */
.dropdown-menu > li > a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  color: var(--color-vino); text-decoration: none;
  font-size: 12px; font-weight: 500;
  border-left: 3px solid transparent;
  white-space: normal; word-break: break-word;
  transition: background var(--ease), border-color var(--ease), padding var(--ease);
}
.dropdown-menu > li > a:hover,
.dropdown-menu > li.open > a {
  background: rgba(123,16,52,.06);
  border-left-color: var(--color-vino);
}
.dropdown-menu .divider { height: 1px; background: rgba(123,16,52,.13); margin: 3px 0; }

/* Flecha submenú */
.dropdown-submenu > a::after {
  content: '›'; font-size: 16px; margin-left: 10px; flex-shrink: 0;
  transition: transform var(--ease);
}
.dropdown-submenu:hover > a::after,
.dropdown-submenu.open  > a::after { transform: rotate(90deg); }

/* ── Sociales / Iconos ── */
.nav-social {
  display: flex; align-items: center; gap: 2px;
  margin-left: 8px; padding-left: 10px;
  border-left: 1px solid rgba(123,16,52,.18); flex-shrink: 0;
}
.social-link, .nav-icon-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--color-vino); text-decoration: none; font-size: 14px;
  transition: background var(--ease), transform var(--ease);
}
.social-link:hover   { background: rgba(123,16,52,.09); transform: scale(1.12); }
.nav-icon-link:hover { background: rgba(123,16,52,.09); }

/* ── Hamburguesa ── */
.navbar-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; padding: 8px;
  background: none; border: 2px solid rgba(123,16,52,.25); border-radius: 6px;
  cursor: pointer; flex-shrink: 0; transition: border-color var(--ease);
}
.navbar-toggle:hover { border-color: var(--color-vino); }
.navbar-toggle .icon-bar {
  display: block; width: 20px; height: 2px;
  background: var(--color-vino); border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease; transform-origin: center;
}
.navbar-toggle[aria-expanded="true"] .icon-bar:nth-child(1){ transform: translateY(7px)  rotate(45deg); }
.navbar-toggle[aria-expanded="true"] .icon-bar:nth-child(2){ opacity: 0; transform: scaleX(0); }
.navbar-toggle[aria-expanded="true"] .icon-bar:nth-child(3){ transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   MÓVIL ≤ 991px
   ============================================================ */
@media (max-width: 991px) {

  .navbar-toggle { display: flex; }

  .header-inner {
    flex-wrap: wrap; height: auto;
    padding: 8px 14px; gap: 0; align-items: center;
  }
  .header-logo { flex: 1; margin-right: 0; }
  .header-logo img { height: 48px; }
  .nav-social { border-left: none; padding-left: 0; margin-left: 0; margin-right: 6px; }

  /* Nav: oculto por defecto, visible con .open */
  .nav-main {
    display: none; flex-direction: column; align-items: stretch;
    width: 100%; height: auto; gap: 0;
    border-top: 1px solid rgba(123,16,52,.12);
    padding: 4px 0 12px;
    max-height: calc(100dvh - 80px);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .nav-main.open { display: flex; }

  /* Items nivel 1 */
  .nav-main > li { height: auto; display: block; border-bottom: 1px solid rgba(123,16,52,.07); }
  .nav-main > li:last-child { border-bottom: none; }
  .nav-main > li > a {
    height: auto; padding: 13px 16px; width: 100%;
    border-bottom: none !important; border-left: 4px solid transparent;
    margin-bottom: 0; font-size: 13px;
    display: flex; justify-content: space-between;
  }
  .nav-main > li > a:hover { background: transparent; border-bottom-color: transparent; }
  .nav-main > li.open > a {
    border-left-color: var(--color-vino) !important;
    background: rgba(123,16,52,.05) !important;
  }

  /* Dropdowns en móvil: ESTÁTICOS (sin posición absoluta) */
  .dropdown-menu {
    position: static !important;
    left: auto !important; top: auto !important;
    width: 100% !important; min-width: 0 !important;
    box-shadow: none !important; border-radius: 0 !important;
    border-top: none !important;
    border-left: 3px solid rgba(123,16,52,.2) !important;
    margin: 0 0 0 16px !important; padding: 0 !important;
    animation: none !important;
    background: rgba(123,16,52,.02);
  }
  .dropdown-submenu > .dropdown-menu { margin-left: 12px !important; }

  .dropdown-menu > li > a { padding: 11px 14px; font-size: 12px; white-space: normal; }
  .dropdown-menu > li > a:hover,
  .dropdown-menu > li.open > a { padding-left: 14px !important; background: rgba(123,16,52,.06); }
}

@media (max-width: 400px) { .header-logo img { height: 40px; } }