/* ============================================
   LifeQuantified Portfolio Tracker - Styles
   Extracted from ACTUAL current index.html
   ============================================ */

/* Import Google Fonts for professional typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  color: #1e293b;
  line-height: 1.6;
}

/* Professional container styling */
.portfolio-container {
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

/* Enhanced table styling */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  background: white;
}

/* Sortable table header styles */
.sortable-header {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s ease;
}

.sortable-header:hover {
  background: linear-gradient(135deg, #5a6477 0%, #404859 100%);
}

.sortable-header::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid rgba(255, 255, 255, 0.4);
  opacity: 0.7;
}

.sortable-header.sort-asc::after {
  border-bottom: 6px solid rgba(255, 255, 255, 0.9);
  border-top: none;
  opacity: 1;
}

.sortable-header.sort-desc::after {
  border-top: 6px solid rgba(255, 255, 255, 0.9);
  border-bottom: none;
  opacity: 1;
}

.sortable-header.sort-active {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.portfolio-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1200px; /* Ensure minimum width for proper display */
}

.portfolio-table th {
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  color: white;
  font-weight: 600;
  font-size: 0.75rem; /* Reduced from 0.875rem */
  text-align: left;
  padding: 10px 8px; /* Reduced from 16px 12px */
  border-bottom: 2px solid #334155;
  vertical-align: top;
  line-height: 1.2;

  /* FIX: avoid conflict with sorting by removing header resize/cursor override */
  /* removed: resize: horizontal; cursor: col-resize; */
}

.portfolio-table td {
  padding: 8px; /* Reduced from 14px 12px */
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.75rem; /* Reduced from 0.875rem */
  vertical-align: middle;
  white-space: nowrap;
}

.portfolio-table tbody tr:hover {
  background-color: #f8fafc;
  transition: background-color 0.2s ease;
}

.portfolio-table tbody tr:last-child td {
  border-bottom: none;
}

/* Totals row styling */
.totals-row {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  font-weight: 600;
  border-top: 2px solid #cbd5e1;
}

/* Flexible column width optimization with proper text handling */
.col-ticker { 
  width: 140px;
  min-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* initial max-width on the TDs only */
.portfolio-table td.col-ticker {
  max-width: 200px;
}
/* no cap on the TH so users can drag wider */
.portfolio-table th.col-ticker {
  max-width: none;
}

.col-shares            { width: 80px;   min-width: 60px; }
.col-avg-buy           { width: 80px;   min-width: 70px; }
.col-avg-sell          { width: 80px;   min-width: 70px; }
.col-total-invested    { width: 110px;  min-width: 90px; }
.col-total-invested-usd{ width: 100px;  min-width: 90px; }
.col-est-value         { width: 90px;   min-width: 80px; }
.col-gain-loss         { width: 90px;   min-width: 80px; }
.col-total-return      { width: 80px;   min-width: 70px; }
.col-unrealized-return { width: 90px;   min-width: 80px; }
.col-annualized        { width: 90px;   min-width: 80px; }
.col-curr-price        { width: 70px;   min-width: 60px; }
.col-curr-price-usd    { width: 85px;   min-width: 75px; }
.col-dividends         { width: 90px;  min-width: 80px; }

/* Make all table cells handle overflow properly */
.portfolio-table th,
.portfolio-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

/* Professional input styling */
.price-input {
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.75rem;
  background: white;
  width: 70px;
  text-align: center;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.price-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Enhanced buttons */
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* Update Cache button styling */
.btn-secondary {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: white;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(5, 150, 105, 0.2);
  font-size: 0.875rem;
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.3);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* File input styling */
.file-input {
  padding: 12px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  transition: all 0.2s ease;
  cursor: pointer;
}

.file-input:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

/* Enhanced checkboxes (CONSOLIDATED SINGLE DEFINITION) */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
  cursor: pointer;
}
.checkbox-container:hover {
  border-color: #3b82f6;
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
  background-color: #f8fafc;
}
.checkbox-container input[type="checkbox"] {
  accent-color: #3b82f6;
}

/* Color-coded values */
.positive-value {
  color: #059669;
  font-weight: 600;
}

.negative-value {
  color: #dc2626;
  font-weight: 600;
}

.neutral-value {
  color: #6b7280;
}

/* Professional title styling */
.main-title {
  background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  font-size: 2.5rem;
  margin-bottom: 2rem;
}

/* Investor comparison chart styles */
.comparison-highlight {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.user-performance-badge {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-block;
  margin-bottom: 10px;
}

#chartStatus {
  font-style: italic;
  padding: 8px;
  background-color: #f8fafc;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

#showMoreHoldings {
  font-size: 0.75rem;
  padding: 4px 8px;
  background: #f1f5f9;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#showMoreHoldings:hover {
  background: #e2e8f0;
}

.section-title {
  color: #1e293b;
  font-weight: 600;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Cache status styling */
.cache-status {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  margin-top: 0.5rem;
}

/* Loading bar styles */
.loading-container {
  display: none;
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 12px;
  border: 2px solid #cbd5e1;
}

.loading-container.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e2e8f0;
  border-top: 3px solid #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.loading-status {
  font-size: 0.875rem;
  color: #64748b;
  margin-bottom: 12px;
  min-height: 21px;
  font-weight: 500;
}

.loading-bar-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
  position: relative;
  overflow: hidden;
}

