/* =========================================================
   KETO TASTE KITCHEN — PREMIUM MACRO CALCULATOR CSS
   ========================================================= */

#ktk-calculator-container .print-logo {
  display: none;
}
      
#ktk-calculator-container {
  max-width: 760px;
  margin: 0 auto;
  font-family: system-ui, sans-serif;
  color: #333;
  overflow-x: hidden !important;
  position: relative;
}

/* Prevent overflow only inside content fields — not structural containers */
#ktk-calculator-container .field *,
#ktk-calculator-container .toggle-row *,
#ktk-calculator-container .form-row *,
#ktk-calculator-container .ktk-card *,
#ktk-calculator-container .macro-layout * {
  box-sizing: border-box;
  max-width: 100%;
}

/* Fix: Ensure hidden fields actually stay hidden */
#ktk-calculator-container .hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}
  
/* Standardize gap between fields to match toggle-row spacing */
#ktk-calculator-container .grid-2,
#ktk-calculator-container .grid-3 {
  gap: 10px !important;
}

/* =========================================================
   BASE STRUCTURE (DESKTOP FIRST)
   ========================================================= */

.ktk-page-title {
  /* text-align: center;
  font-size: 30px;
  margin-bottom: 28px;*/
  display: none;
}

.kbk-card,
.ktk-card {
  background: #fff;
  padding: 40px;
  border-radius: 14px;
  margin-bottom: 36px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.form-label {
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
}

.field input,
.field select,
select {
  padding: 14px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 16px;
}
  
/* Dropdown Arrow Styling */  
#ktk-calculator-container select {
  padding-right: 34px !important; /* pulls arrow in */
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: url("data:image/svg+xml;utf8,<svg fill='black' xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'><path d='M7 10l5 5 5-5z'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 14px !important;
}

.form-row {
  margin-bottom: 26px;
}

/* Buttons */
.btn-primary,
.btn-print {
  width: 100%;
  padding: 18px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  margin-top: 18px;
  color: #fff;
}
  
.btn-primary { 
  background: #ab3727; 
}

/* Hide Print Button before results generated */
.btn-print { 
  background: #3b3202; 
  display: none;
}

/* Toggle buttons */
.toggle-row {
  display: flex;
  gap: 10px;
  min-width: 0 !important;
  flex-wrap: wrap !important;
}
  
.toggle-btn {
  padding: 10px 16px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
  
.toggle-btn.active {
  background: #ab3727;
  border-color: #ab3727;
  color: #fff;
}

/* Info icons */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 50%;
  color: #333;
  margin-left: 6px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: background .25s, transform .2s, box-shadow .2s;
}
  
.info-icon:hover { 
  background: #e5e5ea; 
}
  
.info-icon:active { 
  transform: scale(.84); 
}

/* Accordion text */
.help-text {
  background: #fafafa;
  border-left: 3px solid transparent;
  padding: 0 14px;
  margin-top: 8px;
  margin-bottom: 0;
  border-radius: 6px;
  font-size: 14px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .3s ease, opacity .3s ease, padding .3s, border-color .3s;
}
  
.help-text.open {
  max-height: 300px;
  opacity: 1;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-color: #d8d8d8;
}
  
/* Highlight any missing input fields */
.field.missing input,
.field.missing select {
  border-color: #d9534f !important;
  background: #ffecec !important;
}

/* Friendly error box */
.ktk-error {
  color: #b00000;
  background: #ffecec;
  padding: 12px 16px;
  border: 1px solid #ffb5b5;
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 15px;
}

/* RESULTS */
.macro-layout,
.macro-left {
  width: 100% !important;
  display: block !important;
}

/* Center pie inside its new card */
.macro-right {
  display: flex;
  justify-content: center;
  align-items: center;
}

.macro-right canvas {
  width: 100% !important;
  height: auto !important;
  max-width: 260px !important;   /* full size on desktop */
  aspect-ratio: 1 / 1 !important; /* stays perfectly round */
}



/* Grid defaults */
.grid-2 { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 28px; 
  min-width: 0 !important;
}
  
.grid-3 { 
  display: grid; 
  grid-template-columns: repeat(3,1fr); 
  gap: 28px; 
  min-width: 0 !important;
}

/* Results summary */
#result-summary {
  text-align: center;
  font-size: 18px;
  line-height: 1.45;
  margin-bottom: 24px;
  font-weight: 400;
  
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal !important;
}
  
#result-summary .rs-label {
  font-weight: 700;
  font-size: 15px;
  opacity: .9;
}
  
/* Prevent category phrases from breaking mid-word */
.rs-chunk {
  white-space: normal !important;
} 
  
  
/* =========================================================
   LEGAL DISCLAIMER
   ========================================================= */
#ktk-results .ktk-legal-card {
  background: #fafafa !important;
  /*border-left: 3px solid #d5d5d5 !important;*/
  padding: 12px 16px !important;
  margin-top: 16px !important;
  border-radius: 6px !important;
}

#ktk-results .legal-title {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #444 !important;
  margin: 0 0 4px 0 !important;
}

