/* Modern CSS Variables for Design System */
:root {
  --primary-color: #1e3a8a;
  --primary-dark: #1e3a8a;
  --secondary-color: #a2a2a2;
  --accent-color: #45b7aa;
  --success-color: #2ecc71;
  --warning-color: #f39c12;
  --danger-color: #e74c3c;
  --info-color: #3498db;

  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --text-light: #bdc3c7;

  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-gradient: linear-gradient(135deg, #1e3a8a 0%, #1e3a8a 100%);
  --bg-hero: linear-gradient(135deg, #1e3a8a 0%, #1e3a8a 100%);

  --border-color: #e9ecef;
  --border-radius: 12px;
  --border-radius-lg: 20px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.2);

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}


/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  /* transition: var(--transition); */
}

/* Enhanced Container */
.container {
  max-width: 1920px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Enhanced Navbar */
.navbar {
  background: var(--bg-card) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 0.5rem 0; /* Reduced from 1rem to 0.5rem */
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary-color) !important;
  text-decoration: none;
}

.navbar-brand:hover {
  color: var(--primary-dark) !important;
}

.nav-link {
  font-weight: 500;
  color: var(--text-primary) !important;
  /* transition: var(--transition); */
  padding: 0.5rem 1rem !important;
  border-radius: var(--border-radius);
}

.nav-link:hover {
  color: var(--primary-color) !important;
  background-color: rgba(255, 107, 53, 0.1);
}

/*
 * Sidebar
 */

  .sidebar {
    /* Remove position: fixed */
    position: sticky;
    top: 100px;
    height: calc(100vh - 100px);
}

.sidebar-heading {
  font-size: .75rem;
  text-transform: uppercase;
}

/* Card System */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  /* transition: var(--transition); */
  overflow: hidden;
}

/* .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
} */

.card-header {
  background: white;
  color: var(--primary-color); /* Dark blue text */
  padding: 1rem; /* Reduced from 1.5rem */
  border-bottom: 1px solid var(--border-color); /* Add subtle border */
  font-weight: 600;
  font-size: 1.1rem; /* Slightly smaller font */
  text-align: center; /* Center the card titles */
}

.card-body {
  padding: 2rem;
}

/* Enhanced Form Styling */
.form-section {
  margin: 0.5rem 0; /* Reduced from 3rem to bring cards closer to navbar */

}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group-text {
  background: var(--primary-color);
  color: white;
  border: 2px solid var(--primary-color);
  border-right: none;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

.input-group .form-control {
  border-left: none;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.form-help {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.4;
}

/* Enhanced Buttons */
.btn {
  padding: 0.75rem 2rem;
  border-radius: var(--border-radius);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  /* transition: var(--transition); */
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--bg-hero);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-outline-secondary:hover {
  background: var(--text-primary);
  color: var(--bg-card);
}

.btn-lg {
  padding: 1rem 2.5rem;
  font-size: 1.1rem;
}

/* Alert Enhancements */
.alert {
  border-radius: var(--border-radius-lg);
  border: none;
  padding: 1.5rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
}

.alert-info {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(155, 89, 182, 0.1) 100%);
  border-left: 4px solid var(--info-color);
  color: var(--text-primary);
}

.alert-danger {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.1) 0%, rgba(192, 57, 43, 0.1) 100%);
  border-left: 4px solid var(--danger-color);
  color: var(--text-primary);
}

/* === Data Tables ===================================================== */

/* Wrapper that gives the table "card" aesthetics and clips overflowing rows */
.table-container {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin: 2rem 0; /* vertical spacing */
}

/* Base table element – override Bootstrap defaults we don't need */
.table {
  margin: 0;               /* remove extra space */
  background: transparent; /* let container background show through */
}