.loading-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.loading-percentage {
  font-size: 0.75rem;
  color: #475569;
  text-align: right;
  margin-top: 6px;
  font-weight: 600;
}

.pie-chart-layout {
  display: flex;
  gap: 40px;
  align-items: center;
  min-height: 700px;
  justify-content: center;
}

.pie-legend-list {
  flex: 0 0 350px;
  padding-right: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.875rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

.pie-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  margin-right: 12px;
  flex-shrink: 0;
}

.pie-legend-text {
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.pie-chart-container {
  flex: 1;
  position: relative;
  height: 700px;
  display: flex;
  align-items: center;
  justify-content: center;

  /* CONSOLIDATED */
  overflow: visible !important;
}

/* CONSOLIDATED chart canvas sizing */
.pie-chart-container canvas {
  overflow: visible !important;
  width: 100% !important;
  height: 100% !important;
}

/* CONSOLIDATED specific chart sizing + subtle drop shadow */
#portfolioPieChart,
#netWorthPieChart {
  width: 100% !important;
  height: 100% !important;
  max-width: 950px;
  max-height: 950px;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: optimize-contrast;
  image-rendering: crisp-edges;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  filter: drop-shadow(2px 3px 5px rgba(0, 0, 0, 0.2)) contrast(1.1);
}

/* Net Worth Allocation input styling */
.net-worth-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: end;
  margin-bottom: 30px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.input-group label {
  font-weight: 600;
  color: #374151;
  font-size: 0.875rem;
}

.input-group input {
  padding: 12px 16px;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group input::placeholder {
  color: #9ca3af;
}

#generateNetWorthChart {
  margin-left: auto;
  white-space: nowrap;
  height: fit-content;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .pie-chart-layout {
    flex-direction: column;
    gap: 20px;
    min-height: auto;
    align-items: center;
  }
  
  .pie-legend-list {
    flex: none;
    padding-right: 0;
    order: 2;
    display: block;
    width: 100%;
    max-width: 400px;
  }
  
  .pie-chart-container {
    flex: none;
    height: 450px;
    order: 1;
  }
  
  #portfolioPieChart {
    max-width: 420px;
    max-height: 420px;
  }
  
  .pie-legend-item {
    font-size: 0.8rem;
    margin-bottom: 4px;
    white-space: nowrap;
  }
  
  .pie-legend-color {
    width: 14px;
    height: 14px;
    margin-right: 10px;
  }
  
  .pie-legend-text {
    font-size: 0.8rem;
  }

  .net-worth-inputs {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  
  .input-group {
    min-width: auto;
    width: 100%;
  }
  
  #generateNetWorthChart {
    margin-left: 0;
    margin-top: 10px;
  }

  .portfolio-table {
    min-width: 800px; /* Reduced for mobile but still scrollable */
  }
  
  .portfolio-table th,
  .portfolio-table td {
    padding: 6px 4px; /* Further reduced for mobile */
    font-size: 0.7rem; /* Smaller font on mobile */
  }
  
  .price-input {
    width: 50px; /* Smaller input fields */
    padding: 3px 4px;
    font-size: 0.7rem;
  }
  
  /* Adjust column widths for mobile */
  .col-ticker { width: 100px; min-width: 80px; }
  .col-shares { width: 60px; min-width: 50px; }
  .col-avg-buy { width: 70px; min-width: 60px; }
  .col-avg-sell { width: 70px; min-width: 60px; }
  .col-total-invested { width: 90px; min-width: 80px; }
  .col-total-invested-usd { width: 85px; min-width: 75px; }
  .col-est-value { width: 75px; min-width: 65px; }
  .col-gain-loss { width: 75px; min-width: 65px; }
  .col-total-return { width: 65px; min-width: 55px; }
  .col-unrealized-return { width: 70px; min-width: 60px; }
  .col-annualized { width: 65px; min-width: 55px; }
  .col-curr-price { width: 55px; min-width: 45px; }
  .col-curr-price-usd { width: 65px; min-width: 55px; }
  .col-dividends { width: 75px; min-width: 65px; }
  
  /* Mobile button adjustments */
  .btn-primary, .btn-secondary {
    padding: 10px 16px;
    font-size: 0.8rem;
  }
}

/* ========================================== */
/* INDIVIDUAL STOCK ANALYSIS STYLES          */
/* Ultra-Minimal (Stripe/Apple Style)        */
/* ========================================== */

.stock-button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 6px;
  margin-bottom: 20px;
}

.stock-button {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.stock-button:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.stock-button.active {
  background: #eff6ff;
  border-color: #3b82f6;
}

.stock-button.type-stock.active {
  background: #ecfdf5;
  border-color: #10b981;
}

.stock-button.type-crypto.active {
  background: #fef3c7;
  border-color: #f59e0b;
}

.stock-button-name {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 2px;
}

.stock-button-type {
  display: block;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #64748b;
}

.stock-button.type-stock .stock-button-type {
  color: #10b981;
}

.stock-button.type-crypto .stock-button-type {
  color: #f59e0b;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-label {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
}

.stat-value.positive {
  color: #10b981;
}

.stat-value.negative {
  color: #ef4444;
}



/* ============================================
   END OF STYLES
   ============================================ */