/**
 * geoportal-hemeroteca.css
 * Estilos para el panel lateral (desktop) y bottom-sheet (mobile) de la Hemeroteca.
 */

/* ── Ancho del host en desktop ── */
.right-context-host[data-active-panel="hemeroteca"] {
    flex: 0 0 min(380px, calc(100vw - var(--right-tool-rail-width, 44px) - (2 * var(--right-context-edge, 12px))));
    width: min(380px, calc(100vw - var(--right-tool-rail-width, 44px) - (2 * var(--right-context-edge, 12px))));
}

/* ── Panel Hemeroteca ── */
.hemeroteca-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-panel, var(--bg-glass));
    color: var(--text-primary);
}

.hemeroteca-panel[hidden] {
    display: none !important;
}

/* ── Header ── */
.hemeroteca-panel-header,
.hemeroteca-panel .drawer-header {
    position: relative !important;
    top: auto !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-panel, var(--bg-glass));
    color: var(--text-primary);
    flex-shrink: 0;
}

.hemeroteca-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.hemeroteca-header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.hemeroteca-panel-title {
    margin: 0;
    font-size: var(--fs-md, 1rem);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.hemeroteca-today-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill, 999px);
    font-size: 0.72rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent-hover, var(--accent));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.hemeroteca-panel .drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 6px);
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.hemeroteca-panel .drawer-close:hover {
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
    color: var(--text-primary);
}

.hemeroteca-panel .drawer-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* ── Filtros Sticky ── */
.hemeroteca-panel-sticky-filters {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-panel, var(--bg-glass));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    padding: var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex-shrink: 0;
}

.hemeroteca-category-chips-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.hemeroteca-category-chips-scroll::-webkit-scrollbar {
    height: 3px;
}

.hemeroteca-category-chips-scroll::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

.hemeroteca-category-chips {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: max-content;
}

.hemeroteca-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 var(--space-3);
    white-space: nowrap;
    border-radius: var(--radius-pill, 999px);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-glass);
    background: color-mix(in srgb, var(--text-primary) 4%, transparent);
    color: var(--text-secondary);
    transition: all 0.15s ease;
    user-select: none;
}

.hemeroteca-chip:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--text-primary);
}

.hemeroteca-chip.is-active,
.hemeroteca-chip[aria-checked="true"] {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    font-weight: 600;
}

.hemeroteca-chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Selector de Fecha ── */
.hemeroteca-date-filter-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.hemeroteca-date-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

.hemeroteca-date-select-wrapper {
    flex: 1;
    min-width: 0;
}

.hemeroteca-date-select {
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 0 var(--space-3);
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border-glass);
    background: var(--bg-card, color-mix(in srgb, var(--text-primary) 5%, transparent));
    color: var(--text-primary);
    font-size: 0.84rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.hemeroteca-date-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ── Contenedor de Noticias ── */
.hemeroteca-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-3);
}

.hemeroteca-news-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.hemeroteca-news-list[hidden] {
    display: none !important;
}

/* ── Tarjetas de Noticia ── */
.hemeroteca-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-glass);
    background: var(--bg-card, color-mix(in srgb, var(--text-primary) 3%, transparent));
    color: var(--text-primary);
    text-decoration: none;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.hemeroteca-card:hover {
    background: color-mix(in srgb, var(--accent) 7%, var(--bg-card, transparent));
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
    transform: translateY(-1px);
}

.hemeroteca-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Thumbnail 80x60 */
.hemeroteca-card-media {
    position: relative;
    width: 80px;
    height: 60px;
    min-width: 80px;
    min-height: 60px;
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    background: color-mix(in srgb, var(--text-primary) 6%, transparent);
    flex-shrink: 0;
}

.hemeroteca-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hemeroteca-thumb-placeholder,
.hemeroteca-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-primary) 6%, transparent);
}

.hemeroteca-thumb-placeholder-svg {
    opacity: 0.65;
}

.is-hidden {
    display: none !important;
}

/* Badge de categoría absoluto sobre thumbnail */
.hemeroteca-card-category-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 2;
    padding: 1px 5px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.78);
    color: #ffffff;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    max-width: calc(100% - 6px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Contenido de la tarjeta */
.hemeroteca-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.hemeroteca-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
}

