html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: 'Lato', sans-serif;
  background-color: var(--light-bg);
  color: var(--indigo);
}

:root {
    /* --primary: #492B93; */
    --primary: #5e50b6;
    --primary-rgb: 94, 80, 182;
    --accent: #2F46E4;
    --accent-rgb: 47, 70, 228;
    --lavender: #E6E2FA;
    --mid-purple: #8C6FF0;
    --soft-blue: #A6B4F9;
    --indigo: #1B1A3D;
    --mint: #B9F3DD;
    --alert: #FF8C9C;
    --light-bg: #F8F9FB;
}

/* --- Custom Button Styles (Only what Bootstrap doesn't provide) --- */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--mid-purple);
  border-color: var(--mid-purple);
}

/* Remove focus glow from .btn-primary and .btn-link */
.btn-primary:focus, .btn-primary:active,
.btn-link:focus, .btn-link:active {
  box-shadow: none !important;
  outline: none !important;
}

/* Custom disabled button styling to match the purple theme */
.btn-primary:disabled,
.btn-primary.disabled {
  background-color: var(--lavender);
  border-color: var(--lavender);
  color: var(--primary);
  opacity: 0.8;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--primary);
  border-color: var(--lavender);
  color: white;
}

/* Custom disabled outline button styling */
.btn-outline-primary:disabled,
.btn-outline-primary.disabled {
  color: var(--primary);
  border-color: var(--lavender);
  background-color: transparent;
  opacity: 0.7;
}

