/* profit-margin.css */
#trayonomics-profit-margin-calculator {
  /* WordPress Parent Grid Isolation */
  grid-column: 1 / -1 !important;
  width: 100% !important;
  max-width: 1200px;
  margin: 0 auto;
  display: block;
  box-sizing: border-box;
  clear: both;

  /* Design Tokens */
  --tpm-forest: #12372A;
  --tpm-leaf: #3FA66B;
  --tpm-gold: #E5A93D;
  --tpm-ink: #17201B;
  --tpm-canvas: #F7F8F3;
  --tpm-white: #FFFFFF;
  --tpm-muted: #5F6B64;
  --tpm-border: #DCE5DF;
  --tpm-error: #B3261E;
  --tpm-error-bg: #F9DEDC;
  --tpm-warning: #855C0B;
  --tpm-warning-bg: #FDF3C7;
  --tpm-radius: 16px;
  --tpm-transition: all 0.2s ease;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--tpm-ink);
  background-color: var(--tpm-canvas);
  padding: 2rem;
  border-radius: var(--tpm-radius);
  line-height: 1.5;
}

#trayonomics-profit-margin-calculator *,
#trayonomics-profit-margin-calculator *::before,
#trayonomics-profit-margin-calculator *::after {
  box-sizing: inherit;
}

/* Header */
.tpm-header {
  margin-bottom: 2.5rem;
}

.tpm-eyebrow {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--tpm-leaf);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.5rem 0;
}

.tpm-main-heading {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--tpm-forest);
  margin: 0 0 1rem 0;
  line-height: 1.2;
}

.tpm-description {
  color: var(--tpm-muted);
  font-size: 1.125rem;
  max-width: 800px;
  margin: 0;
}

/* Layout Grid */
.tpm-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 52%) minmax(0, 48%);
  gap: 32px;
  align-items: start;
}

/* Cards */
.tpm-card {
  background: var(--tpm-white);
  border: 1px solid var(--tpm-border);
  border-radius: var(--tpm-radius);
  padding: 2rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

/* Typography Inside Calculator */
.tpm-h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tpm-forest);
  margin: 0 0 0.25rem 0;
}

.tpm-h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--tpm-forest);
  margin: 0 0 1rem 0;
}

.tpm-section-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--tpm-border);
  padding-bottom: 1rem;
}

.tpm-subtext {
  color: var(--tpm-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Form Inputs */
.tpm-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.tpm-form-group {
  display: flex;
  flex-direction: column;
}

.tpm-full-width {
  margin-bottom: 1.5rem;
}

.tpm-label {
  font-weight: 600;
  color: var(--tpm-forest);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.tpm-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.tpm-prefix {
  position: absolute;
  left: 1rem;
  color: var(--tpm-muted);
  font-weight: 500;
  pointer-events: none;
}

.tpm-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--tpm-border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--tpm-ink);
  background-color: var(--tpm-white);
  transition: var(--tpm-transition);
  font-family: inherit;
  margin: 0;
  -moz-appearance: textfield;
}

.tpm-input::-webkit-outer-spin-button,
.tpm-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.tpm-has-prefix {
  padding-left: 2.25rem;
}

.tpm-input:focus {
  outline: none;
  border-color: var(--tpm-leaf);
  box-shadow: 0 0 0 3px rgba(63, 166, 107, 0.15);
}

.tpm-select {
  cursor: pointer;
}

.tpm-help-text {
  font-size: 0.85rem;
  color: var(--tpm-muted);
  margin: 0.5rem 0 0 0;
}

.tpm-related-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--tpm-leaf);
  text-decoration: none;
  transition: var(--tpm-transition);
}

.tpm-related-link:hover {
  text-decoration: underline;
  color: var(--tpm-forest);
}

/* Buttons */
.tpm-buttons-row {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--tpm-border);
}

.tpm-btn {
  /* Strict Centering Rules */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: normal;
  font-family: inherit;
  margin: 0;
  padding: 0 1.5rem;
  min-height: 48px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--tpm-transition);
  text-align: center;
  border: none;
}

.tpm-btn-primary {
  background-color: var(--tpm-leaf);
  color: var(--tpm-white);
  flex: 2;
}

.tpm-btn-primary:hover, .tpm-btn-primary:focus {
  background-color: #338C59;
}

.tpm-btn-secondary {
  background-color: var(--tpm-canvas);
  color: var(--tpm-ink);
  border: 1px solid var(--tpm-border);
  flex: 1;
}

