/* ===== Label Price Calculator (frontend) ===== */

/* Make the whole block use full available width */
.lpc-wrap {
  width: 100%;
  max-width: none !important; /* override any theme caps */
  margin: 20px auto;
  
}

/* 3-column grid; stacks on small screens */
.lpc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) {
  .lpc-grid { grid-template-columns: 1fr; }
}

/* Card/panel */
.lpc-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 14px;
}

/* Form layout: labels above inputs so inputs can be 100% width */
.lpc-form .lpc-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 10px 0;
}
.lpc-form label {
  font-weight: 600;
}

/* Force inputs to full width (override WooCommerce max-width rules) */
.lpc-wrap .lpc-form input,
.lpc-wrap .lpc-form select,
.lpc-wrap .lpc-form input[type=number] {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
  min-height: 36px; /* matches Woo default height */
}

/* If WooCommerce sets a small max-width on number inputs, beat it here */
.woocommerce-js .lpc-wrap .lpc-form input[type=number] {
  width: 100% !important;
  max-width: none !important;
}

/* Width & Height on the SAME ROW always */
.lpc-row.lpc-dims {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
/* NEW: force-hide a row even if other rules use !important */
.lpc-hide { display: none !important; }

.lpc-row.lpc-dims .lpc-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

/* Icon buttons (shape + winding) */
.lpc-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lpc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #f9f9f9;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.lpc-btn:hover {
  background: #f2f6ff;
  border-color: #b6cef3;
}
.lpc-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.lpc-btn.active {
  border-color: #1e73be;
  background: #e8f3ff;
  box-shadow: 0 0 0 2px rgba(30, 115, 190, 0.12) inset;
}

/* Price column */
.lpc-price {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lpc-price .big { font-size: 28px; font-weight: 800; }
.lpc-muted { opacity: .8; }

/* Quantity ladder */
.lpc-ladder {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.lpc-ladder th,
.lpc-ladder td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: left;
}
.lpc-ladder th { background: #fafafa; }
.lpc-ladder tr:hover {
  background: #f7fbff;
  cursor: pointer;
}

/* Debug details + error */
details.lpc-details summary {
  cursor: pointer;
  margin-top: 8px;
  font-weight: 600;
}
.lpc-error {
  background: #fbeaea;
  border: 1px solid #e0b4b4;
  color: #7a1f1f;
  padding: 10px;
  margin-top: 10px;
}
table {
    border-collapse: separate;
    border-spacing: 0;
    border-width: 1px 0 0 1px;
    margin: 0 0 0;
    width: 100%;
}

/* Legacy table helper (for breakdown) */
.lpc-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.lpc-table th,
.lpc-table td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: left;
}
.lpc-table th { background: #fafafa; width: 55%; }
.lpc-btn img { width: 100px; height: 100px; }
/* highlight missing required selects */
.lpc-missing {
  outline: 2px solid #c62828 !important;
  outline-offset: 2px;
  background: #fff6f6;
}
/* ===== Column 3 (Price) polished look ===== */
.lpc-col3 .lpc-title-wrap {
  text-align: center;
  padding: 8px 8px 2px;
}
.lpc-col3 .lpc-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 800;
}
.lpc-col3 .lpc-subtitle {
  margin: 6px auto 8px;
  max-width: 620px;
  opacity: 0.85;
  font-size: 16px;
  line-height: 1.5;
}

/* Generic padded sections inside the panel */
.lpc-section {
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
}

/* Section title (optional) */
.lpc-section-title {
  margin: 0 0 8px;
  font-size: 20px !important;
  font-weight: 700;
  opacity: 0.9;
}

/* Quantity ladder table now has nice padding via .lpc-section */
.lpc-col3 .lpc-section .lpc-ladder {
  margin-top: 0; /* no extra gap—section already padded */
}

.lpc-price-summary .lpc-unit,
.lpc-price-summary .lpc-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px dashed #e3e3e3;
  border-radius: 8px;
  background: #fafcff;
}
.lpc-price-summary .lpc-unit span,
.lpc-price-summary .lpc-total span {
  font-weight: 600;
  opacity: 0.9;
}
.lpc-price-summary .lpc-unit strong {
  font-size: 20px;
  font-weight: 800;
}
.lpc-price-summary .lpc-total strong {
  font-size: 24px;
  font-weight: 900;
}

