/**
 * Indicator Modal - TradingView Style CSS
 * 
 * Design principles:
 * - Full-screen modal with blur backdrop
 * - Dark theme matching TradingView's aesthetic
 * - Smooth animations
 * - Clear visual hierarchy
 */

/* ============================================================================
   MODAL BACKDROP & CONTAINER
   ============================================================================ */

.indicator-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.indicator-modal.open {
  opacity: 1;
  visibility: visible;
}

.indicator-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.indicator-modal-content {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: #1e222d;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(-10px);
  transition: transform 0.2s ease;
}

.indicator-modal.open .indicator-modal-content {
  transform: scale(1) translateY(0);
}

/* ============================================================================
   HEADER
   ============================================================================ */

.indicator-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.indicator-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #e0e0e0;
  letter-spacing: -0.02em;
}

.indicator-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #787b86;
  cursor: pointer;
  transition: all 0.15s ease;
}

.indicator-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e0e0e0;
}

/* ============================================================================
   SEARCH
   ============================================================================ */

.indicator-modal-search {
  position: relative;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.indicator-modal-search .search-icon {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
  color: #787b86;
  pointer-events: none;
}

.indicator-search-input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  background: #131722;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.indicator-search-input::placeholder {
  color: #787b86;
}

.indicator-search-input:focus {
  border-color: #2962ff;
  box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.15);
}

/* ============================================================================
   TABS
   ============================================================================ */

.indicator-modal-tabs {
  display: flex;
  padding: 8px 20px;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.indicator-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #787b86;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.indicator-tab.active {
  background: rgba(41, 98, 255, 0.15);
  color: #2962ff;
}

.indicator-tab svg {
  flex-shrink: 0;
}

/* ============================================================================
   LIST
   ============================================================================ */

.indicator-modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Scrollbar styling */
.indicator-modal-list::-webkit-scrollbar {
  width: 8px;
}

.indicator-modal-list::-webkit-scrollbar-track {
  background: transparent;
}

.indicator-modal-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.indicator-modal-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================================================
   CATEGORY
   ============================================================================ */

.indicator-category {
  margin-bottom: 8px;
}

.indicator-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  color: #787b86;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.indicator-category-header:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #9198a1;
}

.indicator-category-header svg {
  flex-shrink: 0;
}

/* Chevron icon for collapse/expand */
.category-chevron {
  transition: transform 0.2s ease;
}

/* Collapsed state - chevron points right */
.indicator-category.collapsed .category-chevron {
  transform: rotate(-90deg);
}

/* Expanded state - chevron points down */
.indicator-category.expanded .category-chevron {
  transform: rotate(0deg);
}

.indicator-count {
  margin-left: auto;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
}

.indicator-category-items {
  display: flex;
  flex-direction: column;
}

/* ============================================================================
   INDICATOR ITEM
   ============================================================================ */

.indicator-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.indicator-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.indicator-item.active {
  background: rgba(41, 98, 255, 0.08);
}

/* Star button */
.indicator-star {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: #787b86;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.indicator-star:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fbbf24;
}

.indicator-star.favorited {
  color: #fbbf24;
}

/* Info section */
.indicator-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.indicator-name {
  color: #e0e0e0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.indicator-desc {
  color: #787b86;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Type badge */
.indicator-type {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.indicator-type.overlay {
  background: rgba(38, 166, 154, 0.15);
  color: #26a69a;
}

.indicator-type.subplot {
  background: rgba(255, 152, 0, 0.15);
  color: #ff9800;
}

.indicator-type.group {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

/* Group indicator item special styling */
.indicator-item.is-group {
  background: rgba(139, 92, 246, 0.05);
  border-left: 2px solid rgba(139, 92, 246, 0.4);
}

.indicator-item.is-group:hover {
  background: rgba(139, 92, 246, 0.1);
}

/* Check mark */
.indicator-check {
  flex-shrink: 0;
  margin-left: 4px;
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.indicator-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
}

.indicator-empty p {
  margin: 0;
  color: #787b86;
  font-size: 14px;
}

.indicator-empty .hint {
  margin-top: 8px;
  font-size: 12px;
  color: #565a64;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 640px) {
  .indicator-modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .indicator-modal-header {
    padding: 14px 16px;
  }
  
  .indicator-modal-search {
    padding: 10px 16px;
  }
  
  .indicator-modal-search .search-icon {
    left: 28px;
  }
  
  .indicator-modal-tabs {
    padding: 6px 16px;
  }
  
  .indicator-item {
    padding: 10px 16px;
  }
  
  .indicator-category-header {
    padding: 8px 16px;
  }
  
  .indicator-type {
    display: none;
  }
}

/* ============================================================================
   ACTIVE SECTION
   ============================================================================ */

.indicator-category.active-section {
  border-bottom: 1px solid rgba(34, 197, 94, 0.2);
  margin-bottom: 4px;
}

.indicator-category.active-section .indicator-category-header {
  background: rgba(34, 197, 94, 0.08);
}

/* ============================================================================
   COLOR SWATCH
   ============================================================================ */

.indicator-color-swatch {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-right: 8px;
}

.indicator-color-swatch:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   COLOR PICKER
   ============================================================================ */

.indicator-color-picker {
  position: absolute;
  z-index: 10000;
  background: #262932;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  padding: 12px;
  min-width: 200px;
}

.color-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.color-picker-header span {
  font-size: 13px;
  font-weight: 500;
  color: #e0e0e0;
}

.color-picker-close {
  background: none;
  border: none;
  color: #787b86;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.color-picker-close:hover {
  color: #e0e0e0;
}

.color-picker-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.color-preset {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-preset:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.4);
}

.color-picker-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.color-picker-custom label {
  font-size: 12px;
  color: #787b86;
}

.color-input {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: #1e222d;
  cursor: pointer;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.color-picker-actions {
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.color-reset {
  width: 100%;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #787b86;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-reset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
}
