/* Dashboard Main Container - Theme Support */
.light-mode .dashboard-container {
  min-height: 100vh;
  background: #e5e5e5;
  padding: 2rem;
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  overflow-x: hidden;
  box-sizing: border-box;
  color: #1a1a1a;
}

.night-mode .dashboard-container {
  min-height: 100vh;
  background: #2e2c2c;
  padding: 2rem;
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  overflow-x: hidden;
  box-sizing: border-box;
  color: rgba(255, 255, 255, 0.9);
}

.dashboard-container *,
.dashboard-container *::before,
.dashboard-container *::after {
  box-sizing: border-box;
}

.dashboard-stats-wrap {
  margin-bottom: 1.75rem;
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.dashboard-stat-card-wrap {
  min-width: 0;
  height: 100%;
  display: flex;
}

.dashboard-stat-card-wrap .stat-card {
  flex: 1;
  min-height: 0;
}

/* Dashboard chart sections */
.dashboard-section {
  margin-bottom: 2.25rem;
}

.dashboard-section:last-child {
  margin-bottom: 0;
}

.light-mode .dashboard-section-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e5e5;
}

.night-mode .dashboard-section-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.light-mode .dashboard-section-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.02em;
}

.night-mode .dashboard-section-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.98);
  letter-spacing: -0.02em;
}

.light-mode .dashboard-section-description {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: #757575;
}

.night-mode .dashboard-section-description {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
}

.dashboard-section-content {
  display: block;
}

/* Audit Trends filters: inside chart card, left-aligned */
.audit-trends-filters-wrap {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.audit-trends-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
}

.audit-trends-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.light-mode .audit-trends-filter-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #616161;
  letter-spacing: 0.02em;
}

.night-mode .audit-trends-filter-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}

.light-mode .audit-trends-select {
  min-width: 140px;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1a1a1a;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.night-mode .audit-trends-select {
  min-width: 140px;
  padding: 0.6rem 2rem 0.6rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  background: #3a3838;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.light-mode .audit-trends-select:hover {
  border-color: #f21b23;
}

.night-mode .audit-trends-select:hover {
  border-color: #f21b23;
}

.light-mode .audit-trends-select:focus {
  outline: none;
  border-color: #f21b23;
  box-shadow: 0 0 0 3px rgba(242, 27, 35, 0.15);
}

.night-mode .audit-trends-select:focus {
  outline: none;
  border-color: #f21b23;
  box-shadow: 0 0 0 3px rgba(242, 27, 35, 0.4);
}

.light-mode .audit-trends-loading {
  padding: 3rem 2rem;
  text-align: center;
  font-size: 0.9375rem;
  color: #757575;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--border-radius, 8px);
  border: 1px solid #e0e0e0;
}

.night-mode .audit-trends-loading {
  padding: 3rem 2rem;
  text-align: center;
  font-size: 0.9375rem;
  color: rgba(255, 255, 255, 0.75);
  background: #3a3838;
  border-radius: var(--border-radius, 8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.dashboard-section-content > .dashboard-charts-row:last-child,
.dashboard-section-content > .dashboard-main-grid:last-child {
  margin-bottom: 0;
}

.dashboard-obs-oc-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Shared card style for all chart components */
.light-mode .chart-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--border-radius, 8px);
  padding: 1.25rem 1.5rem;
  border: 1px solid #e5e5e5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  animation: slideIn 0.5s ease-out;
}

.night-mode .chart-card {
  background: #3a3838;
  border-radius: var(--border-radius, 8px);
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  animation: slideIn 0.5s ease-out;
}

/* Remove focus/click borders on charts (no black outline) */
.chart-card,
.chart-container,
.chart-card *,
.chart-container * {
  outline: none;
}
.chart-card:focus,
.chart-card:focus-visible,
.chart-container:focus,
.chart-container:focus-visible,
.chart-card *:focus,
.chart-card *:focus-visible,
.chart-container *:focus,
.chart-container *:focus-visible {
  outline: none !important;
}

/* Recharts internal wrapper (removes focus ring when interacting with chart) */
.chart-card .recharts-wrapper,
.chart-container .recharts-wrapper {
  outline: none !important;
}
.chart-card .recharts-wrapper:focus,
.chart-container .recharts-wrapper:focus {
  outline: none !important;
}

/* Night mode: chart axis labels, tick labels, grid – white text for visibility */
.night-mode .chart-card .recharts-text,
.night-mode .chart-container .recharts-text,
.night-mode .chart-card .recharts-cartesian-axis-tick-value,
.night-mode .chart-container .recharts-cartesian-axis-tick-value {
  fill: rgba(255, 255, 255, 0.9) !important;
}

.night-mode .chart-card .recharts-xAxis .recharts-line,
.night-mode .chart-card .recharts-yAxis .recharts-line,
.night-mode .chart-container .recharts-xAxis .recharts-line,
.night-mode .chart-container .recharts-yAxis .recharts-line {
  stroke: rgba(255, 255, 255, 0.35) !important;
}

.night-mode .chart-card .recharts-cartesian-grid line,
.night-mode .chart-container .recharts-cartesian-grid line {
  stroke: rgba(255, 255, 255, 0.15) !important;
}

.night-mode .chart-card .recharts-tooltip-wrapper,
.night-mode .chart-container .recharts-tooltip-wrapper {
  outline: none;
}

/* Short description under chart titles */
.light-mode .chart-subtitle {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #757575;
  font-weight: 400;
}

.night-mode .chart-subtitle {
  margin: 0 0 0.75rem 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
}

.dashboard-charts-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* RPN + Severity/Likelihood: top full width, bottom two equal columns */
.dashboard-rpn-harm-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dashboard-rpn-harm-top {
  width: 100%;
  min-width: 0;
}

.dashboard-rpn-harm-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  min-width: 0;
}

