/* Main Styling */
:root {
  /* Color system */
  --primary-color: #3a7bd5;
  --primary-dark: #2c5e9e;
  --primary-light: #d4e4f7;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --light-color: #f8f9fa;
  --dark-color: #343a40;
  --border-color: #dee2e6;
  
  /* Typography */
  --heading-font: 'Nunito Sans', sans-serif;
  --body-font: 'Nunito Sans', sans-serif;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  
  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
}

body {
  background-color: #f8f9fa;
  color: var(--dark-color);
  font-family: var(--body-font);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--heading-font);
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: var(--spacing-sm);
}

/* Card styling */
.card {
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background-color: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 600;
  border-top-left-radius: var(--radius-md) !important;
  border-top-right-radius: var(--radius-md) !important;
}

.card-body {
  padding: var(--spacing-md);
}

/* Performance metrics styling */
.text-success {
  color: var(--success-color) !important;
}

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

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

/* Table styling */
.table {
  font-size: 0.95rem;
}

.table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.03);
  cursor: pointer;
}

.table-primary {
  background-color: rgba(58, 123, 213, 0.08) !important;
}

/* Button styling */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: 0.375rem 1rem;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

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

.btn-secondary:hover {
  background-color: #5a6268;
  border-color: #545b62;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
}

.btn-danger:hover {
  background-color: #c82333;
  border-color: #bd2130;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
}

/* Form control styling */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border-color);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(58, 123, 213, 0.25);
}

/* Form controls with sm size */
.form-control-sm, .form-select-sm {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  height: calc(1.5em + 0.5rem + 2px);
}

label {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
  color: var(--dark-color);
}

/* Enhanced Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .col-md-6, .col-md-4, .col-md-3 {
    margin-bottom: var(--spacing-sm);
  }
  
  /* Mobile-friendly cards */
  .card {
    margin-bottom: var(--spacing-sm);
  }
  
  .card-body {
    padding: var(--spacing-sm);
  }
  
  /* Mobile buttons */
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-height: 44px; /* Touch-friendly minimum size */
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.6rem;
  }
  
  /* Mobile forms */
  .form-control, .form-select {
    padding: 0.6rem 0.75rem;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
  
  .form-control-sm, .form-select-sm {
    min-height: 36px;
    font-size: 14px;
  }
  
  /* Mobile tables */
  .table-responsive {
    font-size: 0.85rem;
  }
  
  .table td, .table th {
    padding: 0.5rem 0.25rem;
  }
  
  /* Mobile typography */
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
  h5 { font-size: 1rem; }
  h6 { font-size: 0.9rem; }
  
  /* Mobile spacing */
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .row {
    margin-left: -0.375rem;
    margin-right: -0.375rem;
  }
  
  .row > * {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
  }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .btn-group .btn {
    width: auto;
    margin-bottom: 0;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .card-header {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .alert {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .navbar {
    padding: 0.25rem 1rem;
  }
  
  .container-fluid {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
}

/* Touch-friendly interactive elements */
@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    transform: none;
  }
  
  .card:hover {
    transform: none;
  }
  
  .table-hover tbody tr:hover {
    background-color: transparent;
  }
}

/* Chart container */
.chart-container {
  transition: height 0.3s ease;
  background-color: white;
  border-radius: var(--radius-md);
  padding: var(--spacing-sm);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

canvas {
  max-width: 100%;
  height: auto !important;
}

/* Mobile chart adjustments */
@media (max-width: 768px) {
  .chart-container {
    padding: 0.5rem;
    margin-bottom: 1rem;
  }
  
  canvas {
    max-height: 300px;
  }
}

/* Gap utilities */
.gap-2 {
  gap: 0.5rem;
}

.g-2 {
  --bs-gutter-x: 0.5rem;
  --bs-gutter-y: 0.5rem;
}

/* Results panel */
#backtest-results {
  transition: all 0.3s ease;
}

#backtest-results.expanded {
  position: fixed;
  top: 4rem;
  right: 1rem;
  left: 1rem;
  z-index: 1050;
  background: white;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
}

/* Mobile results panel */
@media (max-width: 768px) {
  #backtest-results.expanded {
    top: 3rem;
    right: 0.5rem;
    left: 0.5rem;
  }
}

/* Nav tabs styling */
.nav-tabs .nav-link {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  color: var(--secondary-color);
  border-radius: 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.nav-tabs .nav-link.active {
  font-weight: 600;
  color: var(--primary-color);
  background-color: transparent;
  border-color: transparent transparent var(--primary-color) transparent;
}

.nav-tabs .nav-link:hover:not(.active) {
  border-color: transparent transparent var(--border-color) transparent;
  background-color: rgba(0, 0, 0, 0.01);
}

/* Mobile nav tabs */
@media (max-width: 768px) {
  .nav-tabs .nav-link {
    padding: 0.5rem 0.5rem;
    font-size: 0.85rem;
  }
}

/* Target and feature selection areas */
#targetSelectionSection, 
#featureSelectionSection {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background-color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Selected features list styling */
#selectedFeaturesList {
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
}

.small-inputs input,
.small-inputs select,
.small-inputs textarea {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.small {
  font-size: 0.875rem;
}

/* Reduced margins for main containers */
.container-fluid {
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Border utilities */
.border {
  border: 1px solid var(--border-color) !important;
}

.rounded {
  border-radius: var(--radius-sm) !important;
}

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

/* Badge styling */
.badge {
  padding: 0.35em 0.65em;
  font-weight: 600;
  border-radius: 50rem;
}

/* Animation utilities */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* List group refinements */
.list-group-item {
  border-color: var(--border-color);
  padding: 0.75rem 1rem;
}

.list-group-item:first-child {
  border-top-left-radius: var(--radius-sm);
  border-top-right-radius: var(--radius-sm);
}

.list-group-item:last-child {
  border-bottom-left-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

/* Mobile list groups */
@media (max-width: 768px) {
  .list-group-item {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* Alert styling */
.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
}

.alert-info {
  color: #0c5460;
  background-color: #d1ecf1;
  border-color: #bee5eb;
}

/* Add subtle transition effect for all interactive elements */
a, button, .card, .form-control, .nav-link {
  transition: all 0.2s ease;
}
