/* ===== HARD ISOLATION FROM THEME ===== */
.miscq-wrapper,
.miscq-wrapper * {
  box-sizing: border-box;
  visibility: visible !important;
  opacity: 1 !important;
}

/* ===== MAIN LAYOUT ===== */
.miscq-wrapper {
  display: flex !important;
  gap: 20px !important;
  max-width: 1400px !important;
  margin: 20px auto !important;
  font-family: Arial, sans-serif !important;
  font-size: 13px !important;
}

/* ===== BOX ===== */
.miscq-box {
  width: 50% !important;
  border: 2px solid #000 !important;
  padding: 10px !important;
  background: #fff !important;
}

/* ===== TITLE ===== */
.miscq-title {
  display: block !important;
  text-align: center !important;
  font-size: 18px !important;
  font-weight: bold !important;
  border-bottom: 2px solid #000 !important;
  margin-bottom: 10px !important;
  padding-bottom: 6px !important;
}

/* ===== TABLE ===== */
.miscq-table {
  width: 100% !important;
  border-collapse: collapse !important;
}

.miscq-table th,
.miscq-table td {
  border: 1px solid #000 !important;
  padding: 4px !important;
  text-align: center !important;
}

/* ===== INPUT ===== */
.miscq-table input {
  width: 100% !important;
  border: none !important;
  outline: none !important;
}

/* ===== BUTTON ===== */
.miscq-btn {
  display: inline-block !important;
  margin-top: 10px !important;
  padding: 6px 14px !important;
  background: #000 !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
}

/* ===== DELETE BUTTON ===== */
.del {
  background: red !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  padding: 2px 6px !important;
}

.miscq-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.miscq-form input {
  padding: 5px;
  border: 1px solid #000;
  font-size: 12px;
}

.miscq-totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 10px;
  border: 1px solid #000;
}

.miscq-totals div {
  border-right: 1px solid #000;
  padding: 6px;
  text-align: center;
}

.miscq-totals div:last-child {
  border-right: none;
}

.miscq-terms {
  width: 100%;
  height: 90px;
  margin-top: 10px;
  border: 1px solid #000;
  padding: 6px;
}

.miscq-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.miscq-btn.purple { background: purple; }
.miscq-btn.green { background: green; }

/* ===== LOCK MODE ===== */
.miscq-locked {
  opacity: 0.6;
  pointer-events: none;
}

.miscq-preview-locked {
  border: 3px solid #1b7f3b !important;
}

.discount-col input {
  width: 100%;
}

.miscq-totals.one-row {
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1.2fr;
  font-weight: bold;
}

/* ===== GRAND TOTAL ROW DYNAMIC LAYOUT ===== */

/* When discount is NOT present (4 columns) */
.miscq-totals.one-row.no-discount {
  grid-template-columns: 1.2fr 1fr 1fr 1.2fr;
}

/* When discount IS present (5 columns) */
.miscq-totals.one-row.with-discount {
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1.2fr;
}

/* ===== TERMS PREVIEW FIX (RIGHT SIDE) ===== */

#prev_terms {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Lists alignment inside preview */
#prev_terms ul,
#prev_terms ol {
  padding-left: 18px;
  margin-left: 0;
}

/* Paragraph spacing */
#prev_terms p {
  margin: 0 0 6px 0;
}

/* Prevent long words / URLs from breaking layout */
#prev_terms * {
  max-width: 100%;
}

/* ===== FINAL TERMS PREVIEW (RIGHT SIDE) ===== */

#prev_terms {
  width: 100%;
  max-width: 100%;
  height: auto !important;      /* no height limit */
  min-height: auto !important;
  overflow: visible !important; /* show full content */
  padding: 6px;
  border: 1px solid #000;
  box-sizing: border-box;
  white-space: normal;
  word-break: break-word;
}

/* REMOVE EXTRA SPACING FROM EDITOR HTML */
#prev_terms p {
  margin: 0 0 4px 0 !important;
  padding: 0 !important;
}

#prev_terms br {
  display: none;
}

/* LISTS – COMPACT & CLEAN */
#prev_terms ul,
#prev_terms ol {
  margin: 2px 0 4px 16px !important;
  padding: 0 !important;
}

#prev_terms li {
  margin: 0 !important;
  padding: 0 !important;
}

/* INLINE FORMATTING SHOULD NOT BREAK FLOW */
#prev_terms strong,
#prev_terms em,
#prev_terms u {
  line-height: 1.3;
}

