/* ============================================================
   PORTAL DE DATOS ABIERTOS - VERSION FINAL RESPONSIVA
   Estilo: Clean Professional + Colorful Pro Cards
   ============================================================ */

:root {
  --navy: #0B3B60;
  --pink: #CE1D81;
  --orange: #faa21b;
  --green: #00ae6f;
  --bg-explorer: #f8fafc;
  --text-dark: #1e293b;
  --text-grey: #64748b;
}

/* --- ESTRUCTURA BASE --- */
.main-col {
  background-color: var(--bg-explorer) !important;
  padding: 40px 24px 100px 24px !important;
  font-family: 'Poppins', sans-serif;
}

.dh-explorer-container {
  max-width: 1300px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr; /* Sidebar fija a la izquierda */
  gap: 40px;
}

/* --- RESPONSIVE: TABLETS Y MÓVILES --- */
@media (max-width: 992px) {
  .dh-explorer-container {
    grid-template-columns: 1fr; /* Una sola columna en móvil */
    gap: 20px;
  }

  .dh-sidebar {
    position: relative !important;
    top: 0 !important;
    margin-bottom: 20px;
  }

  .dh-tabs {
    flex-direction: row !important; /* Pestañas horizontales en móvil */
    overflow-x: auto; /* Scroll horizontal */
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }

  .dh-tab {
    white-space: nowrap; /* Que no se corten las palabras */
    flex: 0 0 auto;
    border-left: none !important;
    border-bottom: 4px solid transparent; /* Acento abajo en lugar de lado */
  }

  /* Cambio de acento de lado a abajo para móvil */
  .dh-tab.is-active {
    transform: none !important;
    border-bottom-color: var(--navy);
  }
  
  .dh-tab[data-tab="convocatorias"].is-active { border-bottom-color: var(--pink); }
  .dh-tab[data-tab="publicaciones"].is-active { border-bottom-color: var(--green); }
  .dh-tab[data-tab="reglamentos"].is-active { border-bottom-color: var(--orange); }
}

/* --- SIDEBAR (ESCRITORIO) --- */
.dh-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
}

.dh-tag-mini {
  font-size: 11px; font-weight: 800; color: var(--navy);
  text-transform: uppercase; letter-spacing: 1.5px;
  background: rgba(11, 59, 96, 0.08);
  padding: 5px 12px; border-radius: 50px;
}

.dh-sidebar__title {
  font-size: 26px; font-weight: 800; color: var(--navy);
  margin: 15px 0 25px;
}

.dh-tabs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dh-tab {
  border: none; background: #fff; padding: 16px 20px;
  border-radius: 18px; display: flex; align-items: center; gap: 14px;
  font-size: 15px; font-weight: 700; color: var(--text-grey);
  cursor: pointer; transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,0.02);
  border-left: 5px solid transparent;
}

.dh-tab.is-active {
  background: #fff; transform: translateX(10px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.06);
}

/* --- CONTENIDO PRINCIPAL --- */
.dh-title-main { font-size: 34px; font-weight: 800; color: var(--navy); letter-spacing: -1px; margin: 4px 0; }

@media (max-width: 600px) {
  .dh-title-main { font-size: 26px; }
  .dh-card { padding: 15px !important; gap: 15px !important; }
  .dh-ico { width: 40px !important; height: 40px !important; }
  .dh-card h5 { font-size: 14px !important; }
}

.dh-grid { display: flex; flex-direction: column; gap: 14px; }