/* Keep error after numbers with a bit of spacing */
.lpc-col3 .lpc-error {
  margin-top: 12px;
}
/* Highlight the currently selected (1×) quantity row */
.lpc-ladder tr.selected {
  background: #e8f3ff;
  font-weight: 600;
}
/* Subtle inline hint below the Designs input */
.lpc-hint--subtle{
  margin-top: 2px;       /* tighter gap */
  font-size: 12px;       /* smaller text */
  color: #6b7280;        /* grey */
  line-height: 1.3;
}
/* VAT row integrated into summary */
.lpc-price-summary .lpc-vat-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0,0,0,0.12);
  font-size: 13px;
  opacity: 0.9;
}
.lpc-price-summary .lpc-vat-line strong {
  font-size: 14px;
  font-weight: 700;
}

/* Simple enquiry button placement */
.lpc-price-summary .lpc-enquiry-row {
  margin-top: 12px;
}
.lpc-enquiry-btn { cursor: pointer; }
/* ============ Enquiry popup over column 3 ============ */
.lpc-col3 { position: relative; }

/* Overlay inside the 3rd column only */
.lpc-modal {
  position: absolute;
  inset: 0;
  display: none;               /* toggled by JS */
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.45); /* subtle dark overlay */
  z-index: 30;
  padding: 12px;
  border-radius: 5px;
}

/* When aria-hidden="false", show the modal as flex */
.lpc-modal[aria-hidden="false"] { display: flex; }

.lpc-modal__card {
  width: 100%;
  max-width: 420px;            /* small popup */
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  border: 1px solid #e5e7eb;
  padding: 16px;
}

.lpc-modal__row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.lpc-modal__row label { font-weight: 600; }
.lpc-modal__row input[type="text"],
.lpc-modal__row input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
}

/* Action buttons inside the card */
.lpc-modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Reuse the same overlay area for loading state, scoped to col3 */
.lpc-loading-overlay {
  position: absolute;
  inset: 0;
  display: none;              /* toggled by JS */
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.65);
  z-index: 35;                /* above modal card during submit */
}
.lpc-loading-overlay[aria-hidden="false"] { display: flex; }

/* Minimal spinner */
.lpc-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #111827;
  border-radius: 50%;
  animation: lpc-spin 0.9s linear infinite;
}
@keyframes lpc-spin { to { transform: rotate(360deg); } }

/* Optional success style for the top error/info box */
.lpc-error.lpc-success {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}
/* ============ Upload UI ============ */
.lpc-upload { margin: 10px 0 12px; }
.lpc-upload__label { display:block; font-weight: 600; margin-bottom: 6px; }
.lpc-upload input[type="file"] { display:block; margin-bottom: 8px; }
.lpc-upload__hint { display:block; color:#6b7280; }

.lpc-upload__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lpc-upload__item {
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border:1px solid #e5e7eb;
  border-radius:6px;
  margin-bottom:6px;
  background:#fff;
}
.lpc-upload__name {
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  max-width: 100%;
}
.lpc-upload__remove {
  border:1px solid #ef4444;
  background:#fff;
  color:#ef4444;
  padding:4px 8px;
  border-radius:6px;
  cursor:pointer;
}
.lpc-upload__remove:hover { background:#fee2e2; }
/* Center the main price ladder */
#lpc_ladder th,
#lpc_ladder td {
  text-align: center;
}

/* (Optional) also center the "price per 1000" table */
#lpc_per_1000_table th,
#lpc_per_1000_table td {
  text-align: center;
}
/* Ensure hidden rows stay hidden even against .lpc-dims !important */
.lpc-row.lpc-dims.lpc-hide { 
  display: none !important;
}
/* --- Dimension mode radios: standard look + single line --- */
.lpc-row .lpc-dim-mode {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
  border: 0;
  padding: 0;
  margin: 0;
  white-space: nowrap;        /* keep labels on one line */
}

.lpc-row .lpc-dim-mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

/* Reset many theme overrides so radios look native */
.lpc-row .lpc-dim-mode input[type="radio"] {
  appearance: auto !important;
  -webkit-appearance: radio !important;
  -moz-appearance: radio !important;
  width: auto !important;
  height: auto !important;
  line-height: normal;
  background: initial !important;
  border: initial !important;
  box-shadow: none !important;
  transform: none !important;
  margin: 0 4px 0 0;          /* small space before label text */
  position: static !important;
}