/* ===== FINAL LINE HEIGHT FIX – TERMS PREVIEW ===== */

#prev_terms,
#prev_terms * {
  line-height: 1.2 !important;   /* tight but readable */
}

#prev_terms p {
  margin-bottom: 3px !important;
}

#prev_terms li {
  line-height: 1.2 !important;
}

.miscq-preset-terms {
  margin: 8px 0;
  font-size: 12px;
}

.miscq-preset-terms label {
  margin-right: 12px;
  display: inline-block;
  cursor: pointer;
}

/* ===== LETTERHEAD ===== */

.miscq-letterhead {
  margin-bottom: 10px;
  font-size: 12px;
}

.miscq-letterhead select {
  margin-left: 10px;
  padding: 3px;
}

#preview_letterhead {
  text-align: center;
  font-size: 13px;
  margin-bottom: 10px;
}

#preview_letterhead hr {
  margin: 6px 0;
}

#preview_greeting {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.25;
}

#preview_greeting p {
  margin: 0;
}

#preview_signing {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.25;
}

#preview_signing p {
  margin: 0;
}

/* ================= MOBILE RESPONSIVE ================= */
@media (max-width: 768px) {

  /* Main wrapper ko vertical kar do */
  .miscq-wrapper {
    flex-direction: column !important;
  }

  /* Dono boxes full width ho jaayen */
  .miscq-box {
    width: 100% !important;
  }

  /* Form fields 1 column me aa jaayen */
  .miscq-form {
    grid-template-columns: 1fr !important;
  }

  /* Action buttons vertical ho jaayen */
  .miscq-actions {
    flex-direction: column !important;
    gap: 8px;
  }

  .miscq-btn {
    width: 100% !important;
  }

  /* Tables thoda readable ho jaayen */
  .miscq-table th,
  .miscq-table td {
    font-size: 12px !important;
    padding: 3px !important;
  }

  /* Totals grid ko wrap karne do */
  .miscq-totals {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Grand total one-row ko bhi wrap allow */
  .miscq-totals.one-row {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Terms box height mobile pe thoda bada */
  .miscq-terms {
    height: 120px !important;
  }

}

@media (max-width: 768px) {

  /* ===== TABLE SCROLL FIX ===== */
  .miscq-table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  .miscq-table thead,
  .miscq-table tbody,
  .miscq-table tr {
    width: max-content !important;
  }

  /* Optional: scrollbar thoda clean lage */
  .miscq-table::-webkit-scrollbar {
    height: 6px;
  }

  .miscq-table::-webkit-scrollbar-thumb {
    background: #999;
    border-radius: 4px;
  }

}

@media (max-width: 768px) {

  /* ===== GRAND TOTAL SCROLL FIX ===== */
  .miscq-totals.one-row {
    display: block !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  .miscq-totals.one-row > div {
    display: inline-block !important;
    min-width: 120px;   /* har column readable rahe */
    vertical-align: top;
    border-right: 1px solid #000;
  }

  .miscq-totals.one-row > div:last-child {
    border-right: none;
  }

}

@media (max-width: 768px) {

  /* ===== FORCE HIDE DISCOUNT IF NOT ENABLED ===== */
  .miscq-totals.one-row.no-discount .discount-total {
    display: none !important;
  }

  .miscq-totals.one-row.with-discount .discount-total {
    display: inline-block !important;
  }

}


/* ===== QUOTE NO & DATE SPACING FIX ===== */
#preview_quote_no,
#preview_date {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.2 !important;
}

/* Agar ye <p> ke andar hain */
#preview_quote_no p,
#preview_date p {
  margin: 0 !important;
}

/* ===== MANDATORY PLACEHOLDER STAR ===== */
.mandatory-wrap {
  position: relative;
}

.mandatory-wrap::after {
  content: "*";
  position: absolute;
  right: 10px;
  top: 8px;
  color: red;
  font-weight: bold;
  pointer-events: none;
}


/* ===== MOBILE FIX : SAME WIDTH FOR ALL INPUTS ===== */
@media (max-width: 768px) {

  /* Form grid -> single column */
  .miscq-form {
    grid-template-columns: 1fr !important;
  }

  /* Mandatory wrapper full width */
  .mandatory-wrap {
    width: 100%;
  }

  /* All inputs & textareas same sizing */
  .miscq-form input,
  .miscq-form textarea {
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 22px !important; /* space for red * */
  }

  /* Mandatory star position fix */
  .mandatory-wrap::after {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
  }
}

