/* Professional control styling */
.chart-controls {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid #2a2d3a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chart-controls .form-label {
  color: #e6edf3;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.chart-controls .form-select {
  background: rgba(42, 42, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e6edf3;
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.chart-controls .form-select:focus {
  background: rgba(42, 42, 42, 0.9);
  border-color: #79c0ff;
  box-shadow: 0 0 0 0.2rem rgba(121, 192, 255, 0.25);
  color: #e6edf3;
}

.chart-controls .form-select option {
  background: #1a1a2e;
  color: #e6edf3;
}

.chart-controls .btn {
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
}

.chart-controls .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.chart-controls .btn:active {
  transform: translateY(0);
}

/* Enhanced button states */
.btn-success {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.btn-success:hover {
  background: linear-gradient(135deg, #218838 0%, #1aa085 100%);
}

.btn-warning {
  background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
  color: #212529;
}

.btn-warning:hover {
  background: linear-gradient(135deg, #e0a800 0%, #d39e00 100%);
}

.btn-danger {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #bd2130 0%, #a02622 100%);
}

/* Loading overlay for chart */
#chartLoadingOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 18, 32, 0.8);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 6px;
}

#chartLoadingOverlay .text-muted {
  color: #8b949e;
  text-align: center;
  font-size: 0.9rem;
}

#chartLoadingOverlay i {
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

/* Enhanced live update indicator */
#liveUpdateIndicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.9) 0%, rgba(34, 197, 94, 0.9) 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Professional error styling */
.alert-danger {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(176, 58, 46, 0.1) 100%);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: 8px;
  color: #ff6b7d;
  backdrop-filter: blur(10px);
}

.alert-danger i {
  color: #ff6b7d;
  margin-right: 0.5rem;
}

/* Smooth transitions for all interactive elements */
.chart-container *,
.chart-controls *,
#indicatorModal * {
  transition: all 0.2s ease;
}

/* Enhanced focus states for accessibility */
.chart-controls .form-select:focus,
.chart-controls .btn:focus {
  outline: 2px solid #79c0ff;
  outline-offset: 2px;
}

/* Professional scrollbar styling */
.chart-container::-webkit-scrollbar,
.indicator-tab-content::-webkit-scrollbar {
  width: 6px;
}

.chart-container::-webkit-scrollbar-track,
.indicator-tab-content::-webkit-scrollbar-track {
  background: rgba(31, 38, 51, 0.5);
  border-radius: 3px;
}

.chart-container::-webkit-scrollbar-thumb,
.indicator-tab-content::-webkit-scrollbar-thumb {
  background: rgba(209, 212, 220, 0.3);
  border-radius: 3px;
}

.chart-container::-webkit-scrollbar-thumb:hover,
.indicator-tab-content::-webkit-scrollbar-thumb:hover {
  background: rgba(209, 212, 220, 0.5);
}

.chart-panel {
  background: #0b1220;
  border: 1px solid #1f2633;
  border-radius: 6px;
  padding: 0;
  overflow: hidden;
  width: 100%;
  min-height: 200px; /* Minimum height for each panel */
  flex-shrink: 0; /* Prevent shrinking */
}

/* Main price chart should be double the height of subplots */
#pricePanel {
  flex: 3; /* Increased from 2 to 3 for better visual appeal */
  min-height: 500px; /* Increased from 400px for better visual appeal */
}

/* Subplot panels should have equal height */
.chart-panel:not(#pricePanel) {
  flex: 1; /* Equal height for all subplots */
  min-height: 200px; /* Minimum height for subplots */
}

.chart-canvas {
  width: 100%;
  height: 100%;
}

/* Ensure sizing accounts for borders */
.chart-container, .chart-panel, .chart-canvas { box-sizing: border-box; }

@media (min-width: 1200px) {
  .chart-container { gap: 12px; }
}

/* Search bar styling */
.indicator-search-container {
  padding: 0.75rem;
  background: rgba(42, 42, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.indicator-search-container .input-group-text {
  background: rgba(54, 65, 82, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e6edf3 !important;
}

.indicator-search-container .form-control {
  background: rgba(26, 26, 26, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e6edf3 !important;
}

.indicator-search-container .form-control:focus {
  background: rgba(26, 26, 26, 0.9) !important;
  border-color: #79c0ff !important;
  box-shadow: 0 0 0 0.2rem rgba(121, 192, 255, 0.25) !important;
  color: #e6edf3 !important;
}

.indicator-search-container .form-control::placeholder {
  color: #8b949e !important;
}

.indicator-search-container .btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #8b949e !important;
}

.indicator-search-container .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #e6edf3 !important;
}

/* No search results styling */
.no-search-results {
  color: #8b949e !important;
  font-size: 0.8rem;
}

.no-search-results i {
  color: #6c757d;
}

/* Modal sizing and transparency */
#indicatorModal .modal-dialog {
  max-width: 800px;
  margin: 2rem auto;
  transform: translateY(-50%);
  top: 50%;
}

#indicatorModal .modal-content {
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

#indicatorModal .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
}

