/* ============================================================
 * Obra Social Widget – CSS
 * BEM: .ceca-obra-social
 * ============================================================ */

/* ── Variables locales ────────────────────────── */
.ceca-obra-social {
  --os-card-radius: 20px;
  --os-bar-color: #cce8ee;
  --os-bar-gradient-start: var(--ceca-primary, #002a4f);
  --os-bar-gradient-end: #069bcd;
  --os-bar-width: 38px;
  --os-bar-radius: 20px;
  --os-chart-bg: #f9f9f9;
  --os-value-color: var(--ceca-primary, #002a4f);
  --os-year-color: #615e83;
  --os-font: var(--ceca-font-family, "Encode Sans Expanded", sans-serif);

  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  font-family: var(--os-font);
}

/* ── Cards ──────────────────────────────────── */
.ceca-obra-social__cards {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.ceca-obra-social__card {
  border-radius: 0 !important;
  position: relative;
  overflow: hidden;
  min-height: 160px;
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  padding: 24px;
  cursor: default;
  border: none;
  text-align: left;
  background: linear-gradient(135deg, #002a4f 0%, #069bcd 100%);
  transition: all 0.4s ease;
}

/* Cards clickables */
.ceca-obra-social__card--inversion,
.ceca-obra-social__card--actividades {
  cursor: pointer;
}
.ceca-obra-social__card--actividades.ceca-obra-social__card--active
  .ceca-obra-social__card-title,
.ceca-obra-social__card--actividades.ceca-obra-social__card--active
  .ceca-obra-social__card-value {
  color: var(--ceca-primary);
}
.ceca-obra-social__card--inversion:focus-visible,
.ceca-obra-social__card--actividades:focus-visible {
  outline: var(--ceca-focus-outline, 2px solid #002a4f);
  outline-offset: 2px;
}

/* Imagen de fondo — show/hide por estado activo */
.ceca-obra-social__card-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  z-index: 0;
  transition: opacity 0.4s ease;
}

/* Por defecto: mostrar inactive, ocultar active */
.ceca-obra-social__card-bg--active {
  opacity: 0;
}

.ceca-obra-social__card-bg--inactive {
  opacity: 1;
}

/* Cuando la card está activa: mostrar active, ocultar inactive */
.ceca-obra-social__card--active .ceca-obra-social__card-bg--active {
  opacity: 1;
}

.ceca-obra-social__card--active .ceca-obra-social__card-bg--inactive {
  opacity: 0;
}

/* Contenido sobre la imagen */
.ceca-obra-social__card-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ceca-obra-social__card-title {
  font-size: 16px;
  font-weight: 400;
  color: #ffffff;
  line-height: 1.3;
}

.ceca-obra-social__card-value {
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
}

.ceca-obra-social__card-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.3;
}

/* ── Toggle (círculo con flecha) ──────────── */
.ceca-obra-social__card-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s ease;
  color: var(--os-value-color);
}

/* Flecha rotada cuando activo */
.ceca-obra-social__card--active .ceca-obra-social__card-toggle {
  transform: rotate(180deg);
}

/* Ocultar toggle en beneficiarios */
.ceca-obra-social__card--beneficiarios .ceca-obra-social__card-toggle {
  display: none;
}

/* ── Gráfico ────────────────────────────────── */
.ceca-obra-social__chart-area {
  display: flex;
  gap: 25px;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
}

.ceca-obra-social__chart-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
  height: 490px;
}

.ceca-obra-social__chart {
  position: relative;
  background-color: var(--os-chart-bg);
  box-shadow: 0 2px 6px rgba(13, 10, 44, 0.08);
  padding: 30px;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
}

.ceca-obra-social__chart-subtitle {
  font-size: 22px;
  font-weight: 600;
  color: var(--os-value-color);
  line-height: 28px;
  margin: 0 0 20px 0;
  flex-shrink: 0;
}

/* ── Líneas de fondo ──────────────────────── */
.ceca-obra-social__chart-lines {
  position: absolute;
  top: 70px;
  left: 30px;
  right: 30px;
  bottom: 70px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.ceca-obra-social__chart-lines span {
  display: block;
  height: 1px;
  background: #e5e5ef;
  width: 100%;
}

/* ── Viewport + Track (carousel) ──────────── */
.ceca-obra-social__chart-viewport {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ceca-obra-social__chart-track {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 100%;
  gap: 0;
  transition: transform 0.5s ease;
  padding-bottom: 10px;
  padding-top: 10px;
  padding-right: 4px;
  padding-left: 4px;
}

/* ── Grupo de barra (value + bar + year) ──── */
.ceca-obra-social__bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.ceca-obra-social__bar-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--os-value-color);
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  min-width: 80px;
}

/* Último año: valor y año en bold */
.ceca-obra-social__bar-group--current .ceca-obra-social__bar-value {
  font-weight: 700;
}

.ceca-obra-social__bar-group--current .ceca-obra-social__bar-year {
  font-weight: 700;
}

/* ── Barra ────────────────────────────────── */
.ceca-obra-social__bar {
  width: var(--os-bar-width);
  border-radius: var(--os-bar-radius);
  background-color: var(--os-bar-color);
  transition:
    height 0.5s ease,
    background 0.5s ease;
  min-height: 20px;
}

/* Barra del último año: gradiente activo */
.ceca-obra-social__bar-group--current .ceca-obra-social__bar {
  background: linear-gradient(
    180deg,
    var(--os-bar-gradient-start) 0%,
    var(--os-bar-gradient-end) 100%
  );
}

/* ── Año ────────────────────────────────────── */
.ceca-obra-social__bar-year {
  font-size: 18px;
  font-weight: 400;
  color: var(--os-year-color);
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}

/* ── Navegación ─────────────────────────────── */
.ceca-obra-social__nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 25px;
  padding-top: 27px;
}