@media (max-width: 768px) {
  .dashboard-rpn-harm-bottom {
    grid-template-columns: 1fr;
  }
}

/* Audits per Month: single chart, full width */
.dashboard-charts-row-1 {
  grid-template-columns: 1fr;
}

.dashboard-charts-row-1 .chart-container,
.dashboard-charts-row-2 .chart-container,
.dashboard-charts-row-3 .chart-container {
  margin-bottom: 0;
}

/* SIO / OIO / CA section: keep cards in charts row layout */
.dashboard-charts-row .sio-oio-ca-wrapper {
  width: 100%;
  min-width: 0;
  gap: 1.25rem;
}

.dashboard-charts-row .sio-oio-ca-percentage-cards {
  gap: 1.25rem;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 1200px) {
  .dashboard-charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    padding: 1rem;
  }
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }
  .dashboard-section {
    margin-bottom: 1.5rem;
  }
  .dashboard-section-header {
    margin-bottom: 1rem;
  }
  .dashboard-section-title {
    font-size: 1.1rem;
  }
  .dashboard-section-description {
    font-size: 0.8125rem;
  }
  .dashboard-charts-row {
    gap: 1rem;
    margin-bottom: 1rem;
  }
  .dashboard-charts-row .sio-oio-ca-wrapper,
  .dashboard-charts-row .sio-oio-ca-percentage-cards {
    gap: 1rem;
  }
  .dashboard-main-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  .chart-card {
    padding: 1rem 1rem;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .dashboard-container {
    padding: 0.75rem;
  }
  .dashboard-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.625rem;
    margin-bottom: 1rem;
  }
  .dashboard-section-title {
    font-size: 1rem;
  }
  .dashboard-section-description {
    font-size: 0.75rem;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.stat-card {
  animation: fadeInUp 0.5s ease-out;
}

.chart-container {
  animation: slideIn 0.6s ease-out;
}

.activity-item {
  animation: fadeInUp 0.4s ease-out;
}

.dashboard-loading,
.dashboard-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 1rem;
}

.light-mode .dashboard-loading,
.light-mode .dashboard-error {
  color: #666;
}

.night-mode .dashboard-loading,
.night-mode .dashboard-error {
  color: rgba(255, 255, 255, 0.75);
}

.light-mode .dashboard-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e5e5;
  border-top-color: #f21b23;
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}

.night-mode .dashboard-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f21b23;
  border-radius: 50%;
  animation: dashboard-spin 0.8s linear infinite;
}

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

.light-mode .dashboard-error {
  color: #1a1a1a;
}

.night-mode .dashboard-error {
  color: rgba(255, 255, 255, 0.9);
}

.dashboard-error p {
  margin: 0;
  font-size: 1rem;
}
