/* ========================================
   MODERN DASHBOARD DESIGN SYSTEM
   ======================================== */

:root {
  /* Color Palette - Matching Navbar (#044B69 → #80d0c7) */
  --primary-color: #044B69;
  --primary-dark: #033a52;
  --primary-light: #055d84;
  --secondary-color: #80d0c7;
  --accent-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  /* Navbar gradient colors */
  --navbar-start: #044B69;
  --navbar-end: #80d0c7;

  /* Neutral Colors */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Background */
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-dark: #1f2937;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   GLOBAL STYLES
   ======================================== */

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ========================================
   MODERN FILTER PANEL
   ======================================== */

.modern-filter-panel {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transition: all var(--transition-base);
}

.modern-filter-panel::-webkit-scrollbar {
  width: 6px;
}

.modern-filter-panel::-webkit-scrollbar-track {
  background: var(--gray-100);
  border-radius: 3px;
}

.modern-filter-panel::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.modern-filter-panel::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

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

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

.filter-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.quick-action-btn {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--gray-300);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.quick-action-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* ========================================
   MODERN CARDS
   ======================================== */

.modern-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--spacing-lg);
  transition: all var(--transition-base);
  border: 1px solid var(--gray-200);
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--gray-100);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  font-size: 1.25rem;
}

.card-badge {
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

/* ========================================
   STATISTICS CARDS
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

.stat-card {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  color: white;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(30%, -30%);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.stat-card.stat-success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.stat-card.stat-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.stat-card.stat-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.stat-label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--spacing-xs);
}

.stat-change {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* ========================================
   LOADING STATES
   ======================================== */

.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-card {
  height: 400px;
  margin-bottom: var(--spacing-lg);
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--spacing-sm);
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--spacing-md);
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

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

.loading-text {
  margin-top: var(--spacing-md);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========================================
   MODERN DATA TABLE
   ======================================== */

.modern-table-wrapper {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-modern thead {
  background: var(--gray-50);
}

.table-modern th {
  padding: var(--spacing-md) var(--spacing-lg);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--gray-200);
}

.table-modern td {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.table-modern tbody tr:hover td {
  background: var(--gray-50);
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

/* ========================================
   MODERN CHARTS
   ======================================== */

.chart-container {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--spacing-lg);
}

.chart-wrapper {
  min-height: 400px;
  position: relative;
}

.plotly-graph-div {
  width: 100% !important;
  height: 100% !important;
}

/* ========================================
   TABS
   ======================================== */

.modern-tabs {
  display: flex;
  gap: var(--spacing-sm);
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: var(--spacing-xl);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.modern-tabs::-webkit-scrollbar {
  height: 4px;
}

.modern-tabs::-webkit-scrollbar-track {
  background: var(--gray-100);
}

.modern-tabs::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 2px;
}

.tab-button {
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  position: relative;
}

.tab-button:hover {
  color: var(--primary-color);
  background: var(--gray-50);
}

.tab-button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.tab-content {
  display: none;
  animation: fadeIn var(--transition-base);
}

.tab-content.active {
  display: block;
}

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

/* ========================================
   BUTTONS
   ======================================== */

.btn-modern {
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  text-decoration: none;
}

.btn-modern:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--gray-50);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* ========================================
   SELECT2 CUSTOMIZATION
   ======================================== */

.select2-container--default .select2-selection--single {
  border: 1px solid var(--gray-300) !important;
  border-radius: var(--radius-md) !important;
  height: 42px !important;
  padding: var(--spacing-sm) !important;
  transition: all var(--transition-fast) !important;
}

.select2-container--default .select2-selection--single:hover,
.select2-container--default .select2-selection--single:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 28px !important;
  color: var(--text-primary) !important;
  font-weight: 500 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px !important;
}

.select2-dropdown {
  border: 1px solid var(--gray-300) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
}

.select2-results__option {
  padding: var(--spacing-sm) var(--spacing-md) !important;
  transition: all var(--transition-fast) !important;
}

.select2-results__option--highlighted {
  background-color: var(--primary-color) !important;
}

/* ========================================
   DATATABLES CUSTOMIZATION
   ======================================== */

div.dataTables_wrapper {
  padding: var(--spacing-lg);
}

div.dataTables_wrapper div.dataTables_length select {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--spacing-xs) var(--spacing-sm);
  margin: 0 var(--spacing-sm);
}

div.dataTables_wrapper div.dataTables_filter input {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  margin-left: var(--spacing-sm);
  transition: all var(--transition-fast);
}

div.dataTables_wrapper div.dataTables_filter input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-md) !important;
  padding: var(--spacing-xs) var(--spacing-md) !important;
  margin: 0 2px !important;
  transition: all var(--transition-fast) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--primary-color) !important;
  color: white !important;
  border-color: var(--primary-color) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--primary-light) !important;
  color: white !important;
  border-color: var(--primary-light) !important;
}

.dt-buttons {
  margin-bottom: var(--spacing-md);
}

.dt-button {
  background: var(--bg-primary) !important;
  border: 1px solid var(--gray-300) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--spacing-sm) var(--spacing-md) !important;
  color: var(--text-primary) !important;
  font-weight: 500 !important;
  transition: all var(--transition-fast) !important;
  margin-right: var(--spacing-sm) !important;
}

.dt-button:hover {
  background: var(--primary-color) !important;
  color: white !important;
  border-color: var(--primary-color) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm) !important;
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 768px) {
  .modern-filter-panel {
    position: relative;
    margin-bottom: var(--spacing-lg);
  }

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

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .modern-tabs {
    gap: var(--spacing-xs);
  }

  .tab-button {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.75rem;
  }
}

@media (max-width: 576px) {
  .modern-card {
    padding: var(--spacing-md);
  }

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

  .stat-value {
    font-size: 1.5rem;
  }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--spacing-sm) !important; }
.mt-2 { margin-top: var(--spacing-md) !important; }
.mt-3 { margin-top: var(--spacing-lg) !important; }
.mt-4 { margin-top: var(--spacing-xl) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-sm) !important; }
.mb-2 { margin-bottom: var(--spacing-md) !important; }
.mb-3 { margin-bottom: var(--spacing-lg) !important; }
.mb-4 { margin-bottom: var(--spacing-xl) !important; }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

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

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-1 { gap: var(--spacing-sm) !important; }
.gap-2 { gap: var(--spacing-md) !important; }
.gap-3 { gap: var(--spacing-lg) !important; }

.fade-in {
  animation: fadeIn var(--transition-base);
}

/* ========================================
   ANOMALY INDICATORS
   ======================================== */

.anomaly-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
}

.anomaly-high {
  background: #fee2e2;
  color: #991b1b;
}

.anomaly-low {
  background: #fef3c7;
  color: #92400e;
}

.anomaly-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  font-size: 0.625rem;
  font-weight: 700;
}
