/* =============================================================
   Contract Maker — contract-maker.css
   Mobile-first. Scoped to .cm-wrap
   ============================================================= */

.cm-wrap *, .cm-wrap *::before, .cm-wrap *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}
.cm-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px; color: #1e293b;
  max-width: 1100px; margin: 0 auto;
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 16px; overflow: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.cm-header {
  padding: 18px 24px 16px;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.cm-title    { font-size: 21px; font-weight: 700; color: #1e3a5f; margin-bottom: 3px; }
.cm-subtitle { font-size: 13px; color: #64748b; }
.cm-header-right {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
}
.cm-type-field     { min-width: 200px; }
.cm-currency-field { min-width: 110px; }

/* ── Body ─────────────────────────────────────────────────── */
.cm-body { display: flex; flex-direction: column; }
@media (min-width: 800px) {
  .cm-body { flex-direction: row; align-items: flex-start; }
  .cm-form          { width: 50%; border-right: 1px solid #e2e8f0; overflow-y: auto; }
  .cm-preview-panel { width: 50%; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
}

/* ── Form ─────────────────────────────────────────────────── */
.cm-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.cm-section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #64748b; padding-top: 4px;
}

.cm-card {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.cm-card-label {
  font-size: 12px; font-weight: 700; color: #334155;
  text-transform: uppercase; letter-spacing: .05em;
}

.cm-field { display: flex; flex-direction: column; gap: 5px; }
.cm-label { font-size: 12.5px; font-weight: 600; color: #334155; }
.cm-optional { font-weight: 400; color: #94a3b8; font-size: 11px; }

.cm-input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  font-size: 13.5px; color: #1e293b; background: #f8fafc;
  font-family: inherit; outline: none;
  transition: border-color .18s, background .18s;
  -moz-appearance: textfield;
}
.cm-input::-webkit-outer-spin-button,
.cm-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cm-input:focus { border-color: #7c3aed; background: #fff; }
.cm-textarea { resize: vertical; min-height: 68px; }

.cm-select {
  width: 100%; padding: 9px 32px 9px 12px; height: 42px;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  font-size: 13.5px; color: #1e293b; background: #f8fafc;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23718096' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color .18s; outline: none;
}
.cm-select:focus { border-color: #7c3aed; background-color: #fff; }

.cm-prefix-wrap, .cm-suffix-wrap {
  display: flex; align-items: center;
  border: 1.5px solid #cbd5e1; border-radius: 8px;
  overflow: hidden; background: #f8fafc; transition: border-color .18s;
}
.cm-prefix-wrap:focus-within,
.cm-suffix-wrap:focus-within { border-color: #7c3aed; background: #fff; }
.cm-prefix, .cm-suffix {
  padding: 0 10px; font-size: 14px; font-weight: 600;
  color: #64748b; background: #f1f5f9; height: 42px;
  display: flex; align-items: center; flex-shrink: 0;
}
.cm-prefix { border-right: 1px solid #e2e8f0; }
.cm-suffix  { border-left:  1px solid #e2e8f0; }

.cm-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cm-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) {
  .cm-row-2, .cm-row-3 { grid-template-columns: 1fr; }
}

/* Actions */
.cm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.cm-btn {
  flex: 1; min-width: 90px; padding: 11px 10px;
  border-radius: 9px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: opacity .18s;
}
.cm-btn:hover { opacity: .86; }
.cm-btn-preview { background: #7c3aed; color: #fff; }
.cm-btn-pdf     { background: #185FA5; color: #fff; }
.cm-btn-print   { background: #0f766e; color: #fff; }
.cm-btn-reset   { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.cm-btn-close   { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; margin-left: auto; }

/* ── Preview Panel ────────────────────────────────────────── */
.cm-preview-panel { background: #f8fafc; padding: 20px; }
.cm-preview-label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cm-preview-label > span:first-child {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #94a3b8;
}
.cm-preview-badge {
  font-size: 11px; font-weight: 600; color: #5b21b6;
  background: #ede9fe; padding: 3px 10px; border-radius: 20px;
}
.cm-preview-doc {
  background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; padding: 24px;
  font-size: 13px; line-height: 1.7; color: #1e293b;
  min-height: 400px;
}

/* ── Contract doc internals ───────────────────────────────── */
.cd-title {
  font-size: 18px; font-weight: 800; color: #1e3a5f;
  text-align: center; margin-bottom: 4px; text-transform: uppercase;
  letter-spacing: .04em;
}
.cd-subtitle { text-align: center; font-size: 12px; color: #64748b; margin-bottom: 20px; }
.cd-parties {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  background: #f8fafc; border-radius: 8px; padding: 14px;
  margin-bottom: 18px; font-size: 12.5px;
}
.cd-party-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; margin-bottom: 4px; }
.cd-party-name { font-weight: 700; color: #1e3a5f; font-size: 13px; }
.cd-party-meta { color: #64748b; font-size: 12px; line-height: 1.6; }

.cd-section { margin-bottom: 16px; }
.cd-section-num {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #7c3aed;
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.cd-section-num::after { content: ''; flex: 1; height: 1px; background: #ede9fe; }
.cd-section-body { font-size: 12.5px; color: #334155; line-height: 1.8; }
.cd-section-body strong { color: #1e293b; }
.cd-highlight {
  background: #f5f3ff; border-left: 3px solid #7c3aed;
  border-radius: 0 6px 6px 0; padding: 8px 12px;
  margin: 8px 0; font-size: 12.5px;
}
.cd-sigs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin-top: 28px; border-top: 1px solid #e2e8f0; padding-top: 20px;
}
.cd-sig-box { display: flex; flex-direction: column; gap: 6px; }
.cd-sig-line { border-bottom: 1.5px solid #1e3a5f; height: 36px; margin-bottom: 4px; }
.cd-sig-label { font-size: 11px; color: #64748b; }
.cd-sig-name  { font-size: 12px; font-weight: 600; color: #1e293b; }
.cd-footer {
  text-align: center; margin-top: 20px;
  font-size: 10.5px; color: #cbd5e1;
  padding-top: 14px; border-top: 1px solid #f1f5f9;
}

/* ── Modal ────────────────────────────────────────────────── */
.cm-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55); z-index: 99999;
  display: flex; align-items: center;
  justify-content: center; padding: 20px;
}
.cm-modal {
  background: #fff; border-radius: 12px;
  width: 100%; max-width: 800px;
  max-height: 90vh; overflow-y: auto;
  padding: 24px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
}
.cm-modal-actions {
  display: flex; gap: 10px; margin-bottom: 18px;
  padding-bottom: 16px; border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}
.cm-modal-doc { font-size: 13px; line-height: 1.75; }

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 520px) {
  .cm-header { flex-direction: column; padding: 16px; }
  .cm-header-right { width: 100%; }
  .cm-form, .cm-preview-panel { padding: 16px; }
  .cm-title { font-size: 18px; }
  .cd-parties, .cd-sigs { grid-template-columns: 1fr; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .cm-form, .cm-header, .cm-actions,
  .cm-preview-label, .cm-modal-actions { display: none !important; }
  .cm-body    { display: block; }
  .cm-preview-panel { width: 100%; background: #fff; padding: 0; }
  .cm-preview-doc   { border: none; padding: 0; }
  .cm-wrap    { border: none; border-radius: 0; }
  .cm-modal-overlay { position: static !important; background: none !important; padding: 0; }
  .cm-modal   { box-shadow: none !important; max-height: none !important; padding: 0; }
}
