/**
 * AgIntelligence brand theme
 * Green + grey palette: light grey/white surfaces, charcoal sidebar, vibrant emerald accent.
 * Load after material-dashboard.css.
 */

:root {
  /* Emerald green accent (vibrant, pops on grey) */
  --color-primary: #2E9D6E;
  --color-primary-hover: #259267;
  --color-primary-soft: #E8F5EF;
  --color-primary-900: #1B6B4A;
  --color-primary-700: #259267;
  --color-primary-500: #2E9D6E;
  --color-primary-300: #5BB892;
  --color-primary-100: #E8F5EF;

  /* Secondary accent (sunny yellow — sparingly) */
  --color-accent: #E8C547;
  --color-accent-soft: #FDF8E8;

  /* Tertiary (warm brown — section/brand) */
  --color-warm: #A67C52;
  --color-warm-soft: #F5EDE4;

  /* Neutrals: very light grey page, white cards, soft borders */
  --color-background: #FAFAFA;
  --color-surface: #FFFFFF;
  --color-border: #EEEEEE;
  --color-border-strong: #E0E0E0;
  --color-text-primary: #333333;
  --color-text-secondary: #666666;
  --color-text-tertiary: #777777;

  /* Sidebar (light mode): light grey to match palette; active = green highlight */
  --color-sidebar: #F0F0F0;
  --color-sidebar-text: #333333;
  --color-sidebar-text-muted: #666666;
  --color-sidebar-hover: rgba(0, 0, 0, 0.04);
  --color-sidebar-active-bg: rgba(46, 157, 110, 0.12);
  --color-sidebar-divider: rgba(0, 0, 0, 0.08);

  /* Semantic */
  --color-success: #2E9D6E;
  --color-success-soft: #E8F5EF;
  --color-warning: #C99A3A;
  --color-warning-soft: #FDF8E8;
  --color-danger: #C44536;
  --color-danger-soft: #F8E7E5;

  /* Charts */
  --chart-primary: #2E9D6E;
  --chart-secondary: #5BB892;
  --chart-tertiary: #A7D4BE;
  --chart-highlight: #E8C547;
  --chart-negative: #C44536;
}

/* Override Bootstrap/Material theme variables so entire UI inherits */
:root,
[data-bs-theme="light"] {
  --bs-primary: #2E9D6E;
  --bs-primary-rgb: 46, 157, 110;
  --bs-primary-text-emphasis: #1B6B4A;
  --bs-primary-bg-subtle: #E8F5EF;
  --bs-primary-border-subtle: #5BB892;

  --bs-secondary: #666666;
  --bs-secondary-rgb: 102, 102, 102;

  --bs-success: #2E9D6E;
  --bs-success-rgb: 46, 157, 110;
  --bs-success-text-emphasis: #1B6B4A;
  --bs-success-bg-subtle: #E8F5EF;
  --bs-success-border-subtle: #5BB892;

  --bs-info: #259267;
  --bs-info-rgb: 37, 146, 103;
  --bs-info-text-emphasis: #1B6B4A;
  --bs-info-bg-subtle: #E8F5EF;
  --bs-info-border-subtle: #5BB892;

  --bs-warning: #C99A3A;
  --bs-warning-rgb: 201, 154, 58;
  --bs-warning-text-emphasis: #7a5c1a;
  --bs-warning-bg-subtle: #FDF8E8;
  --bs-warning-border-subtle: #E8C547;

  --bs-danger: #C44536;
  --bs-danger-rgb: 196, 69, 54;
  --bs-danger-text-emphasis: #7a2b22;
  --bs-danger-bg-subtle: #F8E7E5;
  --bs-danger-border-subtle: #d48982;

  --bs-dark: #333333;
  --bs-dark-rgb: 51, 51, 51;

  --bs-body-color: #666666;
  --bs-body-color-rgb: 102, 102, 102;
  --bs-body-bg: #F8F8F8;
  --bs-body-bg-rgb: 248, 248, 248;
  --bs-heading-color: #333333;
  --bs-link-color: #2E9D6E;
  --bs-link-color-rgb: 46, 157, 110;
  --bs-link-hover-color: #259267;
  --bs-link-hover-color-rgb: 37, 146, 103;
  --bs-border-color: #EEEEEE;
  --bs-border-color-translucent: rgba(0, 0, 0, 0.08);

  --bs-gray-100: #F8F8F8;
  --bs-gray-200: #F0F0F0;
  --bs-gray-300: #EEEEEE;
  --bs-gray-500: #666666;
  --bs-gray-600: #666666;
  --bs-gray-700: #333333;
  --bs-gray-800: #333333;
  --bs-gray-900: #333333;
}