.ceca-obra-social__nav-label {
  font-size: 22px;
  font-weight: 500;
  color: #333333;
  line-height: 28px;
}

.ceca-obra-social__nav-buttons {
  display: flex;
  gap: 11px;
  align-items: center;
}

.ceca-obra-social__nav-arrow {
  width: 64px;
  height: 64px;
  border-radius: 100px;
  border: 1px solid #dddddd;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #333333;
  transition:
    background 0.25s ease,
    opacity 0.25s ease;
  padding: 0;
}

.ceca-obra-social__nav-arrow:hover:not(:disabled) {
  background: rgba(255, 255, 255, 1);
}

.ceca-obra-social__nav-arrow:focus-visible {
  outline: var(--ceca-focus-outline, 2px solid #002a4f);
  outline-offset: 2px;
}

.ceca-obra-social__nav-arrow:disabled {
  background: rgba(221, 221, 221, 0.85);
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Modo Actividades (colores alternativos) ── */

/* ── Panel Lateral ────────────────────────── */
.ceca-obra-social__side-panel {
  position: relative;
  width: 550px;
  min-width: 0;
  flex-shrink: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px;
  background: #333;
  margin-bottom: 90px;
}

.ceca-obra-social__side-panel-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  object-fit: cover;
  z-index: 0;
  transition: opacity 0.4s ease;
}

/* Panel lateral: show/hide por categoría activa */
.ceca-obra-social__side-panel-bg--actividades {
  opacity: 0;
}

.ceca-obra-social[data-active-category="actividades"]
  .ceca-obra-social__side-panel-bg--inversion {
  opacity: 0;
}

.ceca-obra-social[data-active-category="actividades"]
  .ceca-obra-social__side-panel-bg--actividades {
  opacity: 1;
}

/* Panel lateral: contenido show/hide por categoría */
.ceca-obra-social__side-panel-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.ceca-obra-social__side-panel-content--inversion {
  display: flex;
}

.ceca-obra-social__side-panel-content--actividades {
  display: none;
}

.ceca-obra-social[data-active-category="actividades"]
  .ceca-obra-social__side-panel-content--inversion {
  display: none;
}

.ceca-obra-social[data-active-category="actividades"]
  .ceca-obra-social__side-panel-content--actividades {
  display: flex;
}

.ceca-obra-social__side-panel-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 1;
}

.ceca-obra-social__side-panel-title {
  font-size: 35px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}

.ceca-obra-social__side-panel-tagline {
  display: flex;
  flex-direction: column;
}

.ceca-obra-social__side-panel-tagline-bold {
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
  text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}

.ceca-obra-social__side-panel-tagline-light {
  font-size: 30px;
  font-weight: 200;
  font-style: italic;
  color: #ffffff;
  line-height: 1.3;
  text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
}

/* ── Modo Actividades (colores alternativos) ── */
.ceca-obra-social[data-active-category="actividades"] .ceca-obra-social__bar {
  background-color: var(--os-bar-color-actividades, #ffd3ab);
}

.ceca-obra-social[data-active-category="actividades"]
  .ceca-obra-social__bar-group--current
  .ceca-obra-social__bar {
  background: linear-gradient(
    180deg,
    var(--os-bar-gradient-act-start, #f07d15) 0%,
    var(--os-bar-gradient-act-end, #ffd3ab) 100%
  );
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1200px) {
  .ceca-obra-social__cards {
    flex-wrap: wrap;
  }

  .ceca-obra-social__card {
    flex: 1 1 calc(50% - 8px);
    min-height: 140px;
  }

  .ceca-obra-social__card--beneficiarios {
    flex: 1 1 100%;
  }

  .ceca-obra-social__chart-area {
    flex-direction: column;
  }

  .ceca-obra-social__side-panel {
    width: 100%;
    min-width: 100%;
    min-height: 280px;
  }

  .ceca-obra-social__chart {
    height: 350px;
    min-height: 350px;
  }

  .ceca-obra-social__bar-value {
    font-size: 16px;
    min-width: 60px;
  }

  .ceca-obra-social__bar-year {
    font-size: 14px;
  }

  .ceca-obra-social__nav-arrow {
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 768px) {
  .ceca-obra-social__side-panel {
    display: none;
  }
  .ceca-obra-social__cards {
    flex-direction: column;
  }

  .ceca-obra-social__card {
    flex: 1 1 100%;
    min-height: 120px;
  }

  .ceca-obra-social__card-value {
    font-size: 26px;
  }

  .ceca-obra-social__chart {
    height: 300px;
    padding: 20px;
  }

  .ceca-obra-social__chart-subtitle {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .ceca-obra-social__bar-value {
    font-size: 13px;
    min-width: 50px;
  }

  .ceca-obra-social__bar-year {
    font-size: 12px;
  }

  .ceca-obra-social__nav {
    flex-direction: column;
    gap: 12px;
  }

  .ceca-obra-social__nav-label {
    font-size: 18px;
  }

  .ceca-obra-social__nav-arrow {
    width: 48px;
    height: 48px;
  }
}

/* ── Elementor Editor ─────────────────────── */
.elementor-editor-active .ceca-obra-social__bar {
  transition: none;
}

.ceca-obra-social__empty {
  text-align: center;
  padding: 40px;
  background: #f9f9f9;
  color: #666;
  font-size: 15px;
}
