/* =============================================================================
   Stox Chart – Container Styles

   Professional styling for the TradingView Lightweight Charts widget,
   including quote header, timeframe buttons, loading & error states.

   @package    Stox_Data_Engine
   @subpackage Stox_Data_Engine/assets/css
   @since      1.3.0
   ============================================================================= */

/* --- Container ----------------------------------------------------------- */
.stox-chart-wrap {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Helvetica Neue", sans-serif;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

/* --- Quote Header (two-line instrument format) --------------------------- */
.stox-chart-header {
  padding: 16px 22px 12px;
  border-bottom: 1px solid #f1f5f9;
}

/* Line 1: Ticker  Price  Change  Star */
.stox-chart-header-line1 {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stox-chart-ticker {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.02em;
}

.stox-chart-price {
  font-size: 20px;
  font-weight: 600;
  color: #334155;
}

.stox-chart-change {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.stox-chart-change.positive {
  color: #006400;
  background: #f0fdf4;
}

.stox-chart-change.negative {
  color: #dc2626;
  background: #fef2f2;
}

.stox-chart-star {
  font-size: 20px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
  margin-left: 4px;
}

.stox-chart-star:hover {
  color: #f59e0b;
}

/* Line 2: Company name  Exchange */
.stox-chart-header-line2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
  padding-left: 0;
}

.stox-chart-name {
  font-size: 13px;
  color: #64748b;
}

.stox-chart-exchange {
  font-size: 13px;
  color: #94a3b8;
}

/* --- Timeframe Buttons --------------------------------------------------- */
.stox-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 22px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}

.stox-tf-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.stox-tf-btn:hover {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.stox-tf-btn.active {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
}

/* --- Chart Container ----------------------------------------------------- */
.stox-chart-container {
  width: 100%;
  position: relative;
}

/* --- Watermark (bordered box, top-left) ---------------------------------- */
.stox-chart-watermark {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 3px 8px;
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  pointer-events: none;
  line-height: 1.4;
}
.stox-chart-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 14px;
  color: #94a3b8;
  font-size: 14px;
}

.stox-chart-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: stox-spin 0.8s linear infinite;
}

@keyframes stox-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Error State --------------------------------------------------------- */
.stox-chart-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 10px;
  color: #ef4444;
  font-size: 14px;
  padding: 20px;
  text-align: center;
}

.stox-chart-error-icon {
  font-size: 28px;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 600px) {
  .stox-chart-header {
    padding: 12px 14px 8px;
    gap: 8px;
  }

  .stox-chart-toolbar {
    padding: 6px 14px;
    gap: 3px;
    overflow-x: auto;
  }

  .stox-tf-btn {
    padding: 4px 10px;
    font-size: 11px;
  }

  .stox-chart-ticker {
    font-size: 15px;
  }

  .stox-chart-price {
    font-size: 17px;
  }

  .stox-chart-updated {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }
}