.dh-card {
  background: #ffffff; border-radius: 20px; padding: 18px 28px;
  display: flex; align-items: center; gap: 24px;
  border: 1px solid rgba(0,0,0,0.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
  transition: all 0.3s ease; cursor: pointer;
}

.dh-card:hover { transform: scale(1.015); box-shadow: 0 15px 35px rgba(0,0,0,0.06); }

.dh-ico {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Colores de Iconos */
.dh-card:nth-child(4n+1) .dh-ico { background: rgba(206, 29, 129, 0.1); color: var(--pink); }
.dh-card:nth-child(4n+2) .dh-ico { background: rgba(0, 174, 111, 0.1); color: var(--green); }
.dh-card:nth-child(4n+3) .dh-ico { background: rgba(250, 162, 27, 0.1); color: var(--orange); }
.dh-card:nth-child(4n+4) .dh-ico { background: rgba(11, 59, 96, 0.1); color: var(--navy); }

.dh-body { flex: 1; display: flex; align-items: center; justify-content: space-between; min-width: 0; }
.dh-card h5 { font-size: 16px; font-weight: 700; color: var(--text-dark); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dh-row { display: flex; align-items: center; gap: 15px; flex-shrink: 0; }

.dh-badge {
  font-size: 10px; font-weight: 800; padding: 5px 10px;
  border-radius: 8px; text-transform: uppercase;
}
.dh-badge.pdf { background: var(--pink); color: #fff; }
.dh-badge.xls { background: var(--green); color: #fff; }
.dh-badge.csv { background: var(--orange); color: #fff; }

/* En móvil ocultamos el texto del año si no cabe */
@media (max-width: 480px) {
  .dh-mini { display: none; }
}

/* ============================================================
   EL MODAL (RESPONSIVO Y LIMPIO)
   ============================================================ */

.dh-modal {
  position: fixed; inset: 0; z-index: 99999;
  display: none; align-items: center; justify-content: center; padding: 15px;
}

.dh-modal.is-open { display: flex; }

/* Overlay sobrio con Blur */
.dh-modal__overlay {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.75); 
  backdrop-filter: blur(10px);
}

.dh-modal__panel {
  position: relative; width: 100%; max-width: 1000px;
  max-height: 90vh; background: #ffffff;
  border-radius: 32px; 
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn 0.4s ease;
}

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

.dh-modal__header {
  padding: 20px 30px; border-bottom: 1px solid #f1f5f9;
  display: flex; justify-content: space-between; align-items: center;
}

.dh-modal__title { font-size: 18px; font-weight: 800; color: var(--navy); margin: 0; }

.dh-modal__close {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: #f1f5f9; color: var(--navy);
  cursor: pointer; font-size: 16px;
}

.dh-modal__body { padding: 20px; }

.dh-preview {
  width: 100%; height: 50vh; border-radius: 20px;
  background: #fafafa; border: 1px solid #eee; overflow: hidden;
}

.dh-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

@media (max-width: 600px) {
  .dh-modal__panel { border-radius: 20px; }
  .dh-modal__header { padding: 15px 20px; }
  .dh-actions { flex-direction: column; } /* Botones uno sobre otro en móvil */
  .dh-btn { text-align: center; width: 100%; }
}

.dh-btn {
  padding: 12px 24px; border-radius: 14px;
  font-size: 14px; font-weight: 700; text-decoration: none;
  transition: 0.3s;
}

.dh-btn.primary { background: var(--navy); color: #fff; }
.dh-btn:not(.primary) { background: #fff; border: 1px solid #ddd; color: var(--text-grey); }
/* ===========================
   PATCH RESPONSIVE (sin rediseño)
   PÉGALO AL FINAL
   =========================== */

/* 0) Evitar scroll horizontal por desbordes */
html, body { max-width: 100%; overflow-x: hidden; }

/* 1) Padding principal fluido (mismo look, mejor escala) */
.main-col{
  padding: clamp(20px, 4vw, 40px) clamp(14px, 3vw, 24px) clamp(70px, 8vw, 100px) clamp(14px, 3vw, 24px) !important;
}

/* 2) Contenedor: sidebar no se “ahorca” y colapsa antes */
.dh-explorer-container{
  max-width: min(1300px, 100%);
  gap: clamp(18px, 4vw, 40px);
  grid-template-columns: minmax(240px, 280px) 1fr;
}

@media (max-width: 1024px){
  .dh-explorer-container{ grid-template-columns: 1fr; }
}

/* 3) Sidebar sticky: top fluido (no tapa contenido) */
.dh-sidebar{
  top: clamp(80px, 10vh, 120px);
}

/* 4) Título principal: fluido (tu mismo tamaño pero adaptable) */
.dh-title-main{
  font-size: clamp(24px, 4.5vw, 34px);
}

/* 5) Cards: que no se rompan en móvil (sin cambiar diseño) */
.dh-card{
  padding: clamp(14px, 3vw, 18px) clamp(16px, 4vw, 28px);
  gap: clamp(12px, 3vw, 24px);
}

/* Icono fluido */
.dh-ico{
  width: clamp(40px, 8vw, 52px);
  height: clamp(40px, 8vw, 52px);
}

/* IMPORTANTÍSIMO: permitir que el contenido se ajuste */
.dh-body{ min-width: 0; gap: 12px; }

/* Mantén tu ellipsis en desktop, pero en móvil deja 2 líneas */
@media (max-width: 600px){
  .dh-card h5{
    white-space: normal !important;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* Si en pantallas pequeñas los badges no caben, que bajen sin romper */
@media (max-width: 520px){
  .dh-body{
    flex-direction: column;
    align-items: flex-start;
  }
  .dh-row{
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* 6) Tabs móvil: scroll horizontal suave (igual que ya tienes, pero mejor) */
@media (max-width: 992px){
  .dh-tabs{
    gap: 10px;
    scroll-snap-type: x mandatory;
  }
  .dh-tab{
    scroll-snap-align: start;
    padding: 14px 16px;
  }
}

/* 7) Modal: más usable en móvil sin tocar estilos */
.dh-modal__panel{
  max-width: min(1000px, 100%);
  max-height: 92vh;
}

.dh-preview{
  height: clamp(40vh, 50vh, 60vh);
}

@media (max-width: 600px){
  .dh-modal__header{ padding: 15px 20px; }
  .dh-actions{ flex-direction: column; }
  .dh-btn{ width: 100%; text-align: center; }
}

/* 8) Reduce motion (opcional, no cambia diseño) */
@media (prefers-reduced-motion: reduce){
  .dh-card, .dh-tab, .dh-modal__panel{ transition: none !important; animation: none !important; }
  .dh-card:hover{ transform: none !important; }
}
/* =========================================
   MEGA RESPONSIVE SOLO PARA OPCIONES IZQUIERDA
   (dh-tabs / dh-tab / sidebar)
   PÉGALO AL FINAL
   ========================================= */

/* Sidebar: que no se sienta “pesada” en móvil */
@media (max-width: 1024px){
  .dh-sidebar{
    margin-bottom: 12px;
  }
  .dh-sidebar__title{
    font-size: clamp(18px, 5vw, 24px);
    margin: 10px 0 14px;
  }
}

/* Tabs: en móvil que puedan WRAP a 2 filas (mejor que solo scroll) */
@media (max-width: 1024px){
  .dh-tabs{
    flex-direction: row !important;
    flex-wrap: wrap;                 /* ✅ CLAVE: se van a 2 filas */
    gap: 10px;
    overflow: visible;               /* ✅ ya no fuerza scroll siempre */
    padding-bottom: 0;
  }

  /* cada tab como “chip” compacto pero igual look */
  .dh-tab{
    flex: 1 1 160px;                 /* ✅ mínimo 160px, se acomodan */
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
    justify-content: center;         /* se ven parejitas */
    text-align: center;
  }

  /* el acento abajo (como ya lo tienes) */
  .dh-tab{
    border-left: none !important;
    border-bottom: 4px solid transparent;
  }
  .dh-tab.is-active{
    transform: none !important;
    border-bottom-color: var(--navy);
  }
  .dh-tab[data-tab="convocatorias"].is-active{ border-bottom-color: var(--pink); }
  .dh-tab[data-tab="publicaciones"].is-active{ border-bottom-color: var(--green); }
  .dh-tab[data-tab="reglamentos"].is-active{ border-bottom-color: var(--orange); }
}

/* Extra: para pantallas MUY chicas (320-380px) -> 1 por fila, tocable */
@media (max-width: 420px){
  .dh-tabs{
    gap: 8px;
  }
  .dh-tab{
    flex: 1 1 100%;                  /* ✅ una por fila */
    padding: 12px 12px;
    font-size: 13px;
  }
}

/* Si quieres que en tablets (600-900) queden 2 por fila bonito */
@media (min-width: 600px) and (max-width: 1024px){
  .dh-tab{
    flex: 1 1 calc(50% - 10px);      /* ✅ 2 columnas */
  }
}

/* Opcional: si hay MUCHAS tabs, activa scroll HORIZONTAL SOLO en pantallas ultra chicas */
@media (max-width: 360px){
  .dh-tabs{
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
  }
  .dh-tab{
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }
}
/* ===== FIX: PREVIEW DEL MODAL (PDF/IMG) ===== */

/* el contenedor ya tiene height, solo hay que forzar que el contenido llene */
.dh-preview{
  position: relative;
  width: 100%;
  height: 50vh;           /* el que ya usas */
  overflow: hidden;
}

/* PDF */
.dh-preview iframe{
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  display: block;
}

/* Imágenes */
.dh-preview img{
  width: 100%;
  height: 100%;
  object-fit: contain;    /* para que se vea completo */
  display: block;
}

/* (Opcional) en móvil, un poquito más alto */
@media (max-width: 600px){
  .dh-preview{ height: 60vh; }
}
/* --- RESPONSIVE MENU FIX --- */
@media (max-width: 992px) {
  /* 1. Botón Hamburguesa: Siempre visible y por encima de todo */
  .topbar__toggle {
    display: block !important;
    position: relative !important;
    z-index: 9999999 !important; /* El nivel más alto */
    background: transparent;
  }

  /* Animación a "X" cuando está abierto */
  .topbar__toggle[aria-expanded="true"] .top {
    transform: translateY(5px) rotate(45deg);
    transform-origin: center;
  }
  .topbar__toggle[aria-expanded="true"] .middle {
    opacity: 0;
  }
  .topbar__toggle[aria-expanded="true"] .bottom {
    transform: translateY(-5px) rotate(-45deg);
    transform-origin: center;
  }
  .topbar__toggle .line {
    transition: all 0.3s ease;
    stroke: var(--blue, #0056b3);
  }

  /* 2. El Menú Lateral (Panel) */
  #topbar-links.topbar__links {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    
    position: fixed !important;
    top: 0 !important;
    right: -100% !important; /* Escondido */
    width: 280px !important;
    height: 100vh !important;
    background: #ffffff !important;
    z-index: 9999998 !important; /* Justo debajo del botón */
    padding: 80px 20px 40px 20px !important;
    box-shadow: -10px 0 20px rgba(0,0,0,0.1) !important;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 0 !important;
    overflow-y: auto !important;
  }

  #topbar-links.topbar__links.is-active {
    right: 0 !important; /* Aparece */
  }

  /* 3. Estilos de links internos */
  .tb-link {
    width: 100% !important;
    padding: 15px 0 !important;
    color: #333 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    display: block !important;
    text-align: left !important;
  }

  /* 4. Dropdowns en móvil */
  .tb-dropdown-content {
    position: static !important;
    display: none !important; /* Oculto por defecto */
    width: 100% !important;
    box-shadow: none !important;
    background: #f8f9fa !important;
    padding-left: 15px !important;
  }

  .tb-dropdown.is-open > .tb-dropdown-content {
    display: block !important;
  }

  .tb-submenu-content {
    position: static !important;
    display: none !important;
    padding-left: 15px !important;
  }
  
  .tb-submenu.is-open .tb-submenu-content {
    display: block !important;
  }
}
@media (max-width: 992px) {
  /* 1. Esto aplica color negro SOLO a los links que NO son el botón azul */
  .topbar__links .tb-link:not([data-variant="primary"]) {
    color: #333 !important; /* "Conoce el Sistema", etc, en negro */
    padding: 15px 0 !important;
    display: block !important;
    border-bottom: 1px solid #f0f0f0 !important;
  }

  /* 2. ESTO CORRIGE TU BOTÓN AZUL */
  .topbar__links .tb-link[data-variant="primary"] {
    /* Forzamos que el texto sea blanco como en desktop */
    color: #ffffff !important; 
    
    /* Aseguramos que mantenga su forma de botón */
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    padding: 14px !important;
    margin-top: 20px !important;
    
    /* Estos de abajo ya los trae tu sitio.css, 
       pero los ponemos por si acaso algo los bloquea */
    background-color: #003e6a !important; 
    border-radius: 50px !important; 
  }
}