#indicatorModal .modal-header {
  background: rgba(42, 42, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 0.75rem;
  border-radius: 12px 12px 0 0;
}

#indicatorModal .modal-title {
  color: #e6edf3;
  font-weight: 600;
  font-size: 0.8rem;
  margin: 0;
}

#indicatorModal .modal-body {
  background: transparent;
  padding: 0;
  max-height: 60vh;
  overflow: hidden;
}

/* Tab navigation - two-row layout */
.indicator-tabs {
  background: rgba(42, 42, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.indicator-tabs-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  justify-content: center;
}

.indicator-tabs-row::-webkit-scrollbar {
  display: none;
}

.indicator-tab {
  background: transparent;
  border: none;
  color: #8b949e;
  padding: 0.4rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  flex-shrink: 0;
}

.indicator-tab:hover {
  color: #e6edf3;
  background: rgba(255, 255, 255, 0.05);
}

.indicator-tab.active {
  color: #79c0ff;
  border-bottom-color: #79c0ff;
  background: rgba(102, 126, 234, 0.1);
}

/* Tab content - ultra compact grid */
.indicator-tab-content {
  padding: 0.5rem;
  max-height: 50vh;
  overflow-y: auto;
}

.indicator-tab-pane {
  display: none;
}

.indicator-tab-pane.active {
  display: block;
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.2rem;
  margin: 0;
}

/* Ultra compact indicator items */
.indicator-item {
  background: rgba(42, 42, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  transition: all 0.15s ease;
  height: 45px;
  cursor: pointer;
}

.indicator-item:hover {
  border-color: rgba(102, 126, 234, 0.3);
  background: rgba(42, 42, 42, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.indicator-item .card-body {
  padding: 0.3rem !important;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  height: 100%;
}

/* Compact checkbox */
.indicator-checkbox {
  margin: 0;
  transform: scale(0.7);
  flex-shrink: 0;
}

.indicator-checkbox:checked {
  background-color: #79c0ff;
  border-color: #79c0ff;
}

/* Ultra compact text */
.indicator-title {
  font-size: 0.65rem;
  font-weight: 600;
  color: #e6edf3;
  margin: 0;
  line-height: 1.2;
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indicator-meta {
  font-size: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-top: 0.1rem;
}

.indicator-type {
  font-size: 0.55rem;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.indicator-color {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

/* Modal footer - minimal */
#indicatorModal .modal-footer {
  background: rgba(42, 42, 42, 0.8);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.75rem;
  justify-content: space-between;
  border-radius: 0 0 12px 12px;
}

#indicatorModal .modal-footer .btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  min-width: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #indicatorModal .modal-dialog {
    max-width: 95vw;
    margin: 1rem auto;
  }

  .indicator-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.15rem;
  }

  .indicator-item {
    height: 45px;
  }

  .indicator-item .card-body {
    padding: 0.25rem !important;
    gap: 0.25rem;
  }

  .indicator-title {
    font-size: 0.65rem;
  }

  .indicator-meta {
    font-size: 0.6rem;
  }

  .indicator-search-container {
    padding: 0.5rem;
  }

  /* Mobile: single row for tabs */
  .indicator-tabs-row {
    justify-content: flex-start;
  }

  .indicator-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
  }
}

@media (max-width: 576px) {
  .indicator-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.1rem;
  }

  .indicator-item {
    height: 42px;
  }

  .indicator-tabs-row {
    padding: 0 0.25rem;
  }

  .indicator-tab {
    padding: 0.375rem 0.5rem;
    font-size: 0.7rem;
  }

  .indicator-search-container .input-group {
    flex-wrap: nowrap;
  }

  .indicator-search-container .form-control {
    font-size: 0.75rem;
  }
}

/* Active indicator highlighting */
.indicator-item .indicator-checkbox:checked ~ .indicator-title {
  color: #79c0ff;
  font-weight: 700;
}

.indicator-item .indicator-checkbox:checked {
  box-shadow: 0 0 0 2px rgba(121, 192, 255, 0.3);
}

/* Loading state */
.indicator-loading {
  opacity: 0.6;
  pointer-events: none;
}

.indicator-loading .indicator-grid {
  position: relative;
}

.indicator-loading .indicator-grid::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #79c0ff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
