/* APFU - Historia de Encuentros CSS */
:root {
  --apfu-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --apfu-primary: #1e40af;
  --apfu-primary-hover: #1d4ed8;
  --apfu-navy: #0f172a;
  --apfu-slate: #334155;
  --apfu-text: #0f172a;
  --apfu-muted: #64748b;
  --apfu-bg-app: #f8fafc;
  --apfu-bg-card: #ffffff;
  --apfu-border: #e2e8f0;
  --apfu-border-hover: #cbd5e1;
  --apfu-cyan-bg: #e0f2fe;
  --apfu-cyan-text: #0369a1;
  --apfu-gold-bg: #fef3c7;
  --apfu-gold-text: #92400e;
  --apfu-green-bg: #dcfce7;
  --apfu-green-text: #15803d;
  --apfu-radius: 12px;
  --apfu-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
  --apfu-shadow-hover: 0 12px 30px -4px rgba(15, 23, 42, 0.15);
}

.apfu-history-wrapper {
  font-family: var(--apfu-font);
  color: var(--apfu-text);
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 10px;
  box-sizing: border-box;
}

.apfu-history-wrapper *,
.apfu-history-wrapper *::before,
.apfu-history-wrapper *::after {
  box-sizing: border-box;
}

/* Toolbar */
.apfu-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--apfu-bg-card);
  padding: 16px 20px;
  border-radius: var(--apfu-radius);
  border: 1px solid var(--apfu-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  margin-bottom: 20px;
}

.apfu-search-box {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  align-items: center;
}

.apfu-search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  opacity: 0.6;
  pointer-events: none;
}

.apfu-search-box input {
  width: 100%;
  padding: 10px 36px 10px 36px;
  border: 1px solid var(--apfu-border);
  border-radius: 50px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f8fafc;
}

.apfu-search-box input:focus {
  border-color: var(--apfu-primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
  background: #ffffff;
}

#apfu-clear-search {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--apfu-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px;
}

/* Decade Filters */
.apfu-decade-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.apfu-decade-btn {
  background: #f1f5f9;
  border: 1px solid transparent;
  color: var(--apfu-slate);
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.apfu-decade-btn:hover {
  background: #e2e8f0;
  color: var(--apfu-navy);
}

.apfu-decade-btn.active {
  background: var(--apfu-primary);
  color: #ffffff;
  border-color: var(--apfu-primary);
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

/* View Toggle */
.apfu-view-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.apfu-view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--apfu-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.apfu-view-btn svg {
  stroke: currentColor;
}

.apfu-view-btn.active {
  background: #ffffff;
  color: var(--apfu-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* Status bar */
.apfu-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 0 4px;
}

#apfu-count-badge {
  font-size: 13px;
  color: var(--apfu-muted);
  font-weight: 500;
}

/* Base Card Styles */
.apfu-card {
  background: var(--apfu-bg-card);
  border-radius: var(--apfu-radius);
  border: 1px solid var(--apfu-border);
  box-shadow: var(--apfu-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  overflow: hidden;
}

.apfu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--apfu-shadow-hover);
  border-color: var(--apfu-border-hover);
}

.apfu-card-inner {
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.apfu-card-header {
  margin-bottom: 16px;
}

.apfu-year-mobile {
  display: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--apfu-primary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.apfu-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--apfu-navy);
  margin: 0 0 8px 0;
  line-height: 1.35;
}

.apfu-card-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--apfu-gold-bg);
  color: var(--apfu-gold-text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.apfu-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.apfu-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 50px;
  font-weight: 500;
}

.apfu-pill-location {
  background: var(--apfu-cyan-bg);
  color: var(--apfu-cyan-text);
}

.apfu-pill-dates {
  background: #f1f5f9;
  color: var(--apfu-slate);
}

.apfu-pill-virtual {
  background: #f3e8ff;
  color: #7e22ce;
}

/* Media Area */
.apfu-media-container {
  margin-top: auto;
  padding-top: 14px;
}

