/* Deep Aries - Stock Dashboard Styles */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --card: #ffffff;
  --border: #e2e8f0;
  --muted: #4a5568;
  --muted2: #718096;
  --background: #fafafa;
  --text: #1a202c;
  --tab-active: #2563eb;
  --tab-inactive: #64748b;
  --metric-bg: #f8fafc;
}

/* Tab and Card Descriptions */
.tab-description {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-description h3 {
  margin: 0 0 10px 0;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 600;
}

.tab-description p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.card-description {
  color: var(--muted2);
  font-size: 0.9rem;
  margin: 0 0 15px 0;
  line-height: 1.5;
  padding: 0 5px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  padding: 20px;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.badge {
  padding: 6px 12px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Grid Layout */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
}

@media (min-width: 1200px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Force single-column layout in Portfolio tab */
  #portfolio .grid {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 1600px) {
  .grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  /* Force single-column layout in Portfolio tab */
  #portfolio .grid {
    grid-template-columns: 1fr !important;
  }
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--muted);
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 12px 0 16px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 12px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

/* Portfolio controls layout: keep date inputs inline and aligned */
#portfolio .controls { flex-wrap: nowrap; gap: 10px; }
#portfolio .controls label { white-space: nowrap; }
#portfolio .controls input[type="date"],
#portfolio .controls select,
#portfolio .controls button { height: 36px; line-height: 36px; padding: 0 10px; }
#portfolio .controls input[type="date"] { min-width: 140px; }

.controls label {
  font-weight: 500;
  color: var(--muted);
  font-size: 14px;
}

select, button {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 14px;
  transition: all 0.2s ease;
}

select:focus, button:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select[multiple] {
  min-width: 280px;
  min-height: 120px;
}

button {
  cursor: pointer;
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 500;
}

button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

/* Layout */
.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.row .half {
  flex: 1 1 380px;
}

/* Typography */
.note {
  font-size: 13px;
  color: var(--muted);
  margin: 8px 0;
  padding: 12px;
  background: #f1f5f9;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
}

.mono {
  font-family: ui-monospace, 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Footer */
footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  color: var(--muted2);
  font-size: 14px;
  text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }
  
  header h1 {
    font-size: 1.5rem;
  }
  
  .card {
    padding: 20px;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls > * {
    width: 100%;
  }
}

/* Loading States */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
}

.loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error States */
.error {
  color: var(--error);
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
}

/* Success States */
.success {
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
}

/* Academic Introduction Styles */
.academic-intro {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 16px;
  padding: 32px;
  margin: 24px 0;
  border: 1px solid var(--border);
}

.academic-intro h2 {
  color: var(--primary);
  font-size: 2rem;
  margin-bottom: 16px;
  text-align: center;
}

.research-description {
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text);
  text-align: center;
  margin-bottom: 32px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.research-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

