@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --primary: #206bc4;
  --secondary: #f0f4fa;
  --accent: #2fb344;
  --danger: #d63939;
  --muted: #7c8ca1;
  --background: #f9fafe;
  --card-radius: 10px;
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--background);
  color: #1a1a1a;
  line-height: 1.6;
  font-size: 16px;
  margin: 0;
}

/* NAV + BRANDING */
.navbar {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  background: white;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
}

/* BUTTONS */
.btn {
  border-radius: 8px;
  font-weight: 600;
  transition: var(--transition);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: #1a5ab1;
  border-color: #1a5ab1;
}

/* CARDS */
.card {
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: none;
  background-color: #ffffff;
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-2px);
}

.card-body {
  padding: 1.25rem;
}

/* FILTER CHIPS */
.filter-chips {
  display: flex;
  overflow-x: auto;
  flex-wrap: nowrap;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: var(--secondary);
  color: #206bc4;
  transition: var(--transition);
}

.filter-chip.active {
  background-color: var(--primary);
  color: #fff;
}

.filter-chip:hover {
  background-color: #d0e3f8;
}

/* MODALS */
.modal-content {
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.modal-form-row {
  margin-bottom: 1.5rem;
}

/* TABLES */
.table th, .table td {
  font-size: 0.9rem;
  padding: 0.75rem 0.5rem;
}

/* CHART WRAPPING */
.chart-container {
  overflow-x: auto;
  padding-bottom: 1rem;
}

/* TREND TOOLTIP */
.trend-tooltip,
.tooltip-text,
.card-tooltip .card-tooltip-text {
  font-size: 0.75rem;
  border-radius: 6px;
  padding: 6px 8px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  text-align: center;
  max-width: 240px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

/* SPARKLINE HEIGHT */
.trend-sparkline {
  height: 30px;
  margin-top: 0.5rem;
}

/* MOBILE STYLES */
@media (max-width: 768px) {
  .navbar-brand {
    font-size: 1.25rem;
  }

  .card-body {
    padding: 1rem;
  }

  .modal-dialog {
    margin: 0.75rem;
  }

  .btn,
  .btn-sm {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .trend-sparkline {
    height: 25px;
  }

  canvas {
    max-height: 250px !important;
  }

  .filter-chip {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .footer {
    font-size: 0.75rem;
  }
}

/* Enhanced badge styles */
.badge {
  font-weight: 600;
  padding: 0.35em 0.65em;
  border-radius: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Enhanced badge color gradients */
.badge.bg-success {
  background: linear-gradient(145deg, #259a39 0%, #2fb344 100%) !important;
}

.badge.bg-primary {
  background: linear-gradient(145deg, #1a579e 0%, #206bc4 100%) !important;
}

.badge.bg-purple {
  background: linear-gradient(145deg, #6941c6 0%, #8b5cf6 100%) !important;
}

.badge.bg-indigo {
  background: linear-gradient(145deg, #4338ca 0%, #6366f1 100%) !important;
}

.badge.bg-teal {
  background: linear-gradient(145deg, #0d9488 0%, #14b8a6 100%) !important;
}

.badge.bg-info {
  background: linear-gradient(145deg, #0ea5e9 0%, #38bdf8 100%) !important;
}

/* Optimize feed guide enhancements */
#optimal-tab .card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#optimal-tab .card:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#optimal-tab .table-hover tbody tr:hover {
  background-color: rgba(32, 107, 196, 0.05);
}

#optimal-tab .card-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
}

/* Enhanced summary cards styling */
.summary-card {
  transition: all 0.3s ease;
  overflow: hidden;
}

.summary-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.summary-card .display-6 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.trend-summary-card {
  transition: all 0.3s ease;
  border-radius: 10px;
  overflow: hidden;
}

.trend-summary-card:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.trend-summary-card .card-header {
  background: linear-gradient(145deg, #2c3e50 0%, #34495e 100%) !important;
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .trend-summary-card .card-header {
    background: linear-gradient(145deg, #344154 0%, #3e5063 100%) !important;
  }
}

/* TINY SCREENS */
@media (max-width: 400px) {
  .filter-chip {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .card .h1 {
    font-size: 1.2rem;
  }
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
  body {
    background-color: #121212;
    color: #eaeaea;
  }

  .card {
    background: linear-gradient(145deg, #1e1e1e 0%, #252525 100%);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  }

  .filter-chip {
    background-color: #2c2c2c;
    color: #ccc;
  }

  .filter-chip.active {
    background-color: var(--primary);
    color: white;
  }
  
  .card-tooltip .card-tooltip-text,
  .stat-tooltip .tooltip-text {
    background-color: rgba(0, 0, 0, 0.9);
  }
  
  .collapsible-section {
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .collapsible-header {
    background-color: rgba(255, 255, 255, 0.03) !important;
  }
  
  .collapsible-header:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
  }
  
  /* Fix for navbar in dark mode */
  .navbar {
    background-color: inherit !important;
  }
  
  /* Enhanced table styles for dark mode */
  .table {
    color: #e2e2e2;
  }
  
  .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  .card-header {
    background: linear-gradient(145deg, #222222 0%, #282828 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  /* Enhanced tab styles */
  .nav-tabs {
    border-bottom: none;
  }
  
  .nav-tabs .nav-link {
    color: #adb5bd;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
  }
  
  .nav-tabs .nav-link:hover {
    color: #eaeaea;
    border-color: transparent;
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  .nav-tabs .nav-link.active {
    color: #206bc4;
    border-color: #206bc4;
    background: linear-gradient(180deg, rgba(32, 107, 196, 0.1) 0%, rgba(32, 107, 196, 0) 100%);
    font-weight: 500;
  }
  
  /* Enhance main tab card header styling */
  .card > .card-header .nav-tabs .nav-link {
    transition: all 0.25s ease;
  }
  
  .card > .card-header .nav-tabs .nav-link.active {
    background: linear-gradient(180deg, rgba(32, 107, 196, 0.12) 0%, rgba(32, 107, 196, 0) 100%);
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
  }
  
  .tab-content {
    padding-top: 1rem;
  }
  
  /* Enhanced tab content styling */
  .tab-pane {
    animation: fadeIn 0.3s ease;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  /* Chart card header special styling */
  .chart-card-header {
    background: linear-gradient(145deg, #242424 0%, #2c2c2c 100%) !important;
    padding: 0.5rem 0.5rem 0 !important;
  }
  
  /* Adjust card body padding responsively */
  .card-body {
    padding: 1.25rem;
  }
  
  @media (max-width: 768px) {
    .card-body {
      padding: 0.75rem;
    }
  }
  
  .chart-card-header .nav-tabs .nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  
  .chart-card-header .nav-tabs .nav-link .icon {
    opacity: 0.7;
    transition: all 0.3s ease;
  }
  
  .chart-card-header .nav-tabs .nav-link:hover .icon {
    opacity: 1;
  }
  
  .chart-card-header .nav-tabs .nav-link.active .icon {
    opacity: 1;
    color: #206bc4;
  }
  
  /* Card sizing for chart tabs */
  #tabs-trends {
    padding-bottom: 2rem;
  }
  
  .card-body .tab-content {
    overflow: visible;
  }
  
  /* Additional space between the two main charts */
  #tabs-trends h4.mt-4 {
    margin-top: 2.5rem !important;
    padding-top: 1rem;
  }

  /* Chart container enhancements */
  .tab-pane canvas {
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    max-width: 100%;
    height: auto !important;
    margin: 0 auto;
    padding-top: 10px;
  }
  
  /* Make sure the chart containers properly size their content */
  #tabs-trends > div[style*="height"] {
    position: relative;
    overflow: visible;
    margin-bottom: 2.5rem;
    max-width: 100%;
  }
  
  /* Improve card and chart container sizing */
  .card {
    box-sizing: border-box;
    overflow: hidden;
    max-width: 100%;
  }
  
  .tab-pane {
    box-sizing: border-box;
    max-width: 100%;
    padding: 0.5rem;
  }
  
  .card-body {
    box-sizing: border-box;
    max-width: 100%;
  }
  
  /* Clock face chart enhancements */
  #clockFaceChart {
    margin: 0 auto;
    max-width: 300px;
  }
  
  /* Time of day chart container styling */
  #time-of-day-tab .row {
    margin-top: 1.5rem;
  }
  
  .feeding-times-container {
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    transition: all 0.3s ease;
    height: 400px;
    position: relative;
    overflow: visible;
    width: 100%;
    max-width: 100%;
  }
  
  .feeding-times-container:hover {
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
  }
  
  /* Mobile optimizations for feeding times analysis */
  .feeding-times-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 1rem;
    margin-bottom: 1.5rem;
  }
    
  #time-of-day-tab h4 {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    margin-bottom: 1rem;
  }
    
    .chart-tooltip {
      max-width: 180px;
      font-size: 0.75rem;
      padding: 4px 6px;
    }s
  }
  
  /* Dark mode specific mobile optimizations */
  @media (prefers-color-scheme: dark) and (max-width: 768px) {
    .feeding-times-container {
      background: rgba(40, 40, 40, 0.4);
      box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    
    .feeding-times-container canvas {
      background: rgba(45, 45, 45, 0.5);
      box-shadow: none;
    }
    
    #time-of-day-tab .text-muted {
      color: rgba(230, 230, 230, 0.7) !important;
    }
  }
  
  /* Extra small screens */
  @media (max-width: 375px) {
    .feeding-times-container {
      height: 280px;
      padding: 0.25rem;
    }
  }
  
  /* Subtle background colors for table sections */
  .bg-warning-subtle {
    background-color: rgba(255, 190, 11, 0.15);
  }
  
  .bg-orange-subtle {
    background-color: rgba(255, 126, 0, 0.15);
  }
  
  .bg-purple-subtle {
    background-color: rgba(181, 23, 158, 0.15);
  }
  
  .bg-blue-subtle {
    background-color: rgba(25, 25, 112, 0.15);
  }
  
  /* Feed volume table styles */
  .feed-volume-table thead {
    position: sticky;
    top: 0;
    background-color: inherit;
    z-index: 1;
  }
  
  .feed-volume-table {
    scrollbar-width: thin;
  }
  
  .feed-volume-table::-webkit-scrollbar {
    width: 6px;
  }
  
  .feed-volume-table::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
  }
  
  @media (prefers-color-scheme: dark) {
    .bg-warning-subtle {
      background-color: rgba(255, 190, 11, 0.1);
    }
    
    .bg-orange-subtle {
      background-color: rgba(255, 126, 0, 0.1);
    }
    
    .bg-purple-subtle {
      background-color: rgba(181, 23, 158, 0.1);
    }
    
    .bg-blue-subtle {
      background-color: rgba(25, 25, 112, 0.1);
    }
    
    .feed-volume-table::-webkit-scrollbar-thumb {
      background-color: rgba(255, 255, 255, 0.2);
    }
  }
  
  /* Enhance buttons in dark mode */
  .btn-primary {
    background: linear-gradient(145deg, #1a579e 0%, #206bc4 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  .btn-primary:hover {
    background: linear-gradient(145deg, #206bc4 0%, #1a579e 100%);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  }
  
  /* Dark mode adjustments for mobile */
  @media (max-width: 767.98px) {
    .collapsible-heading::after {
      background: rgba(255, 255, 255, 0.1);
    }
  }
}