/* Stock Market Specific Styles */

/* Market header */
.market-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding: 15px 20px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 12px;
  border: 1px solid #334155;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 60px;
  z-index: 100;
}

.market-title-section {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.market-header h3 {
  font-size: 20px;
  color: #e2e8f0;
  font-weight: 700;
  margin-right: 8px;
}

.market-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background-color: rgba(16, 185, 129, 0.15);
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-indicator {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
  }
  50% {
    opacity: 0.6;
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.3);
  }
}

.status-text {
  font-size: 11px;
  color: #10b981;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Market stats in header */
.market-stats {
  display: flex;
  gap: 15px;
}

.market-stat-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 130px;
  text-align: center;
}

.stat-card-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  margin-bottom: 5px;
}

.stat-card-value {
  font-size: 17px;
  color: #10b981;
  font-weight: 700;
}

.stat-card-value.negative {
  color: #ef4444;
}

.stockmarket-container {
  display: flex;
  gap: 20px;
  padding: 20px;
  height: 600px;
}

/* Connect settings and graph backgrounds into a single panel */
.stockmarket-container {
  background-color: #29283c;
  border-radius: 12px;
  padding: 12px;
  gap: 16px;
  align-items: stretch;
}

/* Graph container with header */
.stockmarket-graph-container {
  flex: 1;
  background-color: transparent;
  border-radius: 8px 0 0 8px;
  padding: 12px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  order: -1;
  min-height: 500px;
}

.graph-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

/* Slow time button */
.slow-time-btn {
  padding: 5px 10px;
  background-color: #0ea5e9;
  color: #cbd5e1;
  border: 1px solid #3e3e5a;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.slow-time-btn:hover {
  background-color: #0984bc;
  color: #012;
  background-color: #0984bc;
}

/* Risk Selector Panel */
.risk-selector-panel {
  background: rgba(51, 65, 85, 0.4);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px 16px;
  margin: 12px 0;
  box-sizing: border-box;
}

.risk-title {
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.risk-buttons {
  display: flex;
  gap: 8px;
  justify-content: stretch;
  width: 100%;
}

.risk-btn {
  flex: 1 1 0;
  width: 100%;
  max-width: none;
  padding: 10px 14px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  line-height: 1.3;
}

.risk-btn:hover {
  background: rgba(71, 85, 105, 0.3);
  border-color: #64748b;
}

.risk-btn.active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.risk-btn.active#risk-low {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
}

.risk-btn.active#risk-high {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
}

.risk-desc {
  display: block;
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 2px;
  font-weight: 500;
}

.graph-title {
  margin: 0;
  color: #e2e8f0;
  font-size: 18px;
  font-weight: 700;
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  min-height: 0;
}

#stockmarket-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #0d0f14;
  border-radius: 8px;
  border: 2px solid #232936;
}

/* Time filter buttons */
.time-filter-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.time-filter-btn {
  padding: 5px 10px;
  background-color: #1e1e2f;
  color: #cbd5e1;
  border: 1px solid #3e3e5a;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.time-filter-btn:hover {
  background-color: #2a2a3e;
  border-color: #0ea5e9;
}

.time-filter-btn.active {
  background-color: #0ea5e9;
  color: #012;
  border-color: #0ea5e9;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.3);
}

/* Settings sidebar */
.stockmarket-settings {
  width: 250px;
  background-color: transparent;
  border-radius: 0 8px 8px 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: none;
  border-left: 1px solid rgba(255,255,255,0.03);
  overflow-y: auto;
}

/* Card styles */
.settings-card, .trading-card, .portfolio-card, .sell-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.4) 0%, rgba(15, 23, 42, 0.4) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px;
}

.card-title {
  margin: 0 0 10px 0;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Setting row */
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  position: relative;
}

.setting-row label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.setting-row input {
  padding: 8px 10px;
  background-color: #1e1e2f;
  border: 1px solid #3e3e5a;
  color: #e6eef8;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.setting-row input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.2);
}

/* Input with button container */
.input-with-button {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-with-button input {
  flex: 1;
  min-width: 0;
  width: auto;
}

.max-btn {
  padding: 10px 16px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.max-btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.4);
}

.max-btn:active {
  transform: translateY(0);
}

.input-suffix {
  position: absolute;
  right: 12px;
  top: 34px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.time-conversion {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
  font-size: 10px;
  font-style: italic;
  text-align: center;
}

/* Cost display */
.cost-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 6px;
  margin-bottom: 8px;
}

.cost-label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cost-value {
  color: #10b981;
  font-size: 14px;
  font-weight: 700;
}

/* Portfolio stats */
.portfolio-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portfolio-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 9px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
}

