/**
 * Chart Toolbar Styles
 * Provides styling for the chart toolbar buttons and expanded card state
 */

/* ============================================
   Toolbar Container
   ============================================ */
.chart-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ============================================
   Toolbar Buttons
   ============================================ */
.chart-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  background: var(--surface-overlay, rgba(20, 20, 22, 0.8));
  color: var(--text-secondary, #9ca3af);
  font-size: 13px;
  cursor: pointer;
  transition: all 150ms ease-out;
}

.chart-toolbar-btn:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.08));
  border-color: var(--border-default, rgba(255, 255, 255, 0.15));
  color: var(--text-primary, #ffffff);
}

.chart-toolbar-btn:focus-visible {
  outline: 2px solid var(--primary-500, #7C4DFF);
  outline-offset: 2px;
}

.chart-toolbar-btn:active {
  transform: scale(0.95);
}

.chart-toolbar-btn[aria-pressed="true"] {
  background: var(--primary-500, #7C4DFF);
  border-color: var(--primary-500, #7C4DFF);
  color: white;
}

.chart-toolbar-btn[aria-pressed="true"]:hover {
  background: var(--primary-600, #6B3FD4);
  border-color: var(--primary-600, #6B3FD4);
}

/* ============================================
   Expanded Chart Card State
   ============================================ */

/* Backdrop overlay - on body level to escape all stacking contexts */
body.chart-expanded::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  z-index: 99998;
  pointer-events: auto;
}

body.chart-expanded {
  overflow: hidden; /* Prevent scroll when modal open */
}

/* Legacy backdrop div - keep for click handling */
.chart-card-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99997;
  cursor: pointer;
  background: transparent; /* Visual handled by body::before */
}

/* Expanded card - TRUE fullscreen filling entire viewport */
.chart-card.is-expanded {
  position: fixed !important;
  inset: 0 !important;                    /* Fill entire viewport */
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;             /* Remove any cap */
  max-height: none !important;
  transform: none !important;             /* No centering transform */
  z-index: 99999 !important;              /* Above backdrop and everything else */
  background: var(--surface-raised, #141416) !important;
  border: none !important;                /* No border in fullscreen */
  border-radius: 0 !important;            /* No rounded corners in fullscreen */
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Ensure chart content fills the expanded card */
.chart-card.is-expanded .chart-container {
  flex: 1;
  min-height: 0;                          /* Allow flexbox to control */
  max-height: none;                       /* No constraint - fill available space */
}

.chart-card.is-expanded .chart-container svg {
  width: 100%;
  height: 100%;
}

/* Chart content wrapper should fill remaining space */
.chart-card.is-expanded > .relative,
.chart-card.is-expanded > div:not(.chart-card-header):not(.p-4) {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Expanded card header adjustments */
.chart-card.is-expanded .chart-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
}

/* Ensure toolbar is visible in expanded state */
.chart-card.is-expanded .chart-toolbar-btn {
  background: var(--surface-hover, rgba(255, 255, 255, 0.08));
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
  /* Fullscreen is already 100vw x 100vh, no changes needed for expanded state */

  .chart-toolbar-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* ============================================
   Animation for expand/collapse
   ============================================ */
@keyframes expandIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.chart-card.is-expanded {
  animation: expandIn 200ms ease-out forwards;
}

/* ============================================
   Fullscreen Overlay Component Styles
   ============================================ */

.fullscreen-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  z-index: 99998;
  cursor: pointer;
}

.fullscreen-overlay-container {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--surface-raised, #141416);
  display: flex;
  flex-direction: column;
  animation: expandIn 200ms ease-out forwards;
}

.fullscreen-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  flex-shrink: 0;
  background: var(--surface-raised, #141416);
}

.fullscreen-overlay-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #ffffff);
  margin: 0;
}

.fullscreen-overlay-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fullscreen-overlay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  background: var(--surface-overlay, rgba(20, 20, 22, 0.8));
  color: var(--text-secondary, #9ca3af);
  font-size: 14px;
  cursor: pointer;
  transition: all 150ms ease-out;
}

.fullscreen-overlay-btn:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.08));
  border-color: var(--border-default, rgba(255, 255, 255, 0.15));
  color: var(--text-primary, #ffffff);
}

.fullscreen-overlay-btn:focus-visible {
  outline: 2px solid var(--primary-500, #7C4DFF);
  outline-offset: 2px;
}

.fullscreen-overlay-close:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.fullscreen-overlay-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Ensure chart fills the body - make entire hierarchy flex */
.fullscreen-overlay-body > div {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Chart wrapper inside component should also flex */
.fullscreen-overlay-body .insider-volume-chart-wrapper,
.fullscreen-overlay-body .insider-count-chart-wrapper,
.fullscreen-overlay-body .trend-chart-wrapper,
.fullscreen-overlay-body [class*="-chart-wrapper"] {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Nested wrapper divs should also flex */
.fullscreen-overlay-body .insider-volume-chart-wrapper > div,
.fullscreen-overlay-body .insider-count-chart-wrapper > div,
.fullscreen-overlay-body .trend-chart-wrapper > div,
.fullscreen-overlay-body [class*="-chart-wrapper"] > div:not(.absolute) {
  flex: 1;
  min-height: 0;
}

/* Chart container takes remaining space */
.fullscreen-overlay-body .chart-container {
  width: 100%;
  flex: 1;
  min-height: 0;
}

.fullscreen-overlay-body svg {
  width: 100%;
  /* height: auto - use SVG's explicit height attribute from JavaScript */
}

/* ============================================
   Print styles - hide toolbar
   ============================================ */
@media print {
  .chart-toolbar {
    display: none !important;
  }

  .chart-card-backdrop {
    display: none !important;
  }

  .chart-card.is-expanded {
    position: static !important;
    inset: auto;
    box-shadow: none;
    border: none;
  }
}