#ktk-results .legal-text {
  font-size: 12.5px !important;
  color: #555 !important;
  line-height: 1.35 !important;
  margin: 0 !important;
  font-style: italic !important;
}



/* =========================================================
   RESPONSIVE BEHAVIOR - Mobile First
   ========================================================= */
/* =========================================================
   MEDIUM SCREENS (480–767px)
   ========================================================= */
  
@media (max-width: 767px) {

  /* Cards */
  #ktk-calculator-container .ktk-card {
    padding: 28px 20px !important;
  }

  .form-label { font-size: 15px; }

  .field input,
  .field select {
    padding: 13px;
    font-size: 15px;
  }

  /* GRID BEHAVIOR */
  /* Metric:  weight full width, height full width */
  #metric-fields .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Imperial: weight full width, height ft+in side by side */
  #imperial-fields .grid-3 {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }

  #imperial-fields .grid-3 .field:first-child {
    grid-column: 1 / -1;   /* weight spans full width */
  }

  .macro-layout {
    display: flex;
    flex-direction: column !important;   /* ← STACK */
    align-items: center !important;        /* Center everything */
    gap: 20px !important;
    width: 100% !important;
  }


  .macro-right {
    display: flex;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    margin: 0 auto !important;
  }
}
 /* Tablet Pie chart */
 @media (max-width: 767px) {
  .macro-left,
  .macro-right {
    width: 100% !important;
    max-width: 100% !important;
  }
   .macro-right canvas {
    max-width: 200px !important;
  }
}


/* =========================================================
   SMALL PHONES (≤ 480px)
   ========================================================= */
@media (max-width: 480px) {

  /* Card padding */
  .ktk-card {
    padding: 18px 16px !important;
  }

  /* Inputs */
  .field input,
  .field select {
    padding: 12px !important;
    font-size: 15px !important;
  }

  /* Typography */
  p, li {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .card-title { 
    font-size: 18px !important; 
  }
  
  .card-subtitle { 
    font-size: 16px !important; 
  }

  /* GRID FULL STACK */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
}

  /* Mobile Pie chart */
@media (max-width: 480px) {
  .macro-right canvas {
    max-width: 180px !important;
  }
}



/* =========================================================
   PRINT
   ========================================================= */
@media print {

  /* Title */
  .ktk-page-title {
    display: block;
    text-align: center;
    font-size: 24px !important;
    margin-bottom: 20px !important;
  }
  
  #ktk-calculator-container .print-logo {
  display: block;
    margin: 0 auto;
    width: 200px;
  }
  
  #ktk-print-header { 
    display: block !important; 
  }
  
  .ktk-form,
  .btn-primary,
  .btn-print { 
    display: none !important; 
  }

  .ktk-card {
    box-shadow: none !important;
    padding: 14px 16px !important;
    margin-bottom: 14px !important;
  }

  .macro-right canvas {
    width: 180px !important;
    height: 180px !important;
  }

  @page { 
    margin: 8mm; 
  }
  
  
  /* ============================
     PIE CHART for Print
     ============================ */
  /* PRINT — Fix pie chart sizing & centering */
  #ktk-results .macro-right {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  #ktk-results .macro-right canvas {
    width: 200px !important;     /* consistent size */
    height: 200px !important;
    max-width: none !important;
    margin: 0 auto !important;
    display: block !important;
  }
  
  /* ============================
     End PIE CHART on Print
     ============================ */
  
  
  
  /* =========================================================
     PRINT COMPRESSION — FIT EVERYTHING ON ONE PAGE
     ========================================================= */

  /* Reduce default page margins for print */
  @page {
    margin: 0.35in !important;
  }

  /* Reduce spacing between sections */
  #ktk-results .ktk-card {
    padding: 12px 16px !important;
    margin-bottom: 12px !important;
  }

  /* Tighten grid rows */
  #ktk-results .ktk-row {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }

  /* Macro layout spacing */
  #ktk-results .macro-layout {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }

  /* Reduce spacing inside macro text */
  #ktk-results .macro-left p {
    margin: 2px 0 !important;
    line-height: 1.25 !important;
  }

  /* Titles */
  #ktk-results h3,
  #ktk-results h4 {
    margin: 6px 0 4px 0 !important;
    line-height: 1.2 !important;
  }

  #ktk-results h2.result-summary {
    margin-bottom: 12px !important;
  }

  /* Lists */
  #ktk-results ul li {
    margin-bottom: 4px !important;
    line-height: 1.25 !important;
  }

  /* Water + Electrolytes top spacing */
  #ktk-results .ktk-card p,
  #ktk-results .ktk-card ul {
    margin-top: 4px !important;
  }

  /* Legal block tightened */
  #ktk-results .ktk-legal-card {
    padding: 10px 14px !important;
    margin-top: 10px !important;
  }

  #ktk-results .legal-text {
    line-height: 1.25 !important;
    font-size: 13px !important;
    margin-top: 4px !important;
  }

  /* Reduce pie chart size slightly */
  #ktk-results .macro-right canvas {
    max-width: 200px !important;
    height: auto !important;
  }
}