/* ============================================
   Responsive Navigation — ICAC Portal
   Breakpoint: 1280px (matches .max-w-[1280px])
   ============================================ */

/* ── Hamburger Button ── */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.15s;
}
.mobile-menu-btn:hover {
  background-color: #f4f4f5;
}
.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  color: #0a0a0a;
}
.mobile-menu-btn .icon-close {
  display: none;
}
.mobile-menu-btn.is-active .icon-hamburger {
  display: none;
}
.mobile-menu-btn.is-active .icon-close {
  display: block;
}

/* ── Mobile Drawer ── */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
}
.mobile-nav-drawer.is-open {
  visibility: visible;
  opacity: 1;
}
.mobile-nav-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.mobile-nav-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: calc(100% - 48px);
  max-width: 400px;
  height: 100%;
  background: #fff;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
}
.mobile-nav-drawer.is-open .mobile-nav-panel {
  transform: translateX(0);
}

/* ── Drawer Header ── */
.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.mobile-nav-header__title {
  font-size: 16px;
  font-weight: 600;
  color: #0a0a0a;
  margin: 0;
}
.mobile-nav-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  color: #525252;
  transition: background-color 0.15s;
}
.mobile-nav-close:hover {
  background-color: #f4f4f5;
}

/* ── Drawer Menu Items ── */
.mobile-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mobile-nav-item {
  border-bottom: 1px solid #f3f4f6;
}
.mobile-nav-item__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: #0a0a0a;
  text-decoration: none;
  transition: background-color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Inter', sans-serif;
}
.mobile-nav-item__link:hover {
  background-color: #f9fafb;
}
.mobile-nav-item__link svg {
  width: 16px;
  height: 16px;
  color: #a3a3a3;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.mobile-nav-item.is-open > .mobile-nav-item__link svg {
  transform: rotate(180deg);
  color: #b91c1c;
}

/* ── Drawer Sub-menu ── */
.mobile-nav-sub {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0 0 8px 0;
  background: #f9fafb;
}
.mobile-nav-item.is-open > .mobile-nav-sub {
  display: block;
}
.mobile-nav-sub > li > a {
  display: block;
  padding: 10px 20px 10px 36px;
  font-size: 14px;
  font-weight: 400;
  color: #525252;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.mobile-nav-sub > li > a:hover {
  background-color: #f3f4f6;
  color: #0a0a0a;
}
.mobile-nav-sub__heading {
  padding: 10px 20px 4px 36px;
  font-size: 12px;
  font-weight: 600;
  color: #a3a3a3;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Drawer CTA ── */
.mobile-nav-cta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
}
.mobile-nav-cta a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s;
}
.mobile-nav-cta__sede {
  background: #b91c1c;
  color: #fafafa;
}
.mobile-nav-cta__sede:hover {
  background: #991b1b;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */

/* ── Below 1280px: Show hamburger, hide desktop nav ── */
@media (max-width: 1279px) {
  .mobile-menu-btn {
    display: flex;
  }
  .mobile-nav-drawer {
    display: block;
  }

  /* Hide the desktop megamenu nav bar entirely */
  .block-menu.navigation,
  .icac-main-nav {
    display: none !important;
  }
  
  /* Hide the entire dark nav bar region (primary_menu) */
  .region-primary-menu,
  .site-header > nav,
  header > .region-primary-menu {
    display: none !important;
  }
  
  /* Also hide by bg color class — the dark bar */
  .bg-\\[\\#0a0a0a\\] {
    display: none !important;
  }

  /* Adjust header layout */
  [id*="branding"] > div:first-child {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Hide search button text, keep icon */
  .search-trigger-btn {
    font-size: 0;
    gap: 0 !important;
  }
  .search-trigger-btn > div {
    font-size: 16px; /* Reset for icon container */
  }
}

/* ── Below 1024px: Two-line header ── */
@media (max-width: 1023px) {
  /* Header bar: allow wrapping into 2 rows */
  #icac-header-bar {
    height: auto !important;
    padding: 10px 16px !important;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  /* Shrink government logo */
  #logo-gobierno {
    width: 140px !important;
    height: 40px !important;
    margin-right: 4px !important;
  }
  /* Shrink ICAC logo */
  #logo-icac {
    width: 180px !important;
    height: 40px !important;
  }

  /* ── Right side actions wrapper ── */
  #icac-header-actions {
    display: flex !important;
    gap: 8px !important;
  }

  /* Hide Sede Electrónica completely */
  .bg-base-primary {
    display: none !important;
  }

  /* ── Language selector: compact (flag + 3 letters) ── */
  .lang-selector {
    display: inline-block !important;
    order: 2;
    margin-left: 0;
  }
  .lang-selector__trigger-text {
    display: none !important;
  }
  .lang-selector__trigger {
    gap: 0 !important;
    padding: 6px !important;
  }
  .lang-selector__trigger-chevron {
    display: none !important;
  }

  /* Hamburger menu takes order 3 */
  .mobile-menu-btn {
    order: 3;
    margin-left: 0 !important;
  }

  /* ── Search: Icon only on Row 1 ── */
  #icac-header-search {
    order: 1;
    flex: 0 0 auto !important;
    width: auto;
    margin: 0;
  }
  .search-trigger-btn {
    font-size: 0 !important;
    width: 36px !important;
    min-width: 36px !important;
    justify-content: center !important;
    padding: 8px !important;
    gap: 0 !important;
    border-radius: 6px;
  }
  .search-trigger-btn > div {
    margin-left: 0 !important;
  }
}

/* ── Below 768px: Mobile refinements ── */
@media (max-width: 767px) {
  /* Tighter header padding */
  #icac-header-bar {
    padding: 8px 12px !important;
    gap: 6px;
  }

  /* Even smaller logos */
  #logo-gobierno {
    width: 110px !important;
    height: 32px !important;
    margin-right: 4px !important;
  }
  #logo-icac {
    width: 140px !important;
    height: 32px !important;
  }

  /* Lang: flag only, hide text entirely */
  .lang-selector__trigger-text {
    display: none !important;
  }
  .lang-selector__trigger-chevron {
    display: none !important;
  }
  .lang-selector__trigger {
    padding: 4px !important;
  }
  .lang-selector__trigger-flag {
    width: 20px !important;
    height: 20px !important;
  }

  /* Mobile drawer full width */
  .mobile-nav-panel {
    max-width: 100%;
  }
}

/* ── Below 480px: Tiny screens ── */
@media (max-width: 479px) {
  #icac-header-bar {
    padding: 6px 8px !important;
  }
  #logo-gobierno {
    width: 90px !important;
    height: 28px !important;
  }
  #logo-icac {
    width: 115px !important;
    height: 28px !important;
  }
}

/* ── Prevent body scroll when drawer is open ── */
body.mobile-nav-open {
  overflow: hidden;
}
