/* style.css – BrueggerInvest Portfolio Dashboard */

:root {
  /* Bruegger Invest Brand Colors */
  --brand-gold: #C9A86A;
  --brand-gold-hover: #B8966D;
  --brand-gold-light: rgba(201, 168, 106, 0.1);
  --blue-charcoal: #010d1a;
  --navy: #0A2342;
  --off-white: #F5F5F5;
  --white: #FFFFFF;

  /* Additional Colors */
  --success: #2dbd6e;
  --stability: #2d8fbd;
  --core: #bfa14a;
  --cash: #777777;
  --negative: #e74c3c;
  --border-color: rgba(201, 168, 106, 0.2);
  --border-light: rgba(245, 245, 245, 0.1);

  /* Benchmark Colors (lighter shades or distinct hues) */
  --gold-benchmark: #D4B17A;
  --sp500-benchmark: #4DA8D4;
  --nasdaq-benchmark: #40D484;

  /* Typography */
  --font-heading: 'Cinzel', serif;
  --font-body: 'Montserrat', sans-serif;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);

  /* Transitions */
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--blue-charcoal);
  color: var(--off-white);
  line-height: 1.6;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(1, 13, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}
.modal-content {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue-charcoal) 100%);
  border: 2px solid var(--brand-gold);
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
}
.modal-header h2 {
  font-family: var(--font-heading);
  color: var(--brand-gold);
  font-size: 1.8rem;
  margin-bottom: var(--space-md);
  text-align: center;
}
.modal-body {
  margin-bottom: var(--space-lg);
}
.modal-body p {
  margin-bottom: var(--space-sm);
  line-height: 1.7;
}
.modal-body ul {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
}
.modal-body li {
  margin-bottom: var(--space-xs);
}
.disclaimer {
  font-size: 0.9rem;
  color: var(--brand-gold);
  font-style: italic;
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-md);
}
.modal-footer {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

/* Button Styles */
.btn {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn--primary {
  background-color: var(--brand-gold);
  color: var(--blue-charcoal);
}
.btn--primary:hover {
  background-color: var(--brand-gold-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.btn--secondary {
  background-color: transparent;
  color: var(--off-white);
  border: 2px solid var(--border-color);
}
.btn--secondary:hover {
  background-color: var(--brand-gold-light);
  border-color: var(--brand-gold);
}

/* Dashboard */
.dashboard.hidden {
  display: none;
}

.section-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-lg);
  align-items: start; /* Align items to top to match chart height */
}

@media (max-width: 768px) {
  .section-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}

/* Chart Container */
.chart-container {
  position: relative;
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--navy), var(--blue-charcoal));
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  height: 100%; /* Ensure chart container takes full height */
}

.chart-container:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.chart-container canvas {
  max-width: 100%;
  height: auto !important;
  max-height: 400px; /* Fixed max height to control chart size */
}

/* Legend */
.allocation-legend,
.performance-legend {
  padding: var(--space-md);
  background: linear-gradient(135deg, var(--navy), var(--blue-charcoal));
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  height: 100%; /* Match chart height */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow-y: auto; /* Allow scrolling if content overflows */
}

.allocation-legend:hover,
.performance-legend:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.legend-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Two-column layout on desktop */
  gap: var(--space-sm);
  padding: var(--space-xs);
  max-height: 400px; /* Match chart max height */
  overflow-y: auto; /* Scroll if needed */
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs);
  background: rgba(245, 245, 245, 0.05);
  border-radius: 12px;
  border-left: 4px solid;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-text h4 {
  font-family: var(--font-heading);
  color: var(--off-white);
  margin-bottom: 0.1rem;
  font-size: clamp(0.8rem, 1.5vw, 0.9rem);
}

.legend-text p {
  font-size: clamp(0.7rem, 1.2vw, 0.8rem);
  color: var(--off-white);
  opacity: 0.8;
  line-height: 1.2;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chart-container canvas {
    max-height: 250px;
  }
  .legend-items {
    grid-template-columns: 1fr; /* Single column on mobile */
    max-height: 250px; /* Match mobile chart height */
  }
  .allocation-legend,
  .performance-legend {
    padding: var(--space-sm);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .chart-container canvas {
    max-height: 300px;
  }
  .legend-items {
    max-height: 300px;
  }
}

@media (min-width: 1025px) {
  .chart-container canvas {
    max-height: 400px;
  }
  .legend-items {
    max-height: 400px;
  }
}

/* Existing styles remain unchanged */
.header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue-charcoal) 100%);
  border-bottom: 3px solid var(--brand-gold);
  padding: var(--space-lg) 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.brand-title a {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  color: var(--brand-gold);
  text-decoration: none;
  transition: var(--transition);
}

