
:root {
  /* colores de papel y filos, adaptados de tu ejemplo */
  --paper    : #fdfaf2;
  --edge-a   : #ebe0cb;
  --edge-b   : #ded2bd;
  --leaf-gap : 8px;    /* espacio entre capas */
  --tab-w    : 30%;    /* ancho pestañas */
}

/* ===================================================
   Responsive para móvil (< 768px)
   =================================================== */
@media (max-width: 767.98px) {
  /* ————— HEADER SUPERIOR ————— */
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
  }
  .barra-logo {
    width: 100px !important;
    height: auto !important;
  }
  .barra-logo img {
    display: block;
    max-width: 100%;
    height: auto;
  }
  .page-title {
    order: 2;
    width: 100%;
    text-align: center;
  }
  .barra-social {
    order: 3;
    width: 100%;
    text-align: center;
  }

  /* ————— ALTURA DEL MAPA ————— */
  #mapa {
    height: calc(100vh - 180px) !important; /* espacio para header + instrucciones */
  }

  /* ————— MODAL MUNICIPIO (full screen) ————— */
  #modalMunicipio .modal-dialog {
    max-width: 100% !important;
    margin: 0;
  }
  #modalMunicipio .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
  }
  #modalMunicipio .modal-body .row {
    display: flex;
    flex-direction: column;
    height: 100% !important;
    margin: 0 !important;
  }
  #modalMunicipio .sidebar,
  #modalMunicipio .main-content {
    width: 100% !important;
    padding: .5rem !important;
  }

  /* ————— SUBMENÚ LATERAL (oculto en móvil) ————— */
  .submenu-lateral-custom {
    display: none !important;
  }

  /* ————— SIDEBAR / CLASIFICACIONES ————— */
  .sidebar {
    padding-top: .25rem !important;
  }
  .sidebar-header {
    margin: 0 !important;
    padding: .5rem 0 !important;
    text-align: center;
    margin-top: -2rem !important; 
  }
  .sidebar-content {
    max-height: 50vh !important;
    overflow-y: auto !important;
    margin: 0 !important;
    scrollbar-width: thin;
  }
  #listaClasificaciones li {
    padding: .5rem 1rem !important;
    margin: 0 !important;
  }

  /* ————— MAIN CONTENT ————— */
  .main-content {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 120px) !important; /* ajusta 120px a header + buscador + márgenes */
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* ————— BUSCADOR ————— */
  .search-wrapper {
    position: static !important;
    margin: 1rem 1rem 0 !important;
    text-align: right !important;
  }

  /* ————— CAJA DE DOCUMENTOS ————— */
  .classification-box {
    margin-top: .25rem !important;
    background-color: #fff !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 35vh !important;
    max-height: 55vh !important;
  }
  .document-list-wrapper,
  #documentosView {
    background-color: #fff !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding-bottom: 1.5rem !important;
    max-height: none !important;
  }

  /* ————— OCULTAR ELEMENTOS DE ESCRITORIO ————— */
  .district-header,
  .main-content .pink-line {
    display: none !important;
  }

  /* Sólo en móvil: < 768px */
@media (max-width: 767.98px) {
  /* Caja entera del offcanvas */
  #offcanvasSubclasificaciones {
    background-color: transparent;      /* para que no se vea el blanco por defecto */
  }
  /* Header (título y cerrar) */
  #offcanvasSubclasificaciones .offcanvas-header {
    background-color: #ba68c8;          /* púrpura medio */
    color: #fff;
    border-bottom: none;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
  }
  /* Cuerpo general del panel */
  #offcanvasSubclasificaciones .offcanvas-body {
    background-color: #f3e5f5;          /* lavanda muy suave */
    padding: 1rem;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
  }
  /* Lista de subclasificaciones */
  #offcanvasSubclasificaciones .list-group-flush {
    margin: 0;
    padding: 0;
  }
  #offcanvasSubclasificaciones .list-group-item {
    background-color: #fff;             /* blanco puro para cada ítem */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: .5rem;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,0.6),
      0 2px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: background-color .2s, transform .2s;
  }
  #offcanvasSubclasificaciones .list-group-item:hover {
    background-color: #f0e5f5;           /* hover lavanda suave */
    transform: translateX(3px);
  }
}

}

