/* =============================================================================
   CONTRACT GENERATOR — STYLES
   Mobile-first. Same design language as the Playbook Form.

   Key mobile rules:
   - font-size: 16px on all inputs — prevents iOS zoom-on-focus
   - max-width: 640px centered — readable on desktop without going full-width
   - Sticky submit buttons — always reachable without scrolling
   ============================================================================= */

/* --- RESET & BASE ---------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: #f5f5f5;
  color: #1a1a1a;
  -webkit-text-size-adjust: 100%;
}

/* --- LAYOUT --------------------------------------------------------------- */

.page-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 100px 0; /* bottom padding for sticky button clearance */
}

.page-header {
  background: #1a1a2e;
  color: #fff;
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header .brand-name {
  font-size: 13px;
  opacity: 0.7;
  margin: 0 0 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.page-header .deal-name {
  font-size: 13px;
  opacity: 0.7;
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- CARDS ---------------------------------------------------------------- */

.card {
  background: #fff;
  border-radius: 8px;
  margin: 12px 16px;
  padding: 18px 16px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* --- FORM ELEMENTS -------------------------------------------------------- */

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 5px;
}

label .required {
  color: #e53e3e;
  margin-left: 2px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px; /* prevents iOS zoom */
  font-family: inherit;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #1a1a2e;
  box-shadow: 0 0 0 3px rgba(26,26,46,0.08);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Currency inputs with $ prefix */
.currency-wrapper {
  position: relative;
}

.currency-wrapper::before {
  content: "$";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #666;
  font-size: 16px;
  pointer-events: none;
}

.currency-wrapper input {
  padding-left: 26px;
}

/* Number inputs without spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* --- CHECKBOX GROUPS ------------------------------------------------------ */

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.checkbox-option:has(input:checked) {
  background: #eef0f7;
  border-color: #1a1a2e;
}

.checkbox-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: #1a1a2e;
}

.checkbox-option .option-label {
  font-size: 15px;
  line-height: 1.3;
}

/* --- YES/NO TOGGLE -------------------------------------------------------- */
/* Styled select that looks like a toggle for binary Yes/No fields */

.yes-no-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.yes-no-row label {
  flex: 1;
  margin: 0;
  font-size: 14px;
}

.yes-no-row select {
  width: 90px;
  flex-shrink: 0;
  padding: 8px 28px 8px 10px;
  font-size: 15px;
}

/* --- TWO-COLUMN GRID (for yes/no scope grids) ----------------------------- */

.scope-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

@media (max-width: 480px) {
  .scope-grid {
    grid-template-columns: 1fr;
  }
}

/* --- PREFILL NOTICE ------------------------------------------------------- */

.prefill-notice {
  font-size: 13px;
  color: #666;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
}

.prefill-notice.warning {
  background: #fff8e6;
  border-color: #f0b429;
  color: #7d5a00;
}

/* --- PRICE SOURCE INDICATOR ----------------------------------------------- */

.price-source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 5px;
}

.price-source-badge.from-appointment {
  background: #e6f4ea;
  color: #2e7d32;
}

.price-source-badge.from-deal {
  background: #fff8e6;
  color: #7d5a00;
}

/* --- PRODUCT SELECTOR (index.html) ---------------------------------------- */

.selector-intro {
  padding: 16px 16px 8px;
  color: #555;
  font-size: 15px;
}

.product-buttons {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: #fff;
  border: 1.5px solid #d0d0d0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.product-btn:hover {
  border-color: #1a1a2e;
  box-shadow: 0 2px 8px rgba(26,26,46,0.12);
}

.product-btn.has-draft {
  border-color: #f0b429;
  background: #fffcf0;
}

.product-btn .draft-badge {
  font-size: 12px;
  font-weight: 600;
  color: #7d5a00;
  background: #fde68a;
  padding: 2px 8px;
  border-radius: 4px;
}

.product-btn .arrow {
  color: #aaa;
  font-size: 18px;
}

.no-products-msg {
  padding: 20px 16px;
  color: #666;
  font-size: 14px;
  font-style: italic;
}

/* --- CONTACT BLOCK (read-only display in form) ----------------------------- */

.contact-block {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
}

.contact-block .contact-name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 2px;
}

.contact-block .contact-meta {
  color: #555;
}

/* --- PAYMENT BLOCK -------------------------------------------------------- */

.payment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.payment-row .payment-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.payment-row .payment-input {
  width: 140px;
  flex-shrink: 0;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid #eee;
  margin-top: 4px;
  font-weight: 600;
  font-size: 15px;
}

/* --- SUBMIT AREA ---------------------------------------------------------- */

.submit-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  z-index: 100;
  max-width: 640px;
  margin: 0 auto;
}

/* On desktop, keep the submit area aligned with the page content */
@media (min-width: 641px) {
  .submit-area {
    left: 50%;
    transform: translateX(-50%);
    width: 640px;
  }
}

.btn-primary {
  flex: 1;
  padding: 14px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:active {
  background: #0f0f1a;
}

.btn-primary:disabled {
  background: #999;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 14px 20px;
  background: transparent;
  color: #1a1a2e;
  border: 1.5px solid #1a1a2e;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:active {
  background: #f0f0f5;
}

/* --- STATUS MESSAGES ------------------------------------------------------ */

.status-msg {
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 14px;
  display: none;
}

.status-msg.success {
  background: #e6f4ea;
  border: 1px solid #a8d5b5;
  color: #1a4731;
  display: block;
}

.status-msg.error {
  background: #fde8e8;
  border: 1px solid #f5a0a0;
  color: #6b1a1a;
  display: block;
}

.status-msg.loading {
  background: #e8f0fe;
  border: 1px solid #aac4f5;
  color: #1a2e6b;
  display: block;
}

/* --- LOADING STATE -------------------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s infinite;
  border-radius: 4px;
  height: 16px;
  margin-bottom: 8px;
}

@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* --- UTILITY -------------------------------------------------------------- */

.hidden {
  display: none !important;
}

.text-muted {
  color: #888;
  font-size: 13px;
}

.divider {
  border: none;
  border-top: 1px solid #eee;
  margin: 4px 0 14px;
}