.hemeroteca-card-source {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hemeroteca-card-dot {
    opacity: 0.5;
}

.hemeroteca-card-date {
    white-space: nowrap;
}

.hemeroteca-card-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hemeroteca-card-summary {
    margin: 4px 0 0 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Estado Vacío ── */
.hemeroteca-empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.hemeroteca-empty-state[hidden] {
    display: none !important;
}

.hemeroteca-empty-icon {
    font-size: 2.2rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-bottom: var(--space-1);
}

.hemeroteca-empty-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hemeroteca-empty-desc {
    margin: 0;
    font-size: 0.825rem;
    color: var(--text-secondary);
    max-width: 260px;
}

/* ── Loading Skeleton ── */
.hemeroteca-loading-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.hemeroteca-loading-skeleton[hidden] {
    display: none !important;
}

.hemeroteca-skeleton-card {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border-glass);
    background: var(--bg-card, color-mix(in srgb, var(--text-primary) 3%, transparent));
}

.hemeroteca-skeleton-thumb {
    width: 80px;
    height: 60px;
    min-width: 80px;
    min-height: 60px;
    border-radius: var(--radius-sm, 6px);
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
    animation: hemeroteca-shimmer 1.5s infinite ease-in-out;
}

.hemeroteca-skeleton-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}

.hemeroteca-skeleton-line {
    border-radius: 4px;
    background: color-mix(in srgb, var(--text-primary) 8%, transparent);
    animation: hemeroteca-shimmer 1.5s infinite ease-in-out;
}

.hemeroteca-skeleton-line-title {
    height: 14px;
    width: 85%;
}

.hemeroteca-skeleton-line-sub {
    height: 10px;
    width: 45%;
}

.hemeroteca-skeleton-line-body {
    height: 11px;
    width: 70%;
}

@keyframes hemeroteca-shimmer {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.85; }
}

/* ── Adaptación Móvil (<= 768px) ── */
@media (max-width: 768px) {
    body.mobile-hemeroteca-open .right-context-host {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        height: 70vh !important;
        max-height: 70vh !important;
        border-radius: 16px 16px 0 0 !important;
        border: 1px solid var(--border-glass) !important;
        border-bottom: none !important;
        z-index: calc(var(--z-mobile-navigation, 1190) + 10) !important;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4) !important;
        background: var(--bg-panel, var(--bg-glass)) !important;
        transform: translateY(0) !important;
    }

    body.mobile-hemeroteca-open .mobile-year-bar,
    body.mobile-hemeroteca-open .mobile-level-bar,
    body.mobile-hemeroteca-open .map-legend-card,
    body.mobile-hemeroteca-open .legend-visibility-toggle,
    body.mobile-hemeroteca-open .mobile-nav-toggle {
        display: none !important;
    }

    body.mobile-hemeroteca-open .mobile-overlay-backdrop {
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* ── Flatpickr date picker ── */
.hemeroteca-date-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border, #ccc);
  border-radius: 8px;
  padding: 0 8px;
  min-height: 44px;
  background: var(--color-surface, #fff);
  cursor: pointer;
}
.hemeroteca-cal-icon {
  flex-shrink: 0;
  opacity: 0.5;
  pointer-events: none;
}
#hemeroteca-date-input,
.hemeroteca-date-picker-wrapper .form-control.input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  min-height: 44px;
  cursor: pointer;
  outline: none;
}

/* Días con noticias: número en acento + punto debajo */
.flatpickr-day.fp-has-news {
  font-weight: 700;
  color: var(--color-accent, #e63946) !important;
  position: relative;
}
.flatpickr-day.fp-has-news::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-accent, #e63946);
}

/* Días sin noticias: visibles pero atenuados */
.flatpickr-day:not(.fp-has-news):not(.selected):not(.today):not(.prevMonthDay):not(.nextMonthDay):not(.flatpickr-disabled) {
  opacity: 0.35;
}

/* Día seleccionado */
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--color-accent, #e63946) !important;
  border-color: var(--color-accent, #e63946) !important;
  color: #fff !important;
}
.flatpickr-day.selected.fp-has-news::after {
  background: #fff;
}

/* Hoy */
.flatpickr-day.today:not(.selected) {
  border-color: var(--color-accent, #e63946) !important;
}

/* z-index para que flote sobre bottom sheet en mobile */
.flatpickr-calendar { z-index: 99999 !important; }
