/* ============================================================
   WOI — Premium timeframe segmented control
   ============================================================ */

.woi-timeframe-selector {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

.woi-timeframe-selector-title {
  color: #64748b;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/*
 * Dash RadioItems wrapper
 */
.woi-timeframe-radio {
  display: inline-flex !important;
  align-items: center;
  gap: 2px;
  padding: 3px;
  margin: 0;
  border: 1px solid #1e293b;
  border-radius: 9px;
  background: #080f19;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025),
    0 1px 2px rgba(0, 0, 0, 0.24);
}

/*
 * Override the inline label styles supplied by Dash.
 */
.woi-timeframe-radio label {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 9px;
  margin: 0 !important;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #94a3b8;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition:
    color 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 100ms ease;
}

/*
 * Hide native browser radio circles.
 */
.woi-timeframe-radio input[type="radio"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  pointer-events: none;
}

/*
 * Hover state
 */
.woi-timeframe-radio label:hover {
  color: #e2e8f0;
  background: #101a28;
  border-color: #243247;
}

/*
 * Active timeframe
 */
.woi-timeframe-radio label:has(input[type="radio"]:checked) {
  color: #f8fafc;
  background:
    linear-gradient(
      180deg,
      rgba(37, 99, 235, 0.96),
      rgba(30, 64, 175, 0.96)
    );
  border-color: #60a5fa;
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.18),
    0 3px 9px rgba(37, 99, 235, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/*
 * Keyboard accessibility
 */
.woi-timeframe-radio label:has(input[type="radio"]:focus-visible) {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/*
 * Press feedback
 */
.woi-timeframe-radio label:active {
  transform: translateY(1px);
}

/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 768px) {
  .woi-timeframe-selector {
    gap: 5px;
  }

  .woi-timeframe-selector-title {
    display: none;
  }

  .woi-timeframe-radio {
    gap: 1px;
    padding: 2px;
    border-radius: 8px;
  }

  .woi-timeframe-radio label {
    min-width: 31px;
    height: 25px;
    padding: 0 7px;
    border-radius: 6px;
    font-size: 10px;
  }
}


/* ============================================================
   Mobile compactness and collision protection
   ============================================================ */

@media (max-width: 768px) {
  .woi-timeframe-selector {
    display: inline-flex !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 3px 0 0 !important;
    overflow: visible !important;
  }

  .woi-timeframe-radio {
    display: inline-grid !important;
    grid-template-columns: repeat(3, 30px);
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    box-sizing: border-box;
    gap: 1px !important;
    padding: 2px !important;
    overflow: hidden;
  }

  .woi-timeframe-radio label {
    display: inline-flex !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 25px !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box;
    justify-content: center;
  }

  /*
   * Prevent the adjacent Chart dropdown from visually covering 1W.
   */
  .woi-chart-type-menu {
    flex: 0 0 auto !important;
    margin-left: 2px !important;
    position: relative;
  }

  .woi-chart-type-menu .woi-indicator-trigger {
    min-width: 82px !important;
    padding-left: 8px !important;
    padding-right: 7px !important;
  }

  /*
   * Keep timeframe and dropdowns in one clean horizontal group.
   */
  .woi-overlay-controls {
    column-gap: 4px !important;
  }
}


/* Extra narrow phones */

@media (max-width: 430px) {
  .woi-timeframe-radio {
    grid-template-columns: repeat(3, 28px);
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
  }

  .woi-timeframe-radio label {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    font-size: 9px !important;
  }

  .woi-chart-type-menu .woi-indicator-trigger {
    min-width: 76px !important;
    padding-left: 7px !important;
    padding-right: 6px !important;
  }
}


/* ============================================================
   Desktop: place TIMEFRAME as a thin caption above the segments
   ============================================================ */

@media (min-width: 769px) {
  .woi-timeframe-selector {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    gap: 0 !important;
    padding-top: 8px;
  }

  .woi-timeframe-selector-title {
    position: absolute;
    top: 0;
    left: 4px;
    z-index: 1;
    color: #7dd3fc;
    font-size: 7px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.11em;
    pointer-events: none;
  }

  .woi-timeframe-radio {
    margin: 0 !important;
  }
}