.brand-title a:hover {
  color: var(--brand-gold-hover);
  transform: translateY(-2px);
}

.brand-subtitle {
  color: var(--off-white);
  font-size: 0.9rem;
  opacity: 0.8;
}

.portfolio-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--off-white);
  text-align: right;
}

.last-updated {
  font-size: 0.85rem;
  color: var(--brand-gold);
  text-align: right;
}

.portfolio-overview {
  padding: var(--space-xl) 0;
  background: var(--blue-charcoal);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
}

.overview-card {
  background: linear-gradient(135deg, var(--navy) 0%, rgba(10, 35, 66, 0.8) 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: var(--space-lg);
  text-align: center;
  transition: var(--transition);
}

.overview-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-gold);
}

.overview-card h3 {
  font-family: var(--font-heading);
  color: var(--brand-gold);
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.overview-card .value {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--off-white);
  margin-bottom: var(--space-xs);
}

.overview-card .change {
  font-size: 0.9rem;
  font-weight: 500;
}

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

.change.negative {
  color: var(--negative);
}

.change.neutral {
  color: var(--brand-gold);
}

section {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--border-light);
}

section h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 4vw, 1.8rem);
  color: var(--brand-gold);
  margin-bottom: var(--space-lg);
  text-align: center;
}

.performance-section {
  background: var(--blue-charcoal);
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.performance-card {
  background: linear-gradient(135deg, var(--navy) 0%, rgba(10, 35, 66, 0.6) 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: var(--space-lg);
  text-align: center;
  transition: var(--transition);
}

.performance-card:hover {
  border-color: var(--brand-gold);
  transform: translateY(-3px);
}

.metric-label {
  font-size: 0.85rem;
  color: var(--brand-gold);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.metric-value {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--off-white);
}

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

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

.holdings-section {
  background: var(--navy);
}

.holdings-table-container {
  overflow-x: auto; /* Inherited by .table-container */
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.table-container {
  width: 100%;
  max-width: calc(100% - 40px); /* Maintains 20px padding on left and right */
  margin: 0 auto;
  overflow-x: auto; /* Enables horizontal scrolling on all screen sizes */
  padding: 0 20px; /* Ensures padding on sides */
}

.holdings-table {
  width: 100%;
  min-width: 800px; /* Minimum width to trigger scrolling if needed */
  border-collapse: collapse;
  background: var(--blue-charcoal);
}

.holdings-table th {
  background: var(--navy);
  color: var(--brand-gold);
  padding: var(--space-md);
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.holdings-table td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}

.holdings-table tr:hover {
  background: rgba(201, 168, 106, 0.05);
}

.security-info {
  display: flex;
  flex-direction: column;
}

.ticker {
  font-weight: 600;
  color: var(--brand-gold);
  font-size: 0.85rem;
}

.company-name {
  font-size: 0.9rem;
  color: var(--off-white);
  margin-top: 0.25rem;
}

.segment-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.segment-growth {
  background: rgba(45, 189, 110, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.segment-stability {
  background: rgba(45, 143, 189, 0.2);
  color: var(--stability);
  border: 1px solid var(--stability);
}

.segment-core {
  background: rgba(191, 161, 74, 0.2);
  color: var(--core);
  border: 1px solid var(--core);
}

.segment-cash {
  background: rgba(119, 119, 119, 0.2);
  color: var(--cash);
  border: 1px solid var(--cash);
}

.changes-section {
  background: var(--navy);
}

.changes-container {
  background: var(--blue-charcoal);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: var(--space-lg);
  min-height: 200px;
}

.change-history-note {
  font-size: 0.9rem !important;
  color: var(--off-white) !important;
  margin-bottom: var(--space-lg) !important;
  font-family: var(--font-body) !important;
  line-height: 1.6 !important;
  text-align: center !important;
  display: inline !important;
  white-space: nowrap !important;
  padding-left: 45px !important; /* Match table left padding on desktop */
}

.change-history-note a {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--space-xs) !important;
  padding: var(--space-sm) var(--space-md) !important;
  background: rgba(245, 245, 245, 0.05) !important;
  border-left: 4px solid var(--brand-gold) !important;
  border-radius: 12px !important;
  font-family: var(--font-heading) !important;
  font-weight: 600 !important;
  font-size: clamp(0.8rem, 1.5vw, 0.9rem) !important;
  color: var(--brand-gold) !important;
  text-decoration: none !important;
  transition: var(--transition) !important;
  margin-left: 0.5rem !important;
  vertical-align: middle !important;
}

.change-history-note a::before {
  content: '' !important;
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background-color: var(--brand-gold) !important;
  flex-shrink: 0 !important;
  margin-right: var(--space-xs) !important;
}

.change-history-note a:hover {
  background: var(--brand-gold-light) !important;
  color: var(--blue-charcoal) !important;
  border-left-color: var(--brand-gold-hover) !important;
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-md) !important;
}

/* Responsive Adjustment for Very Small Screens */
@media (max-width: 480px) {
  .change-history-note {
    display: flex !important;
    flex-direction: column !important;
    text-align: center !important;
    padding-left: 10px !important; /* Match table padding on mobile */
  }

  .change-history-note a {
    margin-left: 0 !important;
    margin-top: var(--space-sm) !important;
    width: 100% !important;
    justify-content: center !important;
  }
}

@media (max-width: 768px) {
  .change-history-note {
    padding-left: 10px !important; /* Match table padding on tablets */
  }
}

.changes-container .change-history-note {
  /* Ensures compatibility for the .changes-section .changes-container .change-history-note selector */
}

.footer {
  background: var(--navy);
  border-top: 3px solid var(--brand-gold);
  padding: var(--space-xl) 0 var(--space-lg);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.footer-section h4 {
  font-family: var(--font-heading);
  color: var(--brand-gold);
  margin-bottom: var(--space-sm);
}

.footer-section p {
  color: var(--off-white);
  opacity: 0.8;
  line-height: 1.6;
}

.disclaimer-text {
  font-size: 0.85rem;
  line-height: 1.5;
}

.footer-bottom {
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-md);
  text-align: center;
}

.footer-bottom p {
  color: var(--off-white);
  opacity: 0.6;
  font-size: 0.85rem;
}

.gold-subtitle {
  color: var(--brand-gold);
  font-size: 0.9rem;
  margin-bottom: var(--space-xs);
  display: block;
}

.value-container {
  margin-top: var(--space-sm);
}

.value {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--off-white);
  display: block;
  margin-bottom: var(--space-xs);
}

.value.small-text {
  font-size: 0.9rem !important;
  font-weight: 500;
  color: var(--off-white);
}

.small-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--off-white);
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  .portfolio-title,
  .last-updated {
    text-align: center;
  }
  .brand-title a {
    font-size: 2rem;
  }
  .portfolio-title {
    font-size: 1.25rem;
  }

  /* Table responsive adjustments */
  .table-container {
    padding: 0 10px; /* Reduce padding on smaller screens */
    max-width: calc(100% - 20px);
  }

  .holdings-table {
    min-width: 600px; /* Adjust minimum width for smaller screens */
  }
}