/* Gradient overrides (emerald green) */
.bg-gradient-primary {
  background: #2E9D6E !important;
  background-image: linear-gradient(195deg, #2E9D6E 0%, #259267 100%) !important;
}
.bg-gradient-success {
  background-image: linear-gradient(195deg, #2E9D6E 0%, #1B6B4A 100%) !important;
}
.bg-gradient-info {
  background-image: linear-gradient(195deg, #259267 0%, #1B6B4A 100%) !important;
}
.bg-gradient-warning {
  background-image: linear-gradient(195deg, #E8C547 0%, #C99A3A 100%) !important;
}
.bg-gradient-danger {
  background-image: linear-gradient(195deg, #d45646 0%, #C44536 100%) !important;
}

/* Buttons: solid emerald, subtle shadow */
.btn.bg-gradient-primary,
.btn-primary {
  background: #2E9D6E !important;
  background-image: linear-gradient(195deg, #2E9D6E 0%, #259267 100%) !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(46, 157, 110, 0.25) !important;
}
.btn.bg-gradient-primary:hover,
.btn-primary:hover {
  background: #259267 !important;
  background-image: linear-gradient(195deg, #259267 0%, #1B6B4A 100%) !important;
  box-shadow: 0 4px 12px rgba(46, 157, 110, 0.3) !important;
}

/* Sidebar: light grey; active = green left strip + soft green bg (ag-sidenav overrides below) */
.sidenav .nav-link.active {
  background: var(--color-sidebar-active-bg, rgba(46, 157, 110, 0.12)) !important;
  background-image: none !important;
  color: var(--color-primary, #2E9D6E) !important;
  box-shadow: none !important;
}

/* Body: very light grey (clean reference look) */
body.g-sidenav-show,
.bg-gray-100 {
  background-color: var(--color-background, #FAFAFA) !important;
}

/* ========== Dark mode: same greens, darker contrast for lines/surfaces ========== */
html[data-bs-theme="dark"] {
  /* Greens unchanged so they pop on dark */
  --color-primary: #2E9D6E;
  --color-primary-hover: #3AB07E;
  --color-primary-soft: rgba(46, 157, 110, 0.18);
  --color-primary-100: rgba(46, 157, 110, 0.15);
  --color-primary-300: #5BB892;
  --color-primary-700: #259267;

  /* Dark surfaces and stronger borders */
  --color-background: #1a1d21;
  --color-surface: #24262b;
  --color-border: #3a3e44;
  --color-border-strong: #4a4f56;
  --color-text-primary: #e8eaed;
  --color-text-secondary: #b8bcc4;
  --color-text-tertiary: #9aa0a8;

  /* Sidebar: dark again; active = same green highlight */
  --color-sidebar: #24262b;
  --color-sidebar-text: #e8eaed;
  --color-sidebar-text-muted: #9aa0a8;
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-sidebar-active-bg: rgba(46, 157, 110, 0.18);
  --color-sidebar-divider: rgba(255, 255, 255, 0.08);
}

html[data-bs-theme="dark"] body.g-sidenav-show,
html[data-bs-theme="dark"] .bg-gray-100 {
  background-color: #1a1d21 !important;
}

html[data-bs-theme="dark"] .main-content,
html[data-bs-theme="dark"] .main-content .container-fluid {
  background-color: #1a1d21 !important;
}

html[data-bs-theme="dark"] .ag-card,
html[data-bs-theme="dark"] .ag-snapshot-tile,
html[data-bs-theme="dark"] .ag-card-chart-wrap,
html[data-bs-theme="dark"] .ag-drivers-panel,
html[data-bs-theme="dark"] .ag-feed-card {
  background: #24262b !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  border-color: #3a3e44;
}

html[data-bs-theme="dark"] .ag-card:hover,
html[data-bs-theme="dark"] .ag-snapshot-tile:hover,
html[data-bs-theme="dark"] .ag-feed-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

html[data-bs-theme="dark"] .ag-sidenav {
  background: #24262b !important;
  border-right-color: #3a3e44 !important;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.2);
}

html[data-bs-theme="dark"] .ag-sidenav .navbar-brand .text-dark,
html[data-bs-theme="dark"] .ag-sidenav .navbar-brand .text-sm,
html[data-bs-theme="dark"] .ag-sidenav .nav-link-text {
  color: #e8eaed !important;
}

html[data-bs-theme="dark"] .ag-sidenav .nav-link {
  color: #9aa0a8 !important;
}

html[data-bs-theme="dark"] .ag-sidenav .nav-link:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #e8eaed !important;
}

html[data-bs-theme="dark"] .ag-sidenav .nav-link.active {
  background: rgba(46, 157, 110, 0.18) !important;
  color: #2E9D6E !important;
  border-left-color: #2E9D6E;
}

html[data-bs-theme="dark"] .ag-sidenav .nav-link.active .ag-sidenav-icon,
html[data-bs-theme="dark"] .ag-sidenav .nav-link.active .nav-link-text {
  color: #2E9D6E !important;
}

html[data-bs-theme="dark"] .ag-sidenav .ag-sidenav-section {
  color: #9aa0a8 !important;
}

html[data-bs-theme="dark"] .ag-sidenav hr.horizontal {
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Dark: page headings, section titles, body text */
html[data-bs-theme="dark"] .ag-page-heading h1,
html[data-bs-theme="dark"] .ag-page-heading h2,
html[data-bs-theme="dark"] .ag-page-heading h4,
html[data-bs-theme="dark"] .ag-section-title {
  color: #e8eaed !important;
}

html[data-bs-theme="dark"] .ag-page-heading .subtitle,
html[data-bs-theme="dark"] .ag-recap-link,
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-why,
html[data-bs-theme="dark"] .text-secondary {
  color: #b8bcc4 !important;
}

html[data-bs-theme="dark"] .ag-snapshot-tile .ag-snapshot-label,
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-tag {
  color: #b8bcc4 !important;
}

html[data-bs-theme="dark"] .ag-snapshot-tile .ag-snapshot-price,
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-title,
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-impact {
  color: #e8eaed !important;
}

html[data-bs-theme="dark"] .ag-chip {
  border-color: #3a3e44;
  background: #24262b;
  color: #b8bcc4;
}

html[data-bs-theme="dark"] .ag-chip:hover {
  border-color: #5BB892;
  background: rgba(46, 157, 110, 0.18);
  color: #5BB892;
}

html[data-bs-theme="dark"] .ag-topbar .form-label,
html[data-bs-theme="dark"] .ag-topbar .as-of {
  color: #b8bcc4 !important;
}

html[data-bs-theme="dark"] .ag-topbar .input-group-outline .form-control {
  background: #24262b !important;
  border-color: #3a3e44 !important;
  color: #e8eaed !important;
}

html[data-bs-theme="dark"] .ag-card-chart-wrap::before {
  background: #2E9D6E;
}

html[data-bs-theme="dark"] .canola-chart-wrapper .ag-chart-meta,
html[data-bs-theme="dark"] .ag-drivers-panel .ag-driver-bullets {
  color: #9aa0a8 !important;
  border-color: #3a3e44 !important;
}

html[data-bs-theme="dark"] .ag-drivers-panel {
  background: #24262b !important;
}

html[data-bs-theme="dark"] .ag-drivers-panel .ag-driver-icon-circle {
  background: rgba(46, 157, 110, 0.15);
}

html[data-bs-theme="dark"] .ag-feed-card .ag-feed-direction.bg-success-subtle { background: rgba(46, 157, 110, 0.2) !important; }
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-direction.bg-danger-subtle { background: rgba(196, 69, 54, 0.2) !important; }
html[data-bs-theme="dark"] .ag-feed-card .ag-feed-direction.bg-warning-subtle { background: rgba(201, 154, 58, 0.2) !important; }

html[data-bs-theme="dark"] .ag-snapshot-icon-wrap {
  background: rgba(46, 157, 110, 0.15) !important;
}

html[data-bs-theme="dark"] .ag-snapshot-icon-wrap .material-symbols-rounded {
  color: #5BB892 !important;
}

html[data-bs-theme="dark"] .ag-feed-card .ag-feed-tag {
  background: #3a3e44 !important;
  color: #b8bcc4 !important;
}

html[data-bs-theme="dark"] .ag-feed-media {
  background: #2a2d32 !important;
}

/* Cards: pure white, soft shadow */
.card,
.sidenav.bg-white {
  background-color: #FFFFFF !important;
}
.card.bg-gray-100 {
  background-color: #F8F8F8 !important;
}

/* Text gradients (icons) */
.text-primary.text-gradient,
.text-gradient[class*="primary"] {
  background: linear-gradient(195deg, #2E9D6E 0%, #259267 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Progress bars */
.progress-bar.bg-gradient-info {
  background: #2E9D6E !important;
}
.progress-bar.bg-gradient-success {
  background: #2E9D6E !important;
}

/* Form controls */
.form-check-input:checked {
  background-color: #2E9D6E !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e") !important;
}
.input-group-outline .form-control:focus,
.form-control:focus {
  border-color: #2E9D6E !important;
}

/* Fixed plugin badges */
.badge.filter.bg-gradient-primary {
  background: #2E9D6E !important;
}
.badge.filter.bg-gradient-success {
  background: #2E9D6E !important;
}
.badge.filter.bg-gradient-info {
  background: #259267 !important;
}
.badge.filter.bg-gradient-warning {
  background: #C99A3A !important;
}
.badge.filter.bg-gradient-danger {
  background: #C44536 !important;
}

/* Tables and borders */
.table thead th {
  color: #666666 !important;
  border-color: #EEEEEE !important;
}
.border-bottom,
hr {
  border-color: #EEEEEE !important;
}

/* Chart axes — light grey grid, grey labels */
.chart-canvas {
  --chart-grid: #EEEEEE;
  --chart-tick: #666666;
}

/* Prices card: cushion on edges, even spacing between number columns, responsive */
.prices-card .card-body {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}
.prices-table thead th,
.prices-table tbody td {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  white-space: nowrap;
}
.prices-table thead th:first-child,
.prices-table tbody td:first-child {
  padding-left: 0;
}
.prices-table thead th:last-child,
.prices-table tbody td:last-child {
  padding-right: 0;
}
.prices-table tbody td:nth-child(2),
.prices-table tbody td:nth-child(3),
.prices-table tbody td:nth-child(4),
.prices-table tbody td:nth-child(5),
.prices-table tbody td:nth-child(6) {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}
.prices-table thead th:nth-child(2),
.prices-table thead th:nth-child(3),
.prices-table thead th:nth-child(4),
.prices-table thead th:nth-child(5),
.prices-table thead th:nth-child(6) {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

.card .table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.price-chart-cell {
  min-width: 90px;
  width: 90px;
  vertical-align: middle !important;
  padding-right: 0.25rem !important;
}
.price-chart-wrap {
  height: 36px;
  width: 80px;
  min-width: 80px;
  margin-left: auto;
  display: block;
}
.price-chart-wrap canvas {
  display: block;
  width: 100% !important;
  height: 36px !important;
  max-height: 36px;
}
@media (max-width: 991px) {
  .price-chart-wrap {
    width: 70px;
    min-width: 70px;
  }
  .price-chart-cell {
    min-width: 80px;
    width: 80px;
  }
}
@media (max-width: 767px) {
  .card .table thead th,
  .card .table td {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    font-size: 0.75rem;
  }
  .card .table .text-sm {
    font-size: 0.75rem !important;
  }
  .price-chart-wrap {
    width: 60px;
    min-width: 60px;
    height: 32px;
  }
  .price-chart-wrap canvas {
    height: 32px !important;
    max-height: 32px;
  }
  .price-chart-cell {
    min-width: 70px;
    width: 70px;
  }
}