/* Header cells: gradient look + sticky so they stay visible while scrolling */
.table thead th {
  /* visual style */
  background: var(--bg-gradient);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
  padding: 1rem;
  border: none;

  /* sticky behaviour for scrollable tables */
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Data cells */
.table td {
  padding: 0.75rem 1rem;
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* Scroll wrapper around the table body */
.scrollable-table {
  max-height: 600px;
  overflow-y: auto;
}

/* Custom scrollbar (WebKit/Blink) – purely cosmetic */
.scrollable-table::-webkit-scrollbar {
  width: 8px;
}

.scrollable-table::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.scrollable-table::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* Summary Stats Cards */

.stat-card {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Chart Containers */
.chart-container {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 1.5rem;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
  text-align: center;
  flex-shrink: 0;
}

/* Ensure charts fill their containers properly and are centered */
.chart-container > div:last-child {
  flex: 1;
  min-height: 500px;  /* Increased from 400px to 500px for better desktop experience */
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Responsive chart adjustments */
@media (max-width: 1200px) {
  .chart-container > div:last-child {
    min-height: 450px;  /* Slightly smaller for medium screens */
  }
}

@media (max-width: 991.98px) {
  .chart-container {
    margin-bottom: 2rem;
  }

  .chart-container > div:last-child {
    min-height: 400px;  /* Tablet size */
  }
}

@media (max-width: 768px) {
  .chart-container {
    padding: 1rem;
  }

  .chart-title {
    font-size: 1rem;
  }

  .chart-container > div:last-child {
    min-height: 350px;  /* Keep mobile compact */
  }
}

/* Loading States */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 107, 53, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    font-size: 1.2rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }


  .container {
    padding: 0 15px;
  }

  .card-body {
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2rem;
  }

  .btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.85rem;
  }
}

/* Utility Classes */
.text-gradient {
  background: var(--bg-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-spacing {
  margin: 4rem 0;
}

/* Parameter Changes Styling */

/* Collapsible Content */
.collapse {
  transition: var(--transition);
}


/* Focus States for Accessibility */
.btn:focus,
.form-control:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Print Styles */
@media print {
  .navbar,
  .btn {
    display: none !important;
  }


  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
}

/* Custom Button Colors - Dark Blue Theme */
.btn-success,
.btn-outline-success {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: white !important;
}

.btn-success:hover,
.btn-outline-success:hover {
  background-color: #1e40af !important;
  border-color: #1e40af !important;
  color: white !important;
}

.btn-outline-primary {
  background-color: transparent !important;
  border-color: var(--primary-color) !important;
  color: var(--primary-color) !important;
}

.btn-outline-primary:hover {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: white !important;
}

.btn-outline-danger {
  background-color: transparent !important;
  border-color: var(--primary-color) !important;
  color: var(--primary-color) !important;
}

.btn-outline-danger:hover {
  background-color: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
  color: white !important;
}

/* Custom Sidebar Styles */
/* Dark blue sidebar background */
.bg-dark-blue {
  background-color: var(--primary-color) !important; /* Dark blue */
}

/* Update sidebar text colors for dark background */
.bg-dark-blue .nav-link {
  color: #e5e7eb !important; /* Light gray text */
}

.bg-dark-blue .nav-link:hover {
  color: #ffffff !important; /* White text on hover */
  background-color: rgba(255, 255, 255, 0.1) !important; /* Subtle hover effect */
}

.bg-dark-blue .nav-link.active {
  color: #ffffff !important; /* White text for active */
  background-color: rgba(255, 255, 255, 0.2) !important; /* More visible active state */
}

/* Update sidebar heading and text colors */
.bg-dark-blue .sidebar-heading,
.bg-dark-blue .text-muted {
  color: #e5e7eb !important; /* Light gray text for headings and muted text */
}

.bg-dark-blue .sidebar-heading a {
  color: #e5e7eb !important; /* Light gray for links in headings */
}

.bg-dark-blue .sidebar-heading a:hover {
  color: #ffffff !important; /* White on hover */
}

/* Custom Layout: 1.5-column sidebar with optimized proportions */
@media (min-width: 768px) {
  .row {
    display: flex;
    flex-wrap: wrap;
  }
  
  .sidebar-custom {
    flex: 0 0 12.5%; /* 1.5/12 = 12.5% */
    max-width: 12.5%;
    position: fixed;
    top: 64px; /* Fine-tuned to align perfectly with navbar bottom */
    left: 0;
    width: 180px; /* Fixed pixel width - completely independent */
    height: calc(100vh - 64px); /* Height minus navbar height */
    overflow-y: auto;
    padding-top: 1rem;
    z-index: 1050; /* Higher z-index to stay above modal backdrop */
    box-sizing: border-box;
  }
  
  .form-section-custom {
    flex: 0 0 35.4%; /* ~4.25/12 = 35.4% */
    max-width: 35.4%;
    margin-left: 180px; /* Offset for fixed sidebar */
    padding-top: 0.5rem; /* Consistent padding with results section */
  }
  
  .results-section-custom {
    flex: 0 0 52.1%; /* ~6.25/12 = 52.1% */
    max-width: 52.1%;
    padding-top: 0.5rem; /* Consistent padding with form section */
    margin-top: 0.5rem; /* Match form-section margin for card alignment */
  }
}

@media (max-width: 767px) {
  .sidebar-custom {
    display: none !important;
  }
  
  .form-section-custom,
  .results-section-custom {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* === COMPONENT STYLES ================================== */

/* Cluster Components (Income & Milestone sections) */
.income-cluster-container,
.spending-cluster-container,
.milestone-cluster-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.income-summary-card,
.spending-summary-card,
.milestone-summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    transition: var(--transition);
}

.income-summary-card:hover,
.spending-summary-card:hover,
.milestone-summary-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.income-name,
.spending-name,
.milestone-name {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.income-details,
.spending-details,
.milestone-details {
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.income-actions .btn,
.spending-actions .btn,
.milestone-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.add-income-btn,
.add-spending-btn,
.add-milestone-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.add-income-btn:hover,
.add-spending-btn:hover,
.add-milestone-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* Modal Components */
#incomeModal .modal-content,
#spendingModal .modal-content,
#milestoneModal .modal-content {
    border-radius: var(--border-radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: var(--bg-gradient);
    color: white;
    border-bottom: none;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-body {
    padding: 2rem;
}

.form-help {
    color: var(--text-secondary);
    font-size: 0.8rem;
}