.tpm-btn-secondary:hover, .tpm-btn-secondary:focus {
  background-color: #EAECE6;
}

/* Results Section */
.tpm-status-message {
  display: none;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.tpm-status-error {
  background-color: var(--tpm-error-bg);
  color: var(--tpm-error);
  border-left: 4px solid var(--tpm-error);
  display: block;
}

.tpm-status-warning {
  background-color: var(--tpm-warning-bg);
  color: var(--tpm-warning);
  border-left: 4px solid var(--tpm-warning);
  display: block;
}

.tpm-primary-result {
  background-color: var(--tpm-forest);
  color: var(--tpm-white);
  padding: 2.5rem 1.5rem;
  border-radius: var(--tpm-radius);
  text-align: center;
  margin: 1.5rem 0;
}

.tpm-result-label {
  display: block;
  font-size: 1.125rem;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 0.5rem;
}

.tpm-result-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--tpm-leaf);
  line-height: 1.1;
  word-break: break-word;
}

.tpm-result-value.tpm-loss-value {
  color: #F87171;
}

.tpm-supporting-rows {
  margin-bottom: 2rem;
  background-color: var(--tpm-canvas);
  border: 1px solid var(--tpm-border);
  border-radius: 8px;
  padding: 0.5rem 1.5rem;
}

.tpm-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--tpm-border);
}

.tpm-result-row:last-child {
  border-bottom: none;
}

.tpm-row-label {
  color: var(--tpm-muted);
  font-weight: 500;
}

.tpm-row-value {
  font-weight: 700;
  color: var(--tpm-ink);
  font-size: 1.125rem;
}

.tpm-highlight-row .tpm-row-value {
  color: var(--tpm-forest);
  font-size: 1.25rem;
}

/* Breakdown Section */
.tpm-breakdown-section {
  margin-bottom: 2rem;
}

.tpm-breakdown-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.tpm-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.tpm-dot-cost { background-color: var(--tpm-muted); }
.tpm-dot-profit { background-color: var(--tpm-leaf); }

.tpm-breakdown-bar-container {
  height: 12px;
  background-color: var(--tpm-canvas);
  border-radius: 6px;
  display: flex;
  overflow: hidden;
}

.tpm-bar-segment {
  height: 100%;
  transition: width 0.4s ease;
}

.tpm-bg-cost { background-color: var(--tpm-muted); }
.tpm-bg-profit { background-color: var(--tpm-leaf); }

/* Utility Buttons */
.tpm-utility-buttons {
  display: flex;
  gap: 1rem;
}

.tpm-btn-utility {
  flex: 1;
  background-color: transparent;
  color: var(--tpm-leaf);
  border: 1px solid var(--tpm-leaf);
  font-size: 0.95rem;
}

.tpm-btn-utility:hover, .tpm-btn-utility:focus {
  background-color: var(--tpm-leaf);
  color: var(--tpm-white);
}

/* SEO Content */
.tpm-seo-content {
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--tpm-border);
}

.tpm-seo-content h2 {
  font-size: 1.75rem;
  color: var(--tpm-forest);
  margin: 0 0 1.5rem 0;
}

.tpm-seo-content h3 {
  font-size: 1.25rem;
  color: var(--tpm-forest);
  margin: 2rem 0 0.75rem 0;
}

.tpm-seo-content p {
  color: var(--tpm-muted);
  margin: 0 0 1.25rem 0;
}

/* Responsive Rules */
@media (max-width: 900px) {
  .tpm-layout-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 600px) {
  #trayonomics-profit-margin-calculator {
    padding: 1.25rem;
  }
  
  .tpm-card {
    padding: 1.5rem;
  }

  .tpm-input-row {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .tpm-buttons-row, .tpm-utility-buttons {
    flex-direction: column;
  }
  
  .tpm-main-heading {
    font-size: 1.75rem;
  }

  .tpm-result-value {
    font-size: clamp(2.5rem, 8vw, 3.5rem);
  }
}

