/* ===================================
   ACCIONES CLIMÁTICAS - RESPONSIVE
   =================================== */

/* ===================================
   DESKTOP GRANDE (>1440px)
   =================================== */
@media (min-width: 1440px) {
  .header-content,
  .main-container {
    max-width: 1600px;
  }

  .header-title {
    font-size: 2.5rem;
  }

  .header-subtitle {
    font-size: 1.125rem;
  }

  .stat-number {
    font-size: 2rem;
  }
}

/* ===================================
   TABLET (768px - 1023px)
   =================================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .header-left {
    width: 100%;
  }

  .header-right {
    width: 100%;
  }

  .stats-container {
    width: 100%;
    justify-content: space-around;
    padding: 1rem;
  }

  .stat-item {
    flex: 1;
  }

  /* main-container usa flex: 1 1 auto, no necesita altura fija */

  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}

/* ===================================
   MÓVIL GRANDE (481px - 767px)
   =================================== */
@media (min-width: 481px) and (max-width: 767px) {
  .acciones-header {
    padding: 1.5rem 0;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .header-title {
    font-size: 1.5rem;
  }

  .header-subtitle {
    font-size: 0.875rem;
  }

  .stats-container {
    width: 100%;
    gap: 1rem;
    padding: 0.75rem 1rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .main-container {
    padding: 0.5rem 1rem;
  }
  /* main-container usa flex: 1 1 auto, no necesita altura fija */

  .map-control-btn {
    width: 36px;
    height: 36px;
  }

  .map-control-btn svg {
    width: 18px;
    height: 18px;
  }

  .timeline-container {
    padding: 0.5rem 1rem;
    height: 70px;
  }

  /* Popup adjustments */
  .popup-container {
    width: 260px;
  }

  .popup-header {
    padding: 0.875rem;
  }

  .popup-title {
    font-size: 0.938rem;
  }

  .popup-body {
    padding: 0.875rem;
  }
}

/* ===================================
   MÓVIL PEQUEÑO (<480px)
   =================================== */
@media (max-width: 480px) {
  .acciones-header {
    padding: 1rem 0;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 0 1rem;
  }

  .header-title {
    font-size: 1.25rem;
    line-height: 1.3;
  }

  .header-subtitle {
    font-size: 0.813rem;
  }

  .stats-container {
    width: 100%;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .stat-item {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }

  .stat-item:last-child {
    border-bottom: none;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.813rem;
  }

  .main-container {
    padding: 0.5rem 1rem;
  }
  /* main-container usa flex: 1 1 auto, no necesita altura fija */

  .map-wrapper {
    border-radius: 8px;
  }

  .map-control-btn {
    width: 34px;
    height: 34px;
    top: 8px;
    right: 8px;
  }

  .map-control-btn svg {
    width: 16px;
    height: 16px;
  }

  .timeline-container {
    padding: 0.5rem 1rem;
    height: 70px;
    border-radius: 0;
  }

  /* Popup adjustments */
  .popup-container {
    width: 240px;
  }

  .popup-header {
    padding: 0.75rem;
  }

  .popup-dependencia {
    font-size: 0.688rem;
  }

  .popup-title {
    font-size: 0.875rem;
  }

  .popup-body {
    padding: 0.75rem;
  }

  .popup-location {
    font-size: 0.813rem;
  }

  .popup-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .popup-description {
    font-size: 0.813rem;
  }

  .popup-population {
    padding: 0.5rem;
  }

  .popup-population-label {
    font-size: 0.688rem;
  }

  .popup-population-value {
    font-size: 0.813rem;
  }

  .popup-badge {
    font-size: 0.688rem;
    padding: 0.35rem 0.65rem;
  }

  /* Popup sections en móvil */
  .popup-section {
    padding: 0.625rem;
    gap: 0.75rem;
  }

  .popup-section-icon {
    width: 32px;
    height: 32px;
  }

  .popup-meta-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .popup-footer {
    gap: 0.4rem;
  }

  .popup-btn {
    padding: 0.5rem 0.3rem;
    font-size: 0.7rem;
    gap: 0.3rem;
  }

  .popup-btn svg {
    width: 12px;
    height: 12px;
  }
}

/* ===================================
   MODALES - RESPONSIVE
   =================================== */
@media (max-width: 767px) {
  /* Modal de rango de fechas */
  .date-modal {
    width: 95%;
    max-width: none;
    max-height: 90vh;
  }

  .date-modal-header {
    padding: 1rem;
  }

  .date-modal-title {
    font-size: 1.125rem;
  }

  .date-modal-body {
    padding: 1.25rem 1rem;
    gap: 1.25rem;
  }

  .date-input {
    font-size: 1rem;
    padding: 0.875rem;
  }

  .date-modal-footer {
    padding: 1rem;
    flex-direction: column;
  }

  .date-btn {
    width: 100%;
    padding: 0.875rem 1rem;
  }

  /* Modal de ubicaciones */
  .media-modal {
    width: 95%;
    max-width: none;
    max-height: 90vh;
  }

  .media-modal-large {
    width: 95%;
    max-width: none;
  }

  .media-modal-header {
    padding: 1rem;
  }

  .media-modal-title {
    font-size: 1.125rem;
  }

  .media-modal-body {
    padding: 1rem;
  }

  .ubicacion-item {
    padding: 0.875rem 1rem;
  }

  .ubicacion-item-lugar {
    font-size: 1rem;
  }

  .ubicacion-item-actividad {
    font-size: 0.875rem;
  }

  .ubicacion-item-evidencias {
    flex-wrap: wrap;
  }

  .ubicacion-evidencia-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.813rem;
    /* Mínimo 44px para touch */
    min-height: 44px;
    min-width: 44px;
  }
}

/* ===================================
   TIMELINE GRÁFICO - RESPONSIVE
   =================================== */
@media (max-width: 767px) {
  .timeline-container {
    padding: 0.75rem 1rem;
  }

  .timeline-wrapper {
    gap: 1rem;
  }

  .timeline-calendar-icon {
    width: 40px;
    height: 40px;
    /* Mínimo para touch */
    min-width: 44px;
    min-height: 44px;
  }

  .timeline-calendar-icon svg {
    width: 20px;
    height: 20px;
  }

  .timeline-graph {
    height: 50px;
  }

  .timeline-markers {
    gap: 0.25rem;
  }

  .timeline-year-marker {
    min-width: 30px;
  }

  .timeline-marker-dot {
    width: 10px;
    height: 10px;
    border-width: 2px;
  }

  .timeline-marker-year {
    font-size: 0.688rem;
  }

  .timeline-marker-count {
    font-size: 0.625rem;
    padding: 2px 6px;
    top: -26px;
  }
}

@media (max-width: 480px) {
  .timeline-wrapper {
    flex-direction: column;
    gap: 0.75rem;
  }

  .timeline-calendar-icon {
    align-self: flex-start;
  }

  .timeline-graph {
    width: 100%;
    height: 60px;
  }

  /* Ocultar algunos años si hay muchos */
  .timeline-year-marker:nth-child(even) .timeline-marker-year {
    display: none;
  }
}

/* ===================================
   FILTROS COMPACTOS - RESPONSIVE
   =================================== */
@media (max-width: 767px) {
  .filters-compact-container {
    padding: 0.75rem 1rem;
  }

  .filters-compact-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .filter-dropdown-group {
    width: 100%;
  }

  .filter-dropdown {
    width: 100%;
    font-size: 0.938rem;
    padding: 0.75rem 1rem;
    /* Mínimo para touch */
    min-height: 44px;
  }

  .filter-clear-btn {
    width: 100%;
    /* Mínimo para touch */
    min-height: 44px;
    padding: 0.75rem;
    justify-content: center;
  }

  .filter-results-badge {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
    font-size: 0.938rem;
  }
}

/* ===================================
   BUSCADOR FLOTANTE - RESPONSIVE
   =================================== */
@media (max-width: 767px) {
  .map-search-box {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }

  .map-search-input {
    font-size: 0.938rem;
    padding: 0.75rem 2.5rem;
    /* Mínimo para touch */
    min-height: 44px;
  }

  .map-search-icon {
    width: 16px;
    height: 16px;
    left: 0.875rem;
  }

  .map-search-clear {
    right: 0.75rem;
    width: 28px;
    height: 28px;
  }

  .map-search-clear svg {
    width: 14px;
    height: 14px;
  }
}

/* ===================================
   BOTONES TOUCH-FRIENDLY
   =================================== */
@media (max-width: 767px) {
  /* Botón centrar mapa */
  .center-btn {
    width: 44px;
    height: 44px;
    bottom: 20px;
    right: 20px;
  }

  .center-btn svg {
    width: 20px;
    height: 20px;
  }

  /* Botones del popup */
  .popup-btn {
    /* Mínimo 44px para touch */
    min-height: 44px;
    padding: 0.75rem 0.875rem;
    font-size: 0.813rem;
  }

  .popup-btn svg {
    width: 14px;
    height: 14px;
  }

  /* Botones de cerrar modales */
  .date-modal-close,
  .media-modal-close {
    width: 40px;
    height: 40px;
    /* Mínimo para touch */
    min-width: 44px;
    min-height: 44px;
  }

  /* Badge clickeable de ubicaciones */
  .badge-clickeable {
    /* Mínimo para touch */
    min-height: 44px;
    padding: 0.75rem 1rem;
    display: inline-flex;
    align-items: center;
  }
}

/* ===================================
   POPUP LEAFLET - AJUSTES MÓVIL
   =================================== */
@media (max-width: 767px) {
  .leaflet-popup-content-wrapper {
    max-width: 280px;
  }

  .popup-formulario {
    width: 100%;
  }

  .popup-header {
    padding: 0.875rem;
  }

  .popup-header-field label {
    font-size: 0.688rem;
  }

  .header-value {
    font-size: 0.875rem;
  }

  .popup-body {
    padding: 0.875rem;
  }

  .popup-field {
    margin-bottom: 0.75rem;
  }

  .popup-field label {
    font-size: 0.813rem;
  }

  .field-value {
    font-size: 0.875rem;
  }

  .badge {
    font-size: 0.75rem;
    padding: 0.4rem 0.75rem;
  }

  .popup-footer {
    padding: 0.75rem 0.875rem;
    gap: 0.5rem;
  }

  /* Lista mini de ubicaciones */
  .ubicaciones-mini-list {
    max-height: 150px;
  }

  .ubicacion-mini-item {
    font-size: 0.813rem;
    padding: 0.5rem;
  }

  .btn-ver-ubicaciones {
    font-size: 0.875rem;
    padding: 0.75rem;
    /* Mínimo para touch */
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .leaflet-popup-content-wrapper {
    max-width: 260px;
  }

  .popup-header {
    padding: 0.75rem;
  }

  .header-value {
    font-size: 0.813rem;
  }

  .popup-body {
    padding: 0.75rem;
  }

  .popup-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .popup-field-half {
    width: 100%;
  }

  .popup-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .popup-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===================================
   LANDSCAPE MODE (móviles en horizontal)
   =================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .main-container {
    height: calc(100vh - 70px - 58px);
  }

  .timeline-container {
    display: none;
  }

  .acciones-header {
    padding: 0.75rem 0;
  }

  .header-content {
    padding: 0 1rem;
  }

  .stats-container {
    flex-direction: row;
    gap: 1rem;
  }

  .stat-item {
    flex-direction: column;
    border-bottom: none;
  }

  /* Modales en landscape ocupan más altura */
  .date-modal,
  .media-modal {
    max-height: 95vh;
  }
}

/* ===================================
   PRINT STYLES
   =================================== */
@media print {
  .navbar,
  .timeline-container,
  .map-control-btn {
    display: none;
  }

  .map-wrapper {
    height: 500px;
    page-break-inside: avoid;
  }

  .acciones-header {
    background: white;
    color: var(--text-color);
    box-shadow: none;
    border-bottom: 2px solid var(--primary-color);
  }

  .header-title,
  .header-subtitle {
    color: var(--text-color);
  }

  .stats-container {
    background: white;
    border: 1px solid var(--border-color);
  }

  .stat-number,
  .stat-label {
    color: var(--text-color);
  }
}
