/* ============================================================
   MACRO CALCULATOR — macro-calculator.css
   Responsive glassmorphism styles for custom nutrient targeting
   Toolspot by Tradesala
   ============================================================ */

.container {
  --tool-emerald: #10b981;
  --tool-emerald-soft: rgba(16, 185, 129, 0.12);
  --protein-color: #f97316; /* Orange */
  --carbs-color: #10b981;   /* Emerald */
  --fats-color: #3b82f6;    /* Blue */
}

.print-only-header {
  display: none;
}

/* ── Two-Column Layout Override ── */
.tool-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 1024px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
}

/* ── Hero KPI Cards Strip ── */
.macro-hero-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  text-align: center;
}

.hero-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  padding: 16px 14px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--tool-emerald);
  opacity: 0.8;
}

.hero-card.protein-card::before { background: var(--protein-color); }
.hero-card.carbs-card::before { background: var(--carbs-color); }
.hero-card.fats-card::before { background: var(--fats-color); }

.hero-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.hero-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.5px;
}

.hero-val {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.hero-sub {
  font-size: 11px;
  color: var(--text-2);
  margin: 0;
  display: block;
}

/* ── Interactive sliding toggles ── */
.mode-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 4px;
  border-radius: 12px;
  position: relative;
  isolation: isolate;
  margin-bottom: 20px;
}

.mode-toggle::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 8px);
  background: var(--tool-emerald);
  border-radius: 8px;
  z-index: -1;
  transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* unit toggles positions */
.mode-toggle.active-metric::before {
  left: 4px;
}
.mode-toggle.active-imperial::before {
  left: calc(50% + 4px);
}

/* diet presets sliding indicator overrides */
.mode-toggle.diet-tabs::before {
  width: calc(20% - 8px);
}
.mode-toggle.diet-tabs.active-balanced::before { left: 4px; }
.mode-toggle.diet-tabs.active-highprotein::before { left: calc(20% + 4px); }
.mode-toggle.diet-tabs.active-keto::before { left: calc(40% + 4px); }
.mode-toggle.diet-tabs.active-zone::before { left: calc(60% + 4px); }
.mode-toggle.diet-tabs.active-custom::before { left: calc(80% + 4px); }

/* sex toggle indicator position and color */
#sex-toggle.mode-toggle::before {
  width: calc(50% - 8px);
}
#sex-toggle.mode-toggle.active-male::before {
  left: 4px;
}
#sex-toggle.mode-toggle.active-female::before {
  left: calc(50% + 4px);
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
}
body.light #sex-toggle.mode-toggle.active-female::before {
  background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%) !important;
}

/* protein basis toggle indicator position */
#protein-basis-toggle.mode-toggle::before {
  width: calc(50% - 8px);
}
#protein-basis-toggle.mode-toggle.active-percentage::before {
  left: 4px;
}
#protein-basis-toggle.mode-toggle.active-weight::before {
  left: calc(50% + 4px);
}

/* meals split toggle indicator position (3 choices) */
#meals-split-toggle.mode-toggle::before {
  width: calc(33.333% - 8px);
}
#meals-split-toggle.mode-toggle.active-3meals::before {
  left: 4px;
}
#meals-split-toggle.mode-toggle.active-4meals::before {
  left: calc(33.333% + 4px);
}
#meals-split-toggle.mode-toggle.active-5meals::before {
  left: calc(66.666% + 4px);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.25s;
  text-align: center;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: transparent !important;
  box-shadow: none !important;
  color: #ffffff !important;
}

/* Override default range slider to use tool standard (emerald) instead of red/coral from sip-calculator.css */
.range-slider {
  background: linear-gradient(to right, var(--tool-emerald) 0%, var(--tool-emerald) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(255, 255, 255, 0.1) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(255, 255, 255, 0.1) 100%) !important;
}

.range-slider::-webkit-slider-thumb {
  border-color: var(--tool-emerald) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15), 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.range-slider::-moz-range-thumb {
  border-color: var(--tool-emerald) !important;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15) !important;
}