.highlight-card {
  background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border-left: 4px solid var(--primary);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.highlight-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.highlight-card h3 {
  color: var(--primary);
  font-size: 1.2rem;
  margin-bottom: 12px;
  font-weight: 600;
}

.highlight-card p {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.paper-info {
  background: white;
  padding: 24px;
  border-radius: 12px;
  border: 2px solid var(--primary);
  margin-top: 32px;
  text-align: center;
}

.paper-info h3 {
  color: var(--primary);
  margin-bottom: 16px;
  font-size: 1.3rem;
}

.paper-info p {
  margin: 8px 0;
  color: var(--text);
}

.paper-info em {
  color: var(--muted);
  font-style: italic;
}

.paper-info strong {
  color: var(--primary);
  font-weight: 600;
}

.publication-details {
  background: #f8fafc;
  padding: 20px;
  border-radius: 8px;
  margin: 16px 0;
  border-left: 4px solid var(--primary);
}

.publication-details p {
  margin: 8px 0;
  font-size: 14px;
}

.research-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}

.research-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.research-link:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.conference-badge {
  text-align: center;
  margin: 16px 0;
}

.accepted-badge {
  display: inline-block;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.demo-description {
  background: #f1f5f9;
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
  border-left: 4px solid var(--accent);
  font-size: 14px;
  line-height: 1.6;
}

.demo-description p {
  margin: 0;
}

/* Tab Navigation */
.tabs {
  display: flex;
  gap: 4px;
  margin: 24px 0;
  padding: 0 20px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
}

.tab-button {
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: var(--tab-inactive);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.tab-button:hover {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

.tab-button.active {
  color: var(--tab-active);
  background: rgba(37, 99, 235, 0.1);
  border-bottom-color: var(--tab-active);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Chart Containers */
.chart-container {
  min-height: 350px;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: white;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Performance Metrics */
.performance-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
  padding: 20px;
  background: var(--metric-bg);
  border-radius: 12px;
}

.metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.metric-value.positive {
  color: var(--success);
}

.metric-value.negative {
  color: var(--error);
}

/* Tooltip using title attribute fallback and data-tip (for consistent look) */
.metric[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,0.9);
  color: #fff;
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  pointer-events: none;
}

/* Performance summary layout */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.summary-grid .summary-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.summary-grid .summary-title { font-weight: 600; margin-bottom: 8px; }
.summary-grid .summary-row { font-size: 14px; margin: 4px 0; }

/* Risk Metrics Grid */
.risk-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.risk-metrics {
  display: flex;
  gap: 20px;
  margin: 16px 0;
  flex-wrap: wrap;
}

/* News Feed */
.news-feed {
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  background: var(--metric-bg);
  border-radius: 8px;
}

.news-item {
  padding: 16px;
  margin-bottom: 12px;
  background: white;
  border-radius: 8px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.news-item h4 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--text);
}

.news-item p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted2);
}

.sentiment-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.sentiment-positive {
  background: #dcfce7;
  color: #166534;
}

.sentiment-negative {
  background: #fef2f2;
  color: #991b1b;
}

.sentiment-neutral {
  background: #f3f4f6;
  color: #374151;
}

/* Input Fields */
input[type="number"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 120px;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Fullscreen Modal */
.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.fullscreen-modal.active {
  display: flex;
}

.fullscreen-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
}

.close-fullscreen {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--error);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Export Buttons */
.export-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.export-btn {
  padding: 6px 12px;
  background: var(--success);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* Loading States for Charts */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  font-size: 14px;
}

.chart-loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 12px;
}

/* Responsive Design Updates */
@media (max-width: 768px) {
  .tabs {
    padding: 0 16px;
  }
  
  .tab-button {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .performance-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .metric {
    padding: 12px;
  }
  
  .metric-value {
    font-size: 20px;
  }
  
  .risk-metrics {
    flex-direction: column;
    gap: 12px;
  }
  
  .chart-container {
    min-height: 300px;
    padding: 12px;
  }
  
  .card {
    min-height: 350px;
    padding: 16px;
  }
  
  .fullscreen-content {
    padding: 16px;
    max-width: 95vw;
    max-height: 95vh;
  }
}

@media (max-width: 480px) {
  .performance-metrics {
    grid-template-columns: 1fr;
  }
  
  .tab-button {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls > * {
    width: 100%;
    margin-bottom: 8px;
  }
}

/* DeepAries Core Features Styles */
.deeparies-section {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid var(--primary);
  border-radius: 16px;
  text-align: center;
  margin: 32px 0;
}

.deeparies-section h2 {
  color: var(--primary);
  font-size: 1.8rem;
  margin-bottom: 12px;
  font-weight: 700;
}

.deeparies-section .note {
  background: rgba(37, 99, 235, 0.1);
  border-left: 4px solid var(--primary);
  color: var(--primary);
  font-weight: 500;
  margin: 0;
}

/* Enhanced Chart Containers for DeepAries */
#rebalancing_timeline,
#performance_comparison,
#rebalancing_frequency,
#market_condition_detection,
#portfolio_weights_change {
  min-height: 450px;
  border: 2px solid var(--primary);
  border-radius: 12px;
  background: linear-gradient(135deg, #fafafa 0%, #f8fafc 100%);
}

/* Make portfolio charts taller for single-column view */
#portfolio .chart-container { min-height: 520px; }

/* Special styling for DeepAries charts */
.deeparies-section + .card {
  border: 2px solid var(--primary);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.deeparies-section + .card h2 {
  color: var(--primary);
  font-weight: 700;
}

.deeparies-section + .card .note {
  background: rgba(37, 99, 235, 0.1);
  border-left: 4px solid var(--primary);
  color: var(--primary);
  font-weight: 500;
}
