/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1rem;
  min-height: 300px;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 3rem;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chart-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.chart-symbol {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.chart-price {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 0.25rem;
}

.chart-change {
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-mono);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.chart-change.positive {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-success);
}

.chart-change.negative {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-danger);
}

.chart-container {
  padding: 1rem;
  height: 250px;
  position: relative;
}

/* Data Table */
.table-panel {
  flex: 1;
}

.table-container {
  max-height: 400px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: all 0.2s ease;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.company-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.company-symbol {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.price-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.875rem;
}

.change-cell {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
}

.volume-cell {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.btn-add {
  background: var(--accent-success);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-add:hover {
  background: #059669;
  box-shadow: var(--glow-success);
}

.btn-add:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--accent-danger);
  color: white;
}

.modal-body {
  padding: 1.5rem;
}

/* Enhanced Modal Styles - UPDATED PRICE SECTION */
.stock-details-container {
  padding: 0;
}

.price-overview {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  padding: 1rem 2rem; /* REDUCED from 2rem to 1rem */
  margin: -1.5rem -1.5rem 1.5rem -1.5rem; /* REDUCED bottom margin */
  color: white;
  text-align: center;
  border-radius: 0; /* Keep sharp corners for clean look */
}

.current-price h2 {
  font-size: 1.8rem; /* REDUCED from 2.5rem to 1.8rem */
  font-family: var(--font-mono);
  font-weight: 700;
  margin: 0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3); /* REDUCED shadow */
}

.price-change {
  font-size: 0.95rem; /* REDUCED from 1.1rem to 0.95rem */
  font-weight: 600;
  margin-top: 0.25rem; /* REDUCED from 0.5rem */
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.details-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  margin-top: 0.5rem; /* REDUCED from 1rem */
}

.chart-section h3,
.info-section h3 {
  color: var(--accent-primary);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-chart-container {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  height: 280px; /* SLIGHTLY REDUCED from 300px */
  position: relative;
}

.modal-chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.company-info {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}

.info-grid {
  margin-bottom: 1.5rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.info-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

.company-description {
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.company-description h4 {
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.company-description p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
}

.modal-actions {
  margin-top: 2rem;
  text-align: center;
}

.btn-action {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-action:hover {
  background: var(--accent-secondary);
  transform: translateY(-1px);
  box-shadow: var(--glow-primary);
}

.btn-remove-modal {
  background: var(--accent-danger);
}

.btn-remove-modal:hover {
  background: #dc2626;
  box-shadow: var(--glow-danger);
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader {
  width: 60px;
  height: 60px;
  position: relative;
  margin-bottom: 2rem;
}

.loader-inner {
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: var(--glow-primary);
}

.loading-screen p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: var(--font-mono);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Make table rows clearly clickable */
.data-table tbody tr {
  transition: all 0.2s ease;
  cursor: pointer !important;
  border-left: 3px solid transparent;
}

.data-table tbody tr:hover {
  background: var(--bg-tertiary) !important;
  border-left-color: var(--accent-primary);
  transform: translateX(2px);
}

.stock-row {
  cursor: pointer !important;
}

.stock-row:hover .company-name {
  color: var(--accent-primary) !important;
}

/* Responsive Modal */
@media (max-width: 768px) {
  .details-grid {
    grid-template-columns: 1fr;
  }
  
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  
  .price-overview {
    padding: 0.75rem 1.5rem; /* FURTHER REDUCED for mobile */
  }
  
  .current-price h2 {
    font-size: 1.5rem; /* SMALLER on mobile */
  }
  
  .price-change {
    font-size: 0.875rem; /* SMALLER on mobile */
  }
  
  .modal-chart-container {
    height: 220px; /* SMALLER on mobile */
  }

  .modal-content {
    max-width: 95%;
    margin: 1rem;
  }

  .modal {
    padding: 1rem;
  }
}

/* Responsive Tables */
@media (max-width: 768px) {
  .data-table {
    font-size: 0.75rem;
  }
  
  .data-table th,
  .data-table td {
    padding: 0.5rem;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-container {
    height: 200px;
  }
}