/* Introduction Trigger and Fixed Panel */
.intro-trigger {
    position: fixed;
    top: var(--space-sm);
    right: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    background: var(--brand-gold);
    color: var(--blue-charcoal);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    border: 1px solid var(--brand-gold-hover);
}

.intro-trigger::before {
    content: 'ℹ'; /* Info icon */
    font-size: 1rem;
}

.intro-trigger:hover {
    background: var(--brand-gold-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--brand-gold);
}

.intro-panel {
    display: none;
    position: fixed;
    top: calc(var(--space-sm) + 2.5rem); /* Offset below trigger */
    left: var(--space-sm);
    width: 320px;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--navy) 0%, var(--blue-charcoal) 100%);
    border: 2px solid var(--brand-gold);
    border-radius: 12px;
    color: var(--off-white);
    font-size: 0.95rem;
    line-height: 1.7;
    text-align: left;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
}

.intro-panel.active {
    display: block;
}

.intro-panel-content {
    position: relative;
}

.intro-panel-content p {
    margin-bottom: var(--space-md);
}

.intro-panel-content a {
    color: var(--brand-gold);
    text-decoration: underline;
    font-weight: 600;
}

.intro-panel-content a:hover {
    color: var(--brand-gold-hover);
}

.intro-panel .close-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: none;
    color: var(--off-white);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    padding: var(--space-xs);
    border-radius: 50%;
}

.intro-panel .close-btn:hover {
    color: var(--brand-gold);
    transform: rotate(90deg);
}

@media (max-width: 480px) {
    .intro-trigger {
        position: fixed;
        top: var(--space-xs);
        right: var(--space-xs);
    }
    .intro-panel {
        width: 90%;
        left: 5%;
        top: calc(var(--space-xs) + 2.5rem); /* Adjusted for mobile */
    }
    .header-actions {
        display: none; /* Hide header actions on mobile since trigger is fixed */
    }
}