.portfolio-row.highlight {
  background-color: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.portfolio-row.profit-loss {
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.portfolio-row.total {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 12px 10px;
  margin-top: 6px;
}

.portfolio-label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
}

.portfolio-value {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 700;
}

.portfolio-value-large {
  color: #10b981;
  font-size: 15px;
  font-weight: 700;
}

/* Buttons */
.buy-button, .sell-button, .sell-button-secondary, .reset-button {
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.button-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.button-group .buy-button {
  flex: 1;
  width: auto;
}

.button-group .sell-button {
  flex: 1;
  width: auto;
}

.buy-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
}

.buy-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

.sell-button {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
}

.sell-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(239, 68, 68, 0.4);
}

.sell-button-secondary {
  background-color: #1e1e2f;
  color: #ef4444;
  border: 1px solid #ef4444;
}

.sell-button-secondary:hover {
  background-color: #ef4444;
  color: white;
}

/* Percentage buttons for selling */
.sell-percentage-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 10px;
}

.percentage-btn {
  padding: 6px 5px;
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.percentage-btn:hover {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  transform: translateY(-1px);
}

.percentage-btn:active {
  transform: translateY(0);
}

/* Sell buttons row */
.sell-buttons-row {
  display: flex;
  gap: 8px;
}

.reset-button {
  width: 100%;
  background-color: #64748b;
  color: white;
  margin-top: 4px;
}

.reset-button:hover {
  background-color: #475569;
  transform: translateY(-1px);
}

/* Legacy styles (kept for compatibility) */

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.time-filter-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.time-filter-btn {
  padding: 8px 16px;
  background-color: #334155;
  color: #cbd5e1;
  border: 1px solid #475569;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.time-filter-btn:hover {
  background-color: #475569;
  border-color: #64748b;
}

.time-filter-btn.active {
  background-color: #10b981;
  border-color: #10b981;
  color: #fff;
}

.info-section {
  color: #cbd5e1;
}

.info-section h3 {
  margin-bottom: 15px;
  font-size: 18px;
}

.info-section ul {
  list-style: none;
  padding: 0;
}

.info-section li {
  margin-bottom: 12px;
  padding-left: 20px;
  position: relative;
}

.info-section li:before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #10b981;
}

/* Responsive styles */
@media (max-width: 1200px) {
  .market-header {
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
  }
  
  .market-title-section {
    justify-content: space-between;
    width: 100%;
  }
  
  .market-stats {
    justify-content: space-between;
    width: 100%;
  }
  
  .market-stat-card {
    flex: 1;
    min-width: 0;
    padding: 9px 13px;
  }
  
  .stat-card-label {
    font-size: 9px;
  }
  
  .stat-card-value {
    font-size: 15px;
  }
}

@media (max-width: 900px) {
  .market-header h3 {
    font-size: 18px;
  }
  
  .market-stat-card {
    padding: 8px 12px;
  }
  
  .stat-card-label {
    font-size: 9px;
  }
  
  .stat-card-value {
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  .market-header {
    padding: 12px 15px;
  }
  
  .market-title-section {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
  
  .market-stats {
    gap: 10px;
  }
  
  .market-stat-card {
    padding: 8px 12px;
  }
  
  .stat-card-value {
    font-size: 13px;
  }
  
  .time-filter-buttons {
    gap: 6px;
  }
  
  .time-filter-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
  
  .stockmarket-container {
    flex-direction: column;
    height: auto;
  }

  .stockmarket-settings {
    width: 100%;
  }

  .stockmarket-graph-container {
    min-width: 100%;
    height: 400px;
  }
}

/* Statistics Button */
.stats-button {
  width: 100%;
  padding: 10px 14px;
  margin-top: 8px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 6px rgba(251, 191, 36, 0.3);
}

.stats-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(251, 191, 36, 0.5);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.stats-button:active {
  transform: translateY(0);
}

/* Statistics Modal */
.stats-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(3px);
}

.stats-modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 15px;
  padding: 25px;
  width: 650px;
  height: 550px;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
}

.stats-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

.stats-modal-header h2 {
  color: #ffd700;
  font-size: 28px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-modal-close {
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.2), rgba(220, 38, 38, 0.3));
  border: 2px solid #ff3b30;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(255, 59, 48, 0.3);
}

.stats-modal-close:hover {
  background: linear-gradient(135deg, #ff3b30, #dc2626);
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 6px 12px rgba(255, 59, 48, 0.5);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  padding: 20px;
  transition: all 0.3s ease;
}

.stat-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 215, 0, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(255, 215, 0, 0.1);
}

.stat-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.stat-icon {
  font-size: 24px;
}

.stat-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  color: #ffd700;
  font-size: 28px;
  font-weight: bold;
  display: block;
  margin-top: 5px;
}

@media (max-width: 480px) {
  .market-stats {
    flex-direction: column;
    gap: 8px;
  }
  
  .market-stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }
  
  .stat-card-label {
    margin-bottom: 0;
  }
  
  .stats-modal-content {
    padding: 20px;
    width: 95%;
    height: 80vh;
  }
  
  .stats-modal-header h2 {
    font-size: 22px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .stat-value {
    font-size: 24px;
  }
}