/* Modern CSS Variables for Design System */
:root {
  --primary-color: #ff6b35;
  --primary-dark: #e55a2b;
  --secondary-color: #4ecdc4;
  --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, #667eea 0%, #764ba2 100%);
  --bg-hero: linear-gradient(135deg, #ff6b35 0%, #f7931e 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;
}

/* Dark theme variables */
[data-bs-theme="dark"] {
  --text-primary: #ecf0f1;
  --text-secondary: #bdc3c7;
  --text-light: #7f8c8d;

  --bg-primary: #1a1a1a;
  --bg-secondary: #2c2c2c;
  --bg-card: #2c2c2c;
  --border-color: #404040;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 25px rgba(0,0,0,0.5);
}

/* 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: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Hero Section */
.hero-section {
  background: var(--bg-hero);
  color: white;
  padding: 4rem 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.1;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.hero-subtitle {
  font-size: 1.5rem;
  font-weight: 400;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.hero-description {
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
  opacity: 0.8;
}

/* 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: 1rem 0;
}

.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);
}

/* 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: var(--bg-gradient);
  color: white;
  padding: 1.5rem;
  border-bottom: none;
  font-weight: 600;
  font-size: 1.2rem;
}

.card-body {
  padding: 2rem;
}

/* Enhanced Form Styling */
.form-section {
  margin: 3rem 0;
}

.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-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, #e55a2b 0%, #e8851e 100%);
}

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

.btn-secondary:hover {
  background: var(--accent-color);
  transform: translateY(-2px);
}

.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;
}

/* Body rows – add a subtle highlight on hover for readability */
.table tbody tr {
  transition: var(--transition);
}

.table tbody tr:hover {
  background-color: rgba(255, 107, 53, 0.05);
}

/* 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 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.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: 400px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

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

  .chart-container > div:last-child {
    min-height: 450px;
  }
}

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

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

  .chart-container > div:last-child {
    min-height: 350px;
  }
}

/* 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;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 15px;
  }

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

@media (max-width: 480px) {
  .hero-section {
    padding: 2rem 0;
  }

  .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;
}

.fade-in {
  animation: fadeIn 0.6s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Parameter Changes Styling */
.parameter-change {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.parameter-change:hover {
  box-shadow: var(--shadow-sm);
}

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

/* Theme Toggle Enhancement */
#theme-toggle {
  border-radius: 50px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

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

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

  .hero-section {
    background: none !important;
    color: black !important;
  }

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