/* Light mode override for default range slider */
body.light .range-slider {
  background: linear-gradient(to right, var(--tool-emerald) 0%, var(--tool-emerald) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(0, 0, 0, 0.06) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(0, 0, 0, 0.06) 100%) !important;
}

#calories-val-box {
  width: 130px;
  height: 32px;
}

/* Make Daily Calorie Target Slider more prominent and premium */
#calories-slider.range-slider {
  height: 8px;
  background: linear-gradient(to right, var(--tool-emerald) 0%, var(--tool-emerald) calc(12px + var(--fill-pct, 0) * (100% - 24px)), 
    rgba(255, 255, 255, 0.1) calc(12px + var(--fill-pct, 0) * (100% - 24px)), rgba(255, 255, 255, 0.1) 100%) !important;
}

body.light #calories-slider.range-slider {
  background: linear-gradient(to right, var(--tool-emerald) 0%, var(--tool-emerald) calc(12px + var(--fill-pct, 0) * (100% - 24px)), 
    rgba(0, 0, 0, 0.06) calc(12px + var(--fill-pct, 0) * (100% - 24px)), rgba(0, 0, 0, 0.06) 100%) !important;
}

#calories-slider.range-slider::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  border-width: 4px;
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.18), 0 3px 10px rgba(0, 0, 0, 0.25) !important;
}

#calories-slider.range-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-width: 4px;
  box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.18) !important;
}

/* Hide number input spinners inside input boxes */
.input-header .inp-box input::-webkit-outer-spin-button,
.input-header .inp-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-header .inp-box input[type="number"] {
  -moz-appearance: textfield;
}

/* ── Inputs & Slider Elements ── */
.input-group {
  margin-bottom: 20px;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.input-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

/* Premium Slider Text Input Boxes */
.input-header .inp-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 2px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 110px;
  height: 30px;
  box-sizing: border-box;
  transition: all 0.2s;
}

.input-header .inp-box:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.input-header .inp-box:focus-within {
  border-color: var(--tool-emerald);
  box-shadow: 0 0 0 3px var(--tool-emerald-soft);
  background: rgba(255, 255, 255, 0.06);
}

.input-header .inp-box input {
  background: transparent;
  border: none;
  width: 100%;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-align: right;
  padding: 0;
  outline: none;
}

.input-header .inp-box .inp-suf {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  transition: color 0.2s;
}

.input-header .inp-box:focus-within .inp-suf {
  color: var(--tool-emerald);
}

/* ── Custom Sliders Color Coding ── */
.range-slider.protein-slider::-webkit-slider-thumb { border-color: var(--protein-color) !important; }
.range-slider.protein-slider {
  background: linear-gradient(to right, var(--protein-color) 0%, var(--protein-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(255, 255, 255, 0.1) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(255, 255, 255, 0.1) 100%) !important;
}
.range-slider.carbs-slider::-webkit-slider-thumb { border-color: var(--carbs-color) !important; }
.range-slider.carbs-slider {
  background: linear-gradient(to right, var(--carbs-color) 0%, var(--carbs-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(255, 255, 255, 0.1) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(255, 255, 255, 0.1) 100%) !important;
}
.range-slider.fats-slider::-webkit-slider-thumb { border-color: var(--fats-color) !important; }
.range-slider.fats-slider {
  background: linear-gradient(to right, var(--fats-color) 0%, var(--fats-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(255, 255, 255, 0.1) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(255, 255, 255, 0.1) 100%) !important;
}

/* ── SVG Donut and Legend ── */
.macro-donut-container {
  position: relative;
}



.macro-legend-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.macro-legend-item {
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.2s ease;
}

.macro-legend-item:hover {
  transform: translateX(4px);
}

.macro-legend-item span[id$="-pct"] {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}

/* ── Meal Splits Grid ── */
.meal-splits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.meal-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meal-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--tool-emerald);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.meal-kcal {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
}

.meal-macros {
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meal-macros div span {
  font-weight: bold;
}

/* ── Table formatting for Food Sources and Log ── */
.table-wrap {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  margin-top: 12px;
}

/* ── Scrollable Food Table & Sticky Header ── */
.food-table-wrap {
  max-height: 380px;
  overflow-y: auto;
  position: relative;
}

.food-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(18, 17, 24, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.light .food-table-wrap thead th {
  background: rgba(255, 255, 255, 0.95);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

/* Custom Scrollbar for Food Table Wrap */
.food-table-wrap::-webkit-scrollbar {
  width: 6px;
}
.food-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.food-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.food-table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(249, 115, 22, 0.4);
}

body.light .food-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}
body.light .food-table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(249, 115, 22, 0.5);
}

.food-table, .history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.food-table th, .history-table th {
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.food-table td, .history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-2);
}

.food-table tbody tr:hover td, .history-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.015);
  color: var(--text);
}

.food-table tbody tr:last-child td, .history-table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Session Log table items ── */
.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.history-average-card {
  font-size: 12px;
  color: var(--text-2);
}

.history-average-card b {
  color: var(--tool-emerald);
}

.history-actions {
  display: flex;
  gap: 8px;
}

.delete-entry-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.delete-entry-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ── Light Mode Overrides ── */
body.light .hero-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light .hero-card:hover {
  background: rgba(0, 0, 0, 0.035);
  border-color: rgba(0, 0, 0, 0.1);
}

body.light .mode-toggle {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light .mode-btn {
  color: var(--text-2);
}

body.light .input-header .inp-box {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light .input-header .inp-box:hover {
  border-color: rgba(0, 0, 0, 0.15);
  background: rgba(0, 0, 0, 0.04);
}

body.light .input-header .inp-box:focus-within {
  background: #ffffff;
}

body.light .meal-card {
  background: rgba(0, 0, 0, 0.015);
  border-color: rgba(0, 0, 0, 0.05);
}

body.light .table-wrap {
  background: rgba(0, 0, 0, 0.01);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light .food-table th, body.light .history-table th {
  background: rgba(0, 0, 0, 0.03);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light .food-table td, body.light .history-table td {
  border-bottom-color: rgba(0, 0, 0, 0.04);
}

body.light .food-table tbody tr:hover td, body.light .history-table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

/* Light Mode Range Slider custom overrides */
body.light .range-slider.protein-slider {
  background: linear-gradient(to right, var(--protein-color) 0%, var(--protein-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(0, 0, 0, 0.06) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(0, 0, 0, 0.06) 100%) !important;
}
body.light .range-slider.carbs-slider {
  background: linear-gradient(to right, var(--carbs-color) 0%, var(--carbs-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(0, 0, 0, 0.06) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(0, 0, 0, 0.06) 100%) !important;
}
body.light .range-slider.fats-slider {
  background: linear-gradient(to right, var(--fats-color) 0%, var(--fats-color) calc(11px + var(--fill-pct, 0) * (100% - 22px)), 
    rgba(0, 0, 0, 0.06) calc(11px + var(--fill-pct, 0) * (100% - 22px)), rgba(0, 0, 0, 0.06) 100%) !important;
}

/* ── PRINTING LAYOUTS (PDF EXPORTS) ── */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  
  .bg-scene, 
  nav, 
  footer, 
  #ts-header,
  #ts-footer,
  #ts-cookie,
  #ts-share,
  #ts-toast,
  .cookie-banner, 
  .share-pill, 
  #toast-container, 
  .tool-left, 
  .history-actions, 
  .delete-entry-btn,
  .action-column,
  #tool-faq,
  .explanatory-content,
  .breadcrumb,
  .tool-header,
  #add-log-btn,
  .history-log-panel .panel-title,
  .history-table th:last-child,
  .history-table td:last-child,
  #tool-disclaimer {
    display: none !important;
  }
  
  .print-only-header {
    display: block !important;
    margin-bottom: 10px;
    width: 100% !important;
  }
  
  .print-brand {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 6px;
    border-bottom: 1.5px solid #000000;
    padding-bottom: 4px;
    width: 100% !important;
  }
  
  .print-logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: #000000 !important;
  }
  
  .print-logo-text span {
    color: var(--tool-emerald) !important;
  }
  
  .print-report-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    color: #555555 !important;
    letter-spacing: 0.5px;
  }
  
  .print-title {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: #000000 !important;
    margin: 4px 0 6px;
    letter-spacing: -0.5px;
  }
  
  .print-meta-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px 12px !important;
    font-size: 9.5px !important;
    color: #222222 !important;
    background: #f8f9fa !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    border: 1px solid #dee2e6 !important;
    margin-bottom: 12px !important;
  }
  
  .print-meta-grid div strong {
    color: #444444 !important;
  }
  
  .print-divider {
    height: 1px;
    background: #dee2e6;
    margin: 12px 0;
  }

  .page-border {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .tool-layout {
    display: block !important;
  }

  .panel {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 16px !important;
    box-shadow: none !important;
  }

  /* Metric KPI Cards in Print */
  .macro-hero-strip {
    gap: 10px !important;
    margin-bottom: 12px !important;
  }

  .hero-card {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-top: 3px solid #ccc !important;
    border-radius: 8px !important;
    padding: 8px !important;
    box-shadow: none !important;
  }

  .hero-card::before {
    display: none !important;
  }

  .hero-card.protein-card { border-top-color: var(--protein-color) !important; }
  .hero-card.carbs-card { border-top-color: var(--carbs-color) !important; }
  .hero-card.fats-card { border-top-color: var(--fats-color) !important; }

  .hero-val {
    font-size: 18px !important;
    color: #000000 !important;
  }

  .hero-label {
    font-size: 8px !important;
    color: #444444 !important;
  }

  .hero-sub {
    font-size: 8px !important;
    color: #555555 !important;
  }

  /* Donut display in print */
  .macro-donut-container {
    min-width: 80px !important;
  }

  .macro-donut {
    width: 80px !important;
    height: 80px !important;
  }

  .macro-legend-item {
    font-size: 11px !important;
    line-height: 1.3 !important;
  }

  /* Meal splits in print */
  .meal-splits-grid {
    gap: 8px !important;
  }

  .meal-card {
    background: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    padding: 8px !important;
    border-radius: 6px !important;
  }

  .meal-kcal {
    font-size: 12px !important;
    color: #000000 !important;
  }

  .meal-macros {
    font-size: 9.5px !important;
  }

  /* Food table in print */
  .table-wrap {
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    background: #ffffff !important;
  }

  .food-table th {
    background: #f1f3f5 !important;
    color: #000000 !important;
    border-bottom: 2px solid #dee2e6 !important;
    padding: 6px 10px !important;
    font-size: 8.5px !important;
  }

  .food-table td {
    color: #222222 !important;
    border-bottom: 1px solid #dee2e6 !important;
    padding: 6px 10px !important;
    font-size: 10px !important;
  }

  /* History Table print formatting */
  .history-log-panel {
    margin-top: 24px !important;
    page-break-before: always !important;
    break-before: page !important;
  }
  
  .history-average-card {
    color: #000000 !important;
    font-weight: 600 !important;
  }

  .history-average-card b {
    color: #000000 !important;
    font-weight: 800 !important;
  }

  .history-table th {
    background: #f1f3f5 !important;
    color: #000000 !important;
    border-bottom: 2px solid #dee2e6 !important;
    padding: 8px 12px !important;
  }

  .history-table td {
    color: #222222 !important;
    border-bottom: 1px solid #dee2e6 !important;
    padding: 8px 12px !important;
  }

  .history-table td strong {
    color: #000000 !important;
  }
}