.apfu-media-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.apfu-media-tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--apfu-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.apfu-media-tab-btn.active {
  background: #ffffff;
  color: var(--apfu-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.apfu-media-views {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
}

.apfu-media-pane {
  display: none;
  animation: apfuFadeIn 0.25s ease-in-out;
}

.apfu-media-pane.active {
  display: block;
}

@keyframes apfuFadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.apfu-img-wrapper {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  display: block;
  height: 240px;
}

.apfu-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.apfu-img-wrapper:hover img {
  transform: scale(1.05);
}

.apfu-img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.apfu-img-wrapper:hover .apfu-img-overlay {
  opacity: 1;
}

.apfu-zoom-icon {
  background: rgba(255, 255, 255, 0.95);
  color: var(--apfu-navy);
  padding: 8px 14px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Placeholder for years without media */
.apfu-media-placeholder {
  background: #f8fafc;
  border: 1px dashed var(--apfu-border);
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
}

.apfu-placeholder-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.apfu-placeholder-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--apfu-slate);
}

.apfu-placeholder-desc {
  font-size: 11px;
  color: var(--apfu-muted);
  margin-top: 4px;
}

/* PDF link */
.apfu-doc-link-wrap {
  margin-top: 10px;
}

.apfu-pdf-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: center;
  background: #fff;
  border: 1px solid #fed7aa;
  color: #c2410c;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  transition: all 0.2s;
}

.apfu-pdf-button:hover {
  background: #fff7ed;
  border-color: #f97316;
  color: #9a3412;
}

/* =========================================
   TIMELINE LAYOUT
========================================= */
.apfu-layout-timeline {
  position: relative;
  padding: 20px 0 20px 140px;
}

.apfu-layout-timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 95px;
  width: 3px;
  background: #e2e8f0;
  border-radius: 2px;
}

.apfu-layout-timeline .apfu-card {
  position: relative;
  margin-bottom: 32px;
}

.apfu-layout-timeline .apfu-timeline-marker {
  position: absolute;
  left: -140px;
  top: 24px;
  width: 90px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.apfu-layout-timeline .apfu-year-badge {
  background: var(--apfu-primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 50px;
  box-shadow: 0 2px 8px rgba(30, 64, 175, 0.3);
  position: relative;
}

.apfu-layout-timeline .apfu-year-badge::after {
  content: '';
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--apfu-primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px #ffffff;
}

/* =========================================
   GRID LAYOUT
========================================= */
.apfu-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.apfu-layout-grid .apfu-timeline-marker {
  display: none;
}

.apfu-layout-grid .apfu-year-mobile {
  display: block;
}

/* No results block */
.apfu-no-results {
  background: #ffffff;
  border: 1px solid var(--apfu-border);
  border-radius: var(--apfu-radius);
  padding: 40px 20px;
  text-align: center;
  margin: 30px 0;
}

.apfu-no-results-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.apfu-no-results h3 {
  margin: 0 0 8px 0;
  color: var(--apfu-navy);
}

.apfu-no-results p {
  margin: 0;
  color: var(--apfu-muted);
  font-size: 14px;
}

/* =========================================
   LIGHTBOX MODAL
========================================= */
.apfu-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.apfu-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.apfu-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
}

.apfu-lightbox-content {
  position: relative;
  z-index: 10;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.apfu-lightbox-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.apfu-lightbox-body img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: block;
}

.apfu-lightbox-footer {
  margin-top: 12px;
  text-align: center;
  color: #ffffff;
}

.apfu-lb-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.apfu-lb-caption {
  font-size: 13px;
  color: #94a3b8;
}

.apfu-lightbox-close {
  position: absolute;
  top: -45px;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.apfu-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.4);
}

.apfu-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.apfu-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.35);
}

.apfu-lightbox-prev {
  left: -60px;
}

.apfu-lightbox-next {
  right: -60px;
}

/* =========================================
   RESPONSIVE QUERIES
========================================= */
@media (max-width: 768px) {
  .apfu-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .apfu-decade-filters {
    justify-content: center;
  }

  .apfu-view-toggle {
    justify-content: center;
  }

  .apfu-layout-timeline {
    padding-left: 0;
  }

  .apfu-layout-timeline::before {
    display: none;
  }

  .apfu-layout-timeline .apfu-timeline-marker {
    display: none;
  }

  .apfu-layout-timeline .apfu-year-mobile {
    display: block;
  }

  .apfu-lightbox-prev {
    left: 10px;
  }

  .apfu-lightbox-next {
    right: 10px;
  }
}