/* ===================================================
   Responsive para tablet (768px – 992px)
   =================================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
  #mapa {
    height: calc(100vh - 200px);
  }
  #modalMunicipio .modal-dialog.modal-lg {
    max-width: 90vw !important;
  }
  #modalMunicipio .sidebar {
    flex: 0 0 35% !important;
  }
  #modalMunicipio .main-content {
    flex: 0 0 65% !important;
  }
}

/* ===================================================
   Muy estrecho (< 480px): logo aún más pequeño
   =================================================== */
@media (max-width: 479.98px) {
  .barra-logo {
    width: 80px !important;
  }
}

@media (max-width: 767.98px) {
  .mobile-distrito-header {
    padding-top: 1.5rem; /* deja espacio para la X */
  }
  .mobile-distrito-header .btn-close {
    font-size: 1.2rem;
  }
}
/* ————— Ocultar siempre la versión móvil ————— */
.glossary-mobile {
  display: none;
}

/* ————— En desktop (>=768px) mostramos el libro apilado ————— */
@media (min-width: 768px) {
  .book-glosario {
    display: block !important;
    visibility: visible !important;
  }
}

/* ————— En móvil (<768px) ocultamos el libro y mostramos la versión móvil ————— */
@media (max-width: 767.98px) {
  /* 1) Libro desktop desaparece */
  .book-glosario {
    display: none !important;
    visibility: hidden !important;
  }

  /* 2) Mostramos el glosario móvil */
  .glossary-mobile {
    display: flex !important;
    flex-direction: column;
    gap: .5rem;
    padding: .5rem;
    z-index: 1000;
    overflow-x: hidden;
  }

  /* 3) Header móvil (tapa de libro) */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg,#7f3eae,#9c27b0);
    padding: .75rem 1rem;
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    position: relative;
  }
  .mobile-header h3 {
    flex: 1;
    color: #fff;
    font-size: 1.25rem;
    text-align: center;
    margin: 0;
    line-height: 1.2;
  }
  .mobile-menu-icon {
    position: absolute; left: 1rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: #fff; font-size: 1.4rem;
    cursor: pointer;
  }

  /* 4) Cuerpo móvil: pestañas + hojas */
  .mobile-body {
    display: flex;
    gap: 0;
    overflow-x: hidden;
  }

  /* 5) Pestañas verticales */
  .mobile-tabs {
    flex: 0 0 var(--tab-w);
    margin: 0; padding: .5rem 0;
    background: #fff;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 0 0 0 8px;
    box-shadow:
      inset 2px 0 4px rgba(0,0,0,0.05),
      inset -2px 0 4px rgba(255,255,255,0.2),
      0 2px 4px rgba(0,0,0,0.08);
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cc9e65 #f0ece2;
    scrollbar-gutter: stable both-edges;
  }
  .mobile-tabs::-webkit-scrollbar { width: 12px; }
  .mobile-tabs::-webkit-scrollbar-track { background: #f0ece2; }
  .mobile-tabs::-webkit-scrollbar-thumb {
    background: linear-gradient(
      to bottom,
      #333 0%,#333 15%,
      #cc9e65 15%,#cc9e65 85%,
      #996633 85%,#996633 100%
    );
    border: 2px solid #f0ece2;
    border-radius: 6px;
  }
  .mobile-tabs li {
    padding: .6rem 1rem;
    background: #9c27b0;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.5);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.1);
    transition: background .2s, transform .2s;
    cursor: pointer;
  }
  .mobile-tabs li:first-child { border-top-left-radius: 6px; }
  .mobile-tabs li:last-child  { border-bottom-left-radius: 6px; border-bottom: none; }
  .mobile-tabs li:hover       { background: #ab47bc; transform: translateX(2px); }
  .mobile-tabs li.active      { background: #7f3eae; transform: translateX(4px); box-shadow: 2px 2px 6px rgba(0,0,0,0.1); }

  /* 6) Hojas apiladas */
  .sheet-wrapper {
    position: relative;
    flex: 1;
    height: 80vh;
    margin-left: -1px;
  }
  .sheet-wrapper .sheet {
    position: absolute; inset: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 1rem;
    overflow-y: auto;
    display: none;
    box-shadow:
      inset -4px 0 6px -3px rgba(0,0,0,0.1),
      0 4px 8px rgba(0,0,0,0.15),
      4px 0 0 -1px var(--edge-a),
      8px 0 0 -1px var(--edge-b),
      12px 0 0 -1px var(--edge-a);
  }
  .sheet-wrapper .sheet:nth-child(1),
  .sheet-wrapper .sheet:nth-child(2) {
    background: rgba(0,0,0,0.03);
  }
  .sheet-wrapper .sheet:nth-child(1) {
    transform: translate(calc(var(--leaf-gap)*2), calc(var(--leaf-gap)*2));
  }
  .sheet-wrapper .sheet:nth-child(2) {
    transform: translate(var(--leaf-gap), var(--leaf-gap));
  }

  /* 7) Hoja activa y líneas de libreta */
  .sheet-wrapper .sheet.active-sheet {
    display: block; z-index: 3;
    background-image:
      repeating-linear-gradient(to bottom, transparent, transparent 24px, rgba(0,0,0,0.12) 25px),
      linear-gradient(90deg,#d6cab3 0 4px,transparent 4px);
    background-size: auto,4px 100%;
    background-position: 0 0,18px 0;
    border-color: #ddd;
  }
  .sheet-wrapper .sheet.active-sheet::before {
    content: "";
    position: absolute; left: -8px; top: 1.5rem;
    width: 8px; height: 8px;
    background: #fff; border: 1px solid #ccc; border-radius: 50%;
    box-shadow:
      0 2rem 0 0 #fff,
      0 4rem 0 0 #fff,
      0 6rem 0 0 #fff,
      0 8rem 0 0 #fff;
    z-index: 4;
  }

  /* 8) Contenido hoja activa */
  .sheet-wrapper .sheet.active-sheet h2 { color: #6a1b9a; margin-bottom: .5rem; }
  .sheet-wrapper .sheet.active-sheet h4 { color: #6a1b9a; margin-top: 1rem; }
  .sheet-wrapper .sheet.active-sheet p  { line-height: 1.6; color: #333; }
  .sheet-wrapper .sheet.active-sheet::-webkit-scrollbar { width: 8px; }
  .sheet-wrapper .sheet.active-sheet::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2); border-radius: 4px;
  }
  .sheet-wrapper .sheet.active-sheet::-webkit-scrollbar-track {
    background: transparent;
  }

  .mobile-close-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 1002;
  }
  .mobile-close-icon:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
  }
}
@media (max-width: 767.98px) {
  /* Sólo en móvil: centrar y resetear márgenes del título */
  .TextoTitulo {
    display: block;
    width: 100%;
    text-align: center !important;
    margin: 0 0 0.5rem !important;
  }
  /* Opcional: si necesitas además centrar el wrapper del form */
  #formBuscadorGlobal {
    justify-content: center !important;
  }
}

@media (max-width: 576px) {
  /* 1) Reducimos drásticamente la altura del mapa */
  #mapa {
    height: 30vh;       /* antes tenías 60vh/100vh, aquí solo 30% de la altura */
    min-height: 200px;  /* evita que quede demasiado pequeño */
  }

  /* 2) Acortamos márgenes del encabezado del mapa */
  .map-header {
    margin-bottom: 0.5rem;
  }
  .instruccion {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
  }
}
/* ================================
   Ajustes para móvil (<576px)
   ================================ */
@media (max-width: 575.98px) {
  /* 1) Rebajamos la altura del mapa */
  #mapa {
    height: 40vh !important;     /* ocupa sólo el 40% de la ventana */
    min-height: 180px !important; /* para que no quede ridículamente pequeño */
  }

  /* 2) Reducimos el gap de la sección del header del mapa */
  .container.text-center.my-4 {
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }

  /* 3) Acortamos el espacio entre título e instrucción */
  .map-header {
    margin-bottom: 0.25rem !important;
  }
  .instruccion {
    margin-bottom: 0.5rem !important;
    font-size: 0.9rem;
  }
}