/* Optional: ensure the fieldset never wraps beneath */
@media (max-width: 420px) {
  .lpc-row .lpc-dim-mode {
    overflow-x: auto;         /* allow horizontal scroll instead of wrapping */
  }
}
/* Stack the rows vertically (no grid on parent) */
.lpc-col3 .lpc-price-summary{
  display: flex !important;
  flex-direction: column;
  row-gap: 10px;               /* replaces grid gap */
}

/* Each price row: label grows, price hugs content */
.lpc-col3 .lpc-price-summary .lpc-unit,
.lpc-col3 .lpc-price-summary .lpc-total{
  display: flex !important;
  align-items: center;
  gap: .75rem;
}

/* Let the left label shrink/wrap; keep the right price on one line */
.lpc-col3 .lpc-price-summary .lpc-unit > span,
.lpc-col3 .lpc-price-summary .lpc-total > span{
  flex: 1 1 auto;
  min-width: 0;                /* critical to prevent overflow in flex */
  overflow-wrap: anywhere;
}
.lpc-col3 .lpc-price-summary .lpc-unit > strong,
.lpc-col3 .lpc-price-summary .lpc-total > strong{
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: right;
}
/* ===== Mobile fixes (table fits, no horizontal scroll) ===== */
@media (max-width: 600px){

  /* 0) Tighter panel padding */
  .lpc-wrap .lpc-panel{
    padding: 8px !important;
  }

  /* 1) Stop column 3 from being scrollable */
  .lpc-wrap .lpc-col3{
    overflow-x: visible !important; /* overrides the inline rule in calculator.php */
  }

  /* 2) Make the ladder table fit the column */
  .lpc-wrap .lpc-col3 .lpc-ladder{
    width: 100% !important;
    min-width: 0 !important;       /* beats the old 420px min-width */
    table-layout: fixed;            /* share width across columns */
    border-collapse: collapse;
  }
  .lpc-wrap .lpc-col3 .lpc-ladder thead th{
    font-weight: 600;
  }
  .lpc-wrap .lpc-col3 .lpc-ladder th,
  .lpc-wrap .lpc-col3 .lpc-ladder td{
    padding: 6px 6px;               /* tighter cells */
    font-size: clamp(12px, 3.3vw, 13px);
    line-height: 1.25;
  }

  /* Allow header text to wrap to two lines if needed */
  .lpc-wrap .lpc-col3 .lpc-ladder th{
    white-space: normal;
    word-break: break-word;
  }

  /* First column can wrap; price columns compact & right aligned */
  .lpc-wrap .lpc-col3 .lpc-ladder th:nth-child(1),
  .lpc-wrap .lpc-col3 .lpc-ladder td:nth-child(1){
    width: 40%;
  }
  .lpc-wrap .lpc-col3 .lpc-ladder th:nth-child(2),
  .lpc-wrap .lpc-col3 .lpc-ladder td:nth-child(2),
  .lpc-wrap .lpc-col3 .lpc-ladder th:nth-child(3),
  .lpc-wrap .lpc-col3 .lpc-ladder td:nth-child(3){
    width: 30%;
    white-space: nowrap;
    text-align: right;
  }

  /* 3) Price rows: smaller typography + tighter gaps */
  .lpc-wrap .lpc-col3 .lpc-price-summary{
    row-gap: 6px; /* was 10px */
  }
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-unit,
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-total{
    padding: 6px 8px; /* reduce inner padding */
  }
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-unit > span,
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-total > span{
    font-size: clamp(12px, 3.3vw, 13px);
  }
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-unit > strong,
  .lpc-wrap .lpc-col3 .lpc-price-summary .lpc-total > strong{
    font-size: clamp(13px, 3.8vw, 15px);
  }
}
/* Upload: keep the native file input from overflowing */
.lpc-wrap .lpc-upload input[type="file"]{
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Clip any internal "Choose file" button/text so it can't push the field wider */
.lpc-wrap .lpc-upload{ 
  overflow: hidden;     /* safe, only affects the upload row */
  min-width: 0;
}

/* Optional: limit the internal button width so long UI strings don't expand it */
@supports selector(::file-selector-button){
  .lpc-wrap .lpc-upload input[type="file"]::file-selector-button{
    max-width: 45%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
/* Safari/WebKit prefix */
.lpc-wrap .lpc-upload input[type="file"]::-webkit-file-upload-button{
  max-width: 45%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mobile: now that the table fits, stop column 3 from scrolling horizontally */
@media (max-width: 600px){
  .lpc-wrap .lpc-col3{ overflow-x: hidden; }
}