/* Print Styles */
@media print {
  body * {
    visibility: hidden;
  }
  
  #trayonomics-profit-margin-calculator,
  #trayonomics-profit-margin-calculator * {
    visibility: visible;
  }
  
  #trayonomics-profit-margin-calculator {
    position: absolute;
    left: 0;
    top: 0;
    width: 100% !important;
    padding: 0;
    background: white;
  }
  
  .tpm-buttons-row, 
  .tpm-utility-buttons, 
  .tpm-seo-content,
  .tpm-related-link,
  .tpm-help-text {
    display: none !important;
  }
  
  .tpm-layout-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .tpm-card {
    box-shadow: none;
    border: 1px solid #ccc;
    padding: 1.5rem;
    break-inside: avoid;
  }
  
  .tpm-primary-result {
    background-color: #f7f7f7 !important;
    color: black !important;
    border: 1px solid #ccc;
  }
  
  .tpm-result-value {
    color: black !important;
  }
  
  .tpm-supporting-rows {
    background: transparent;
  }
}
/* =========================================================
   Trayonomics Profit Margin — FINAL LAYOUT OVERRIDE
   Based on the proven Cost Per Tray grid strategy.
   ========================================================= */

/* 1. Escape the WordPress outer content-grid placement */
#trayonomics-profit-margin-calculator {
  grid-column: 1 / -1 !important;
  justify-self: stretch !important;
  align-self: start !important;
  width: 100% !important;
  max-width: 1180px !important;
  min-width: 0 !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* 2. Desktop: Inputs LEFT / Results RIGHT */
@media (min-width: 900px) {
  #trayonomics-profit-margin-calculator .tpm-layout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 52%) minmax(0, 48%) !important;
    gap: 32px !important;
    align-items: start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  #trayonomics-profit-margin-calculator .tpm-inputs-section,
  #trayonomics-profit-margin-calculator .tpm-results-section {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}

/* 3. Tablet/mobile: Inputs ABOVE Results */
@media (max-width: 899.98px) {
  #trayonomics-profit-margin-calculator .tpm-layout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 30px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* 4. Button alignment — perfectly centered */
#trayonomics-profit-margin-calculator .tpm-button,
#trayonomics-profit-margin-calculator button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  vertical-align: middle !important;
  box-sizing: border-box !important;
  font-family: inherit !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

/* Primary + Reset buttons */
#trayonomics-profit-margin-calculator .tpm-form-actions {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

#trayonomics-profit-margin-calculator #tpm-calculate,
#trayonomics-profit-margin-calculator #tpm-reset {
  min-height: 44px !important;
}

/* 5. Mobile buttons */
@media (max-width: 600px) {
  #trayonomics-profit-margin-calculator .tpm-form-actions {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  #trayonomics-profit-margin-calculator #tpm-calculate,
  #trayonomics-profit-margin-calculator #tpm-reset {
    width: 100% !important;
    min-height: 46px !important;
  }
}
/* =========================================================
   PROFIT MARGIN — FORCE INPUT/RESULT COLUMN PLACEMENT
   ========================================================= */

@media (min-width: 900px) {

  #trayonomics-profit-margin-calculator .tpm-layout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 52%) minmax(0, 48%) !important;
    gap: 32px !important;
    align-items: start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Inputs MUST be column 1 */
  #trayonomics-profit-margin-calculator .tpm-layout-grid > .tpm-inputs-section {
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Results MUST be column 2 */
  #trayonomics-profit-margin-calculator .tpm-layout-grid > .tpm-results-section {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Tablet/mobile: stack them */
@media (max-width: 899.98px) {

  #trayonomics-profit-margin-calculator .tpm-layout-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 30px !important;
  }

  #trayonomics-profit-margin-calculator .tpm-layout-grid > .tpm-inputs-section,
  #trayonomics-profit-margin-calculator .tpm-layout-grid > .tpm-results-section {
    grid-column: 1 !important;
    grid-row: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
}
/* Hide the duplicate WordPress page title */
body.page-id-66 .wp-block-post-title {
  display: none !important;
}
/* Override WordPress Theme Global Spacing */
#trayonomics-profit-margin-calculator .tpm-form-group {
  gap: 0 !important;
  justify-content: flex-start !important;
}

#trayonomics-profit-margin-calculator .tpm-label {
  margin: 0 0 0.5rem 0 !important;
  padding: 0 !important;
  line-height: 1.2 !important;
}

#trayonomics-profit-margin-calculator .tpm-input,
#trayonomics-profit-margin-calculator .tpm-select {
  margin: 0 !important;
}

#trayonomics-profit-margin-calculator .tpm-help-text,
#trayonomics-profit-margin-calculator .tpm-related-link {
  margin: 0.5rem 0 0 0 !important;
  line-height: 1.4 !important;
}

#trayonomics-profit-margin-calculator .tpm-input-wrapper {
  margin: 0 !important;
}

#trayonomics-profit-margin-calculator .tpm-form-group p {
  margin-bottom: 0 !important;
}