
/* CSS Variables - Bootstrap Overrides & Custom Theme */
:root {
  /* Bootstrap CSS Variable Overrides */
  --bs-primary: #0056b3;
  --bs-primary-rgb: 0, 86, 179;
  --bs-secondary: #6c757d;
  --bs-secondary-rgb: 108, 117, 125;
  --bs-success: #28a745;
  --bs-success-rgb: 40, 167, 69;
  --bs-danger: #dc3545;
  --bs-danger-rgb: 220, 53, 69;
  --bs-warning: #ffc107;
  --bs-warning-rgb: 255, 193, 7;
  --bs-info: #17a2b8;
  --bs-info-rgb: 23, 162, 184;
  --bs-light: #f8f9fa;
  --bs-light-rgb: 248, 249, 250;
  --bs-dark: #343a40;
  --bs-dark-rgb: 52, 58, 64;
  --bs-body-font-size: 0.95rem;
  --bs-body-line-height: 1.6;
  --bs-border-radius: 0.5rem;

  /* Bootstrap Component Overrides */
  --bs-card-border-width: 0;
  --bs-card-box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
  --bs-heading-font-weight: 600;

  /* Mill-specific colors */
  --mill-a-color: #007bff;
  --mill-b-color: #6610f2;

  /* Shift colors */
  --shift-day-color: #ffc107;
  --shift-night-color: #17a2b8;
  --shift-a-color: #007bff;
  --shift-b-color: #28a745;
  --shift-c-color: #dc3545;

  /* Spacing */
  --card-spacing: 1.5rem;
  --section-spacing: 2rem;

  --navbar-height: 48px;
}

/* Typography & Base Styles */
body {
  background-color: #e9ecef;
}

h1, h2, h3, h4, h5, h6 {
  margin-bottom: 1rem;
}


/* Card Enhancements */
.card {
  background-color: #fff;
  transition: box-shadow 0.3s ease-in-out, transform 0.2s ease-in-out;
}

.card:hover {
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
}

.card-header {
  background-color: var(--bs-light);
  border-bottom: 2px solid var(--bs-gray-200, #e9ecef);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

.card-title {
  margin-bottom: 0;
  font-size: 1.1rem;
}

/* Chart cards */
.chart-card {
  margin-bottom: var(--card-spacing);
}

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

/* Chart containers */
.chart-container {
  width: 100%;
  height: 400px;
}

.chart-container-lg {
  width: 100%;
  height: 500px;
}

/* Tables */
.table {
  margin-bottom: 0;
}

.table thead th {
  border-bottom: 2px solid var(--bs-gray-300, #dee2e6);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  color: var(--bs-dark);
}

.table-hover tbody tr {
  transition: background-color 0.15s ease-in-out;
}

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

/* Responsive table wrapper */
.table-responsive {
  border-radius: 0.25rem;
}

/* Sticky table headers (for data export page) */
.table-sticky-header thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
  box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Scrollable container for export table */
.export-table-container {
  max-height: calc(100vh - 320px);
  overflow: auto;
}

@media (max-width: 768px) {
  .export-table-container {
    max-height: calc(100vh - 280px);
  }
}

/* Badges & Status Indicators */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
  font-size: 0.875rem;
}

/* Mill badges */
.mill-badge {
  font-weight: 600;
  padding: 0.4em 0.8em;
}

.mill-badge.mill-a {
  background-color: var(--mill-a-color);
  color: white;
}

.mill-badge.mill-b {
  background-color: var(--mill-b-color);
  color: white;
}

/* Shift type badges */
.shift-badge {
  font-weight: 600;
  padding: 0.4em 0.8em;
}

.shift-badge.shift-a {
  background-color: var(--shift-a-color);
  color: white;
}

.shift-badge.shift-b {
  background-color: var(--shift-b-color);
  color: white;
}

.shift-badge.shift-c {
  background-color: var(--shift-c-color);
  color: white;
}

.shift-badge.shift-day {
  background-color: var(--shift-day-color);
  color: #000;
}

.shift-badge.shift-night {
  background-color: var(--shift-night-color);
  color: white;
}

/* Event type badges */
.event-badge {
  font-weight: 500;
}

/* Status indicators */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.status-dot.status-active {
  background-color: var(--bs-success);
}

.status-dot.status-warning {
  background-color: var(--bs-warning);
}

.status-dot.status-inactive {
  background-color: var(--bs-secondary);
}

/* Buttons */
.btn {
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

/* Navbar */
.navbar.sticky-top {
  position: sticky;
  top: 0;
  z-index: 1030;
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.navbar-brand img {
  height: 20px;
  width: 20px;
  margin-right: 0.5rem;
}

.navbar-logo-center {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem 1rem;
}

.navbar-logo {
  height: 32px;
  max-width: 100%;
  object-fit: contain;
  filter: invert(1);
}

/* Navigation & Sidebar */
.container-fluid {
  padding-top: 0;
}

.sidebar {
  position: sticky;
  top: var(--navbar-height);
  max-height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  border-radius: 0 0.5rem 0.5rem 0;
  border-right: none;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.3s ease;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

/* Mobile sidebar styles - collapse behavior */
@media (max-width: 767.98px) {
  #sidebar.collapse:not(.show) {
    display: none;
  }

  #sidebar.collapsing {
    display: block;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    z-index: 1040;
    background: var(--bs-body-bg);
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  }

  #sidebar.collapse.show {
    display: block;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    z-index: 1040;
    background: var(--bs-body-bg);
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  }
}

.nav-link.active {
  font-weight: 600;
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  border-left: 4px solid var(--bs-primary);
  padding-left: calc(0.5rem - 1px); 
}

.nav-link {
  transition: all 0.15s ease-in-out;
  margin-bottom: 0.125rem;
  border-left: 4px solid transparent;
  padding-left: 0.5rem;
}

.nav-link:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.05);
  border-left-color: rgba(var(--bs-primary-rgb), 0.3);
  transform: translateX(2px);
}

/* Forms */
.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Form Formsets */
.multiField {
  background-color: var(--bs-gray-100, #f8f9fa);
  padding: 1rem;
  margin-bottom: 2rem;
  border-radius: 0.375rem;
}

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

/* Progress Bars */
.progress {
  height: 1.25rem;
  border-radius: 0.375rem;
  background-color: #e9ecef;
}

.progress-bar {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Alerts */
.alert {
  border: none;
  border-left: 4px solid;
}

.alert-info {
  background-color: rgba(var(--bs-info-rgb), 0.1);
  border-left-color: var(--bs-info);
}

.alert-success {
  background-color: rgba(var(--bs-success-rgb), 0.1);
  border-left-color: var(--bs-success);
}

.alert-warning {
  background-color: rgba(var(--bs-warning-rgb), 0.1);
  border-left-color: var(--bs-warning);
}

.alert-danger {
  background-color: rgba(var(--bs-danger-rgb), 0.1);
  border-left-color: var(--bs-danger);
}

/* Timeline (for shift events) */
.timeline-event {
  position: relative;
  padding-left: 2rem;
  padding-bottom: 1.5rem;
  border-left: 2px solid #e9ecef;
}

.timeline-event:last-child {
  border-left: none;
}

.timeline-event::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--bs-primary);
  border: 2px solid white;
}

.timeline-event.event-maintenance::before {
  background-color: var(--bs-danger);
}

.timeline-event.event-planned::before {
  background-color: var(--bs-info);
}

/* Shift Header */
.shift-header {
  background: linear-gradient(135deg, var(--bs-primary) 0%, #003d82 100%);
  color: white;
  padding: 2rem;
  border-radius: var(--bs-border-radius);
  margin-bottom: var(--section-spacing);
}

.shift-header h1 {
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.shift-header .shift-meta {
  font-size: 1.1rem;
  opacity: 0.95;
}

/* Metric Row */
.metric-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e9ecef;
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row .metric-label {
  flex: 1;
  font-weight: 500;
  color: var(--bs-dark);
}

.metric-row .metric-value {
  font-weight: 600;
  color: var(--bs-primary);
}

/* Utility Classes */
.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.shadow {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.mb-section {
  margin-bottom: var(--section-spacing);
}

.text-muted-light {
  color: var(--bs-gray-600, #868e96);
}

/* Spacing utilities */
.gap-4 {
  gap: 1.5rem;
}

/* Loading States */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .stat-value {
    font-size: 1.5rem;
  }

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

  .chart-card .card-body {
    padding: 1rem;
  }

  .shift-header {
    padding: 1.5rem;
  }
}

/* Bootstrap Icons Enhancements */
.bi {
  vertical-align: -0.125em;
}

.nav-link .bi {
  font-size: 1.1rem;
  margin-right: 0.25rem;
}

.btn .bi {
  margin-right: 0.25rem;
  display: inline-block;
  vertical-align: middle;
}

.card-title .bi {
  font-size: 1rem;
  margin-right: 0.35rem;
  color: var(--bs-primary);
}

h4 .bi, h5 .bi {
  color: var(--bs-primary);
  margin-right: 0.5rem;
}

/* Icon size utilities */
.bi.icon-md {
  font-size: 1.2rem;
}

.bi.icon-lg {
  font-size: 1.5rem;
}

/* Print Styles */
@media print {
  .card {
    box-shadow: none;
    border: 1px solid #dee2e6;
    page-break-inside: avoid;
  }

  .btn, .nav-link {
    display: none;
  }

  .chart-card {
    page-break-inside: avoid;
  }

  /* Hide icons in print */
  .bi {
    display: none;
  }
}