/* Accent Button (Secondary Action) */
.btn-accent {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover,
.btn-accent:focus {
  background-color: #2338c2;
  border-color: #2338c2;
}

/* Custom disabled accent button styling */
.btn-accent:disabled,
.btn-accent.disabled {
  background-color: var(--soft-blue);
  border-color: var(--soft-blue);
  opacity: 0.8;
}

/* --- Custom Text & Background Utility Classes --- */
.text-primary {
  color: var(--primary) !important;
}

.text-accent {
  color: var(--accent) !important;
}

.text-indigo {
  color: var(--indigo) !important;
}

.text-mid-purple {
  color: var(--mid-purple) !important;
}

.bg-primary {
  background-color: var(--primary) !important;
}

.bg-lavender {
  background-color: var(--lavender) !important;
}

.bg-accent {
  background-color: var(--accent) !important;
}

.bg-mint {
  background-color: var(--mint) !important;
}

.bg-alert {
  background-color: var(--alert) !important;
}

.bg-mid-purple {
  background-color: var(--mid-purple) !important;
}

.bg-soft-blue {
  background-color: var(--soft-blue) !important;
}

.bg-light {
  background-color: var(--light-bg) !important;
}

/* --- Custom Links --- */
a,
.link-primary {
  color: var(--primary);
}

a:hover,
.link-primary:hover {
  color: var(--mid-purple);
  text-decoration: none;
}

/* --- Custom .btn-link to match color scheme --- */
.btn-link {
  color: var(--primary);
  text-decoration: underline;
}

.btn-link:hover,
.btn-link:focus {
  color: var(--mid-purple);
  text-decoration: none;
}

/* --- Alpine.js Utility --- */
[x-cloak] { display: none !important; }

/* --- Portfolio Node Custom Styles (that can't use Bootstrap) --- */
.modal-header {
  background-color: var(--primary);
  color: white;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.portfolio-table {
  border-collapse: collapse;
  width: 100%;
  border-radius: 0.3rem;
  overflow: hidden;
  /* table-layout: fixed; */
}

.portfolio-table td {
  border: 1px solid #dee2e6;
  transition: background-color 0.2s;
  /* height: 80px; Set a fixed height for better vertical layout */
}

.node-option-card {
  transition: all 0.2s ease;
  border: 2px solid transparent;
  cursor: pointer;
}

.node-option-card:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.node-option-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(73, 43, 147, 0.25);
}

.etf-list-item:hover {
  background-color: var(--lavender);
}

.etf-badge {
  background-color: var(--mint);
  color: var(--indigo);
}

.index-label {
  color: var(--primary);
  border-bottom: 2px solid var(--lavender);
}

.node-cell {
  cursor: pointer;
}

td.padding {
  background: transparent;
  border: 0;
}

/* Style for intermediate nodes with rowspan */
.node-cell[rowspan] {
  border: 1px solid #dee2e6;
  vertical-align: top;
}

.node-content {
  width: 100%;
  transition: all 0.2s;
}

.node-cell:hover {
  background-color: var(--lavender)
}

.node-cell:hover .node-content {
  transform: translateY(-2px);
}

/* Compact Country Concentration specific styles */
.compact-country-concentration .progress {
  transition: all 0.15s ease;
  box-shadow: none;
  background-color: #f0f0f5;
  overflow: hidden;
  border-radius: 999px;
}

.compact-country-concentration .text-weight-indicator {
  /* transition: all 0.15s ease; */
  line-height: 1;
  margin-top: 2px;
}

.compact-country-concentration .progress-bar {
  /* transition: all 0.15s ease; */
  box-shadow: none;
  border-radius: 999px;
}

.compact-country-concentration .progress-bar:hover {
  opacity: 1 !important;
}

.compact-country-concentration .small-text {
  font-size: 0.75rem;
}

.fs-7 {
  font-size: 0.75rem !important;
}

.compact-country-concentration .table > tbody > tr {
  line-height: 1.2;
  margin-bottom: 4px;
  /* transition: all 0.15s ease; */
  border-left: 3px solid transparent;
}

/* Dynamic hover border colors based on progress bar color */
.compact-country-concentration .table > tbody > tr[data-bar-color="primary"]:hover {
  border-left: 3px solid var(--primary);
}

.compact-country-concentration .table > tbody > tr[data-bar-color="soft-blue"]:hover {
  border-left: 3px solid var(--soft-blue);
}

.compact-country-concentration .table > tbody > tr:hover .progress {
  transform: translateY(-1px) scaleY(1.5);
}

.compact-country-concentration .table > tbody > tr:hover .text-weight-indicator {
  font-weight: bold;
  /* transform: scale(1.1); */
}

.compact-country-concentration .table > tbody > tr > td {
  padding-top: 2px;
  padding-bottom: 2px;
}

.compact-country-concentration .table-responsive {
  overflow-x: hidden;
}

.compact-country-concentration .table-responsive:hover {
  overflow-x: auto;
}

.compact-country-concentration .table {
  margin-bottom: 0;
  table-layout: auto;
}

.compact-country-concentration td:first-child {
  white-space: nowrap;
  width: 1%;
  border-right: 1px solid var(--lavender) !important;
}

/* --- Custom Border Utility Overrides --- */
.border-primary {
  border-color: var(--primary) !important;
}

.border-accent {
  border-color: var(--accent) !important;
}

.border-lavender {
  border-color: var(--lavender) !important;
}

.border-mid-purple {
  border-color: var(--mid-purple) !important;
}

.border-soft-blue {
  border-color: var(--soft-blue) !important;
}

.border-indigo {
  border-color: var(--indigo) !important;
}

.border-mint {
  border-color: var(--mint) !important;
}

.border-alert {
  border-color: var(--alert) !important;
}

/* Optionally override Bootstrap's default .border class
.border {
  border-color: var(--lavender) !important;
} */


/* --- Custom Alert Utility Overrides --- */
.alert-primary {
  background-color: var(--lavender) !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}

.alert-accent {
  background-color: var(--soft-blue) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.alert-mid-purple {
  background-color: var(--mid-purple) !important;
  color: #fff !important;
  border-color: var(--mid-purple) !important;
}

.alert-indigo {
  background-color: var(--indigo) !important;
  color: #fff !important;
  border-color: var(--indigo) !important;
}

.alert-mint {
  background-color: var(--mint) !important;
  color: var(--indigo) !important;
  border-color: var(--mint) !important;
}

.alert-alert {
  background-color: var(--alert) !important;
  color: #fff !important;
  border-color: var(--alert) !important;
}

/* Table Row Hover Effect */
.hover-row {
  position: relative;
  border-left: 3px solid transparent;
}

.hover-row:hover {
  background-color: rgba(94, 80, 182, 0.05); /* Using primary color with low opacity */
  border-left: 3px solid var(--primary);
}

/* Remove bottom border from last table row */
.no-bottom-border {
  border-bottom: none !important;
}

/* Portfolio Performance Metrics */
.metrics-container {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 0.375rem;
  white-space: nowrap;
}

.metric-badge i {
  margin-right: 4px;
  font-size: 0.7rem;
}

.metric-return {
  background-color: var(--mint);
  color: var(--indigo);
}

.metric-risk {
  background-color: var(--soft-blue);
  color: var(--indigo);
}

.metric-sharpe {
  background-color: var(--primary);
  color: white;
}

/* Detailed metrics hover effect */
.metric-hover {
  transition: all 0.2s ease;
}

.metric-hover:hover {
  background-color: rgba(94, 80, 182, 0.05);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}


/* Custom scrollbar for the right panel */
/* .right-panel::-webkit-scrollbar {
  width: 6px;
}

.right-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.right-panel::-webkit-scrollbar-thumb {
  background: rgba(var(--primary-rgb), 0.3);
  border-radius: 10px;
}

.right-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--primary-rgb), 0.5);
} */


/* Content preloader for portfolio builder */
.portfolio-preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--light-bg);
  z-index: 1060;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.portfolio-preloader.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Floating help button */
.portfolio-help-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.3);
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s ease;
}

.portfolio-help-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.tutorial-modal .modal-content {
  overflow: hidden;
  border: none;
}

.tutorial-step {
  display: flex;
  margin-bottom: 25px;
}

