/* Modern card styling with subtle shadows */
.analysis-card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 10px 30px rgba(59, 59, 59, 0.05);
  transition: all 0.3s ease;
  overflow: hidden;
}

.analysis-card .card-header {
  background: linear-gradient(135deg, #4a6377, #2c3e50);
  color: #f8f8f8;
  border-bottom: none;
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Light card header variant — matches default Bootstrap look */
.analysis-card--light .card-header {
  background: #f8f9fa;
  color: #2c3e50;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.75rem 1.25rem;
}

.analysis-card--light .card-header h5 {
  font-size: 0.95rem;
  font-weight: 600;
}

/* Chart info icon in card header */
.chart-info-icon {
  color: #2c3e50;
  font-size: 0.875rem;
  cursor: help;
  transition: color 0.2s ease;
}

.chart-info-icon:hover {
  color: #1a252f;
}

/* Dark header variant (default analysis-card) */
.analysis-card .card-header .chart-info-icon {
  color: #f8f8f8;
}

.analysis-card .card-header .chart-info-icon:hover {
  color: #ffffff;
}

/* Light header variant — override back to dark icon */
.analysis-card--light .card-header .chart-info-icon {
  color: #2c3e50;
}

.analysis-card--light .card-header .chart-info-icon:hover {
  color: #1a252f;
}

/* Filter controls styling */
.filter-controls {
  background-color: #eef2f5;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
}

.filter-section {
  transition: all 0.3s ease;
}

.input-group {
  box-shadow: 0 2px 5px rgba(59, 59, 59, 0.05);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.input-group-text {
  background-color: #f8f8f8;
  border: none;
  color: #3b3b3b;
  font-weight: 500;
}

.form-control, .form-select {
  border-color: #ebebeb;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}

.btn-filter {
  background: linear-gradient(135deg, #4a6377, #2c3e50);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 6px rgba(42, 62, 80, 0.25);
  transition: all 0.3s ease;
  color: #f8f8f8;
}

.btn-filter:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(42, 62, 80, 0.3);
  background: linear-gradient(135deg, #3a4f5f, #1a2530);
}

/* Chart container styling */
.chart-container {
  padding: 1rem;
  border-radius: 12px;
  background-color: #f8f8f8;
}

/* Chart wrapper base styles */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 400px;
  margin-bottom: 1.5rem;
}

.chart-container {
  position: relative;
  height: 100%;
  width: 100%;
}

.chart-title {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: #f8f8f8;
  font-weight: 600;
}

/* Modern Metric Card Styling */
.metric-card {
  --card-padding: 1.25rem;
  --card-radius: 12px;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --card-bg: #ffffff;
  --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --title-color: #6c757d;
  --value-color: #2c3e50;
  --subtitle-color: #8898aa;
  --transition-duration: 0.2s;

  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: var(--card-padding);
  transition: transform var(--transition-duration) ease,
              box-shadow var(--transition-duration) ease;
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: default;
}

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

.metric-card__content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-card__title {
  color: var(--title-color);
  font-size: 0.75rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.metric-card__value {
  color: var(--value-color);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 0.125rem;
  margin-top: 0.125rem;
}

.metric-card__prefix,
.metric-card__suffix {
  font-size: 0.875em;
  opacity: 0.8;
}

.metric-card__number {
  transition: color var(--transition-duration) ease;
}

.metric-card__subtitle {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--subtitle-color);
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.metric-card__subtitle-label {
  font-weight: 500;
}

.metric-card__subtitle-value {
  opacity: 0.9;
}

/* Metric card color variants — semantic (direction of value) */
.metric-card--neutral  { border-left: 4px solid #94a3b8; } /* slate   — Revenue, VAT, Count */
.metric-card--positive { border-left: 4px solid #10b981; } /* emerald — Profit, Profit %   */
.metric-card--negative { border-left: 4px solid #f43f5e; } /* rose    — Cost, Cost %       */

/* Restore compact sizing for Bootstrap's small form controls */
.form-select-sm {
  padding: 0.25rem 2rem 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Scrollable table wrapper — caps height for large datasets */
.table-scroll {
  max-height: 500px;
  overflow-y: auto;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  .analysis-card {
    border-radius: 8px;
  }

  .analysis-card .card-header {
    padding: 1rem;
  }

  .chart-wrapper {
    min-height: 250px;
    height: auto;
    margin-bottom: 1rem;
  }

  .chart-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: white
  }

  .filter-controls {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
  }

  .filter-controls .collapse:not(.show) {
    display: none;
  }

  .filter-controls .collapse.show {
    animation: slideDown 0.3s ease forwards;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .filter-section {
    margin-bottom: 0.75rem;
  }

  .form-control, .form-select {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
  }

  .btn-filter {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    min-height: 48px;
  }

  .input-group {
    margin-bottom: 0.5rem;
  }

  /* Mobile metric card adjustments */
  .metric-card {
    --card-padding: 1rem;
    --card-radius: 8px;
    padding: var(--card-padding);
    min-height: 88px; /* Ensure good touch target size */
  }

  .metric-card__title {
    font-size: 0.675rem;
  }

  .metric-card__value {
    font-size: 1.5rem;
    margin-top: 0.125rem;
  }

  .metric-card__subtitle {
    font-size: 0.6875rem;
    margin-top: 0.375rem;
  }

  /* Improve touch targets */
  .btn, .form-control, .form-select {
    min-height: 32px;
  }

  /* Adjust spacing for filter groups */
  .filter-group {
    margin-bottom: 0.75rem;
  }

  /* Make charts more compact */
  .chart-container {
    padding: 0.5rem;
  }
}

/* Tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .chart-wrapper {
    height: 350px;
  }

  .metric-card {
    --card-padding: 1.125rem;
  }

  .metric-card__title {
    font-size: 0.7rem;
  }

  .metric-card__value {
    font-size: 1.625rem;
  }

  .metric-card__subtitle {
    font-size: 0.75rem;
  }
}

/* Ensure charts are responsive */
@media (orientation: landscape) and (max-width: 768px) {
  .chart-wrapper {
    height: 70vh;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .metric-card {
    --card-shadow: none;
    --card-hover-shadow: none;
    border: 2px solid currentColor;
  }

  .metric-card__title,
  .metric-card__value,
  .metric-card__subtitle {
    color: currentColor;
  }
}