.tutorial-step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 15px;
  flex-shrink: 0;
}

.tutorial-step-content h5 {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.tutorial-step-content p {
  color: var(--indigo);
  opacity: 0.85;
}

/* Pulsing animation for highlighted nodes
@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4), 0 8px 16px rgba(0, 0, 0, 0.1);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0), 0 8px 16px rgba(0, 0, 0, 0.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0), 0 8px 16px rgba(0, 0, 0, 0.1);
  }
}

.node-content.animate-pulse {
  animation: pulse-border 2s infinite;
} */

.portfolio-table-instruction {
  display: inline-flex;
  align-items: center;
  font-size: 0.9rem;
  color: var(--primary);
  background-color: rgba(var(--primary-rgb), 0.08);
  padding: 6px 12px;
  border-radius: 20px;
}

/* Portfolio Tabs Styling */
.portfolio-tabs {
  margin-bottom: 2rem;
}

.portfolio-button-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-rounded {
  background-color: #f0f0f0;
  color: var(--indigo);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-rounded:hover {
  background-color: rgba(94, 80, 182, 0.1);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-rounded.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(94, 80, 182, 0.3);
}

.portfolio-tabs .tab-content {
  padding: 1.5rem 0;
}

/* Empty Portfolio State Styles */
.empty-portfolio-state {
  background-color: rgba(94, 80, 182, 0.05);
  border-radius: 10px;
  border: 1px dashed var(--primary);
  padding: 2.5rem;
  /* max-width: 800px; */
  margin: 0 auto;
  transition: all 0.3s ease;
}

.empty-portfolio-state:hover {
  box-shadow: 0 5px 15px rgba(94, 80, 182, 0.1);
}

.step-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
}

.step-number {
  background-color: var(--primary);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  flex-shrink: 0;
}

.step-text {
  flex-grow: 1;
}

#startBuildingButton {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#startBuildingButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(94, 80, 182, 0.2);
}

#startBuildingButton.active {
  transform: scale(0.98);
  box-shadow: 0 2px 4px rgba(94, 80, 182, 0.1);
}

/* Empty tabs state */
.empty-tabs-state {
  background-color: rgba(94, 80, 182, 0.03);
  border-radius: 10px;
  border: 1px dashed var(--primary);
  max-width: 600px;
  margin: 0 auto;
  transition: all 0.3s ease;
}

.empty-tabs-features {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 120px;
}

.feature-item i {
  font-size: 1.8rem;
  color: var(--primary);
  background-color: rgba(94, 80, 182, 0.1);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 0.5rem;
  transition: all 0.3s ease;
}

.feature-item:hover i {
  transform: translateY(-5px);
  background-color: rgba(94, 80, 182, 0.15);
}

/* Portfolio Navigation Map */
.portfolio-nav-map {
  background-color: rgba(255, 255, 255, 0.7);
  border-radius: 0.5rem;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--lavender);
  position: sticky;
  top: 20px;
}

.nav-map-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-map-item {
  margin-bottom: 0.75rem;
}

.nav-map-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: var(--indigo);
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.nav-map-link:hover, .nav-map-link:focus {
  background-color: rgba(94, 80, 182, 0.08);
  color: var(--primary);
  border-left-color: var(--primary);
  transform: translateX(3px);
}

.nav-map-link.active {
  background-color: rgba(94, 80, 182, 0.12);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  margin-right: 0.75rem;
  color: var(--primary);
}

/* Portfolio Separator */
.separator-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.separator-line {
  height: 1px;
  background-color: var(--lavender);
  flex-grow: 1;
}

.separator-icon {
  padding: 0 20px;
  font-size: 1.5rem;
  color: var(--primary);
}

.separator-icon i {
  background-color: var(--light-bg);
  padding: 10px;
  border-radius: 50%;
  border: 1px solid var(--lavender);
  box-shadow: 0 2px 10px rgba(var(--primary-rgb), 0.1);
}

/* Footer Styles */
footer a.btn-outline-secondary:hover {
  color: var(--primary) !important;
  background-color: var(--lavender);
  border-color: var(--primary);
  transition: all 0.2s ease;
}

footer a.link-secondary:hover {
  color: var(--primary) !important;
  text-decoration: underline !important;
  transition: color 0.2s ease;
}

/* Optimization Method Selector Styling */
.optimization-method-select {
  border: 0;
  border-bottom: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-weight: 500;
  padding: 4px 8px 4px 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
  transition: border-color 0.2s ease;
}

.optimization-method-select:focus {
  border-bottom-color: var(--mid-purple);
  box-shadow: none;
}

.optimization-method-select option {
  background-color: white;
  color: var(--indigo);
  padding: 8px;
}

.optimization-method-container {
  background-color: rgba(var(--primary-rgb), 0.05);
  border: 1px solid rgba(var(--primary-rgb), 0.15);
  border-radius: 20px;
  padding: 8px 16px;
}
