/* ============================================
   Cotee — Estilos del generador (app.html)
   ============================================ */

.app-body {
  background: var(--bg-alt);
  min-height: 100vh;
}

/* App nav */
.app-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-nav__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage {
  font-size: 0.85rem;
  color: var(--text-soft);
  padding: 6px 10px;
  background: var(--bg-alt);
  border-radius: 6px;
  border: 1px solid var(--border);
}

@media (max-width: 760px) {
  .usage { display: none; }
}

/* Two-pane layout */
.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - 64px);
  overflow: hidden;
}

@media (max-width: 1000px) {
  .app-main {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.form-pane {
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--border);
  background: white;
}

.form-pane__inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-pane__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  position: sticky;
  bottom: -24px;
  background: white;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* AI Box */
.ai-box {
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}

.ai-box__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--text);
}

.ai-box__star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 6px;
  color: white;
  font-size: 0.9rem;
}

.ai-box__input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: white;
}
.ai-box__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.ai-box__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ai-box__hint {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* Form cards */
.card-form {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0;
}

.card-form legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0 8px;
  color: var(--text);
}

.row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.row:last-child { margin-bottom: 0; }
.row > .field { min-width: 0; }

.row .field--small { flex: 0 0 auto; }

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

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.field:last-child { margin-bottom: 0; }

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: white;
  color: var(--text);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field input[type="color"] {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

/* Conceptos */
.conceptos {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.concepto {
  display: grid;
  grid-template-columns: 1fr 70px 90px 90px 32px;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
}

.concepto input {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: white;
  font-size: 0.9rem;
  width: 100%;
}
.concepto input:focus {
  outline: none;
  border-color: var(--primary);
}

.concepto__total {
  text-align: right;
  font-weight: 600;
  color: var(--text);
  padding: 0 8px;
  font-size: 0.9rem;
}

.concepto__remove {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}
.concepto__remove:hover { background: rgba(239, 68, 68, 0.1); }

@media (max-width: 600px) {
  .concepto {
    grid-template-columns: 1fr 1fr;
  }
  .concepto > input:first-child { grid-column: span 2; }
  .concepto__total { grid-column: span 2; text-align: left; }
}

/* Preview pane */
.preview-pane {
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-alt);
}

.preview-pane__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.preview-pane__head h2 {
  font-size: 1rem;
  margin: 0;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.preview-pane__hint {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-left: auto;
}

/* Document preview (the actual PDF look) */
.preview-doc {
  background: white;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  padding: 50px 56px;
  font-size: 14px;
  color: #111827;
  line-height: 1.5;
  min-height: 800px;
  max-width: 800px;
  margin: 0 auto;
  font-family: var(--font);
}

.doc__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--brand-color, #2563eb);
  margin-bottom: 32px;
}

.doc__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.doc__logo {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--brand-color, #2563eb);
  color: white;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.doc__logo img { width: 100%; height: 100%; object-fit: cover; }

.doc__brand-text {
  font-size: 1.1rem;
  font-weight: 700;
}
.doc__brand-text small {
  display: block;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.doc__meta {
  text-align: right;
}
.doc__meta h1 {
  font-size: 1.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-color, #2563eb);
  margin-bottom: 8px;
}
.doc__meta p {
  margin: 2px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.doc__parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}
.doc__party h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 8px;
  font-weight: 700;
}
.doc__party p {
  margin: 2px 0;
  font-size: 0.92rem;
  color: var(--text);
}
.doc__party p:first-of-type { font-weight: 600; }

.doc__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.92rem;
}
.doc__table thead th {
  text-align: left;
  padding: 12px 10px;
  background: var(--brand-color, #2563eb);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.doc__table thead th:nth-child(2),
.doc__table thead th:nth-child(3),
.doc__table thead th:nth-child(4) { text-align: right; }

.doc__table tbody td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.doc__table tbody td:nth-child(2),
.doc__table tbody td:nth-child(3),
.doc__table tbody td:nth-child(4) { text-align: right; white-space: nowrap; }

.doc__concepto {
  font-weight: 600;
  margin-bottom: 4px;
}
.doc__detalle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.doc__totals {
  margin-left: auto;
  width: 320px;
  font-size: 0.92rem;
}
.doc__totals .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.doc__totals .row.row--total {
  border-bottom: none;
  margin-top: 8px;
  padding: 14px 12px;
  background: var(--brand-color, #2563eb);
  color: white;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.1rem;
}

.doc__notas {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.doc__notas h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin-bottom: 8px;
  font-weight: 700;
}
.doc__notas p { white-space: pre-wrap; }

.doc__foot {
  margin-top: 50px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-soft);
  text-align: center;
}

/* ============================================
   Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal[hidden] { display: none; }

.modal__inner {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal__head {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal__head h3 { margin: 0; font-size: 1.05rem; }

.modal__close {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--text-soft);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal__close:hover { background: var(--bg-alt); color: var(--text); }

.modal__body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* Saved list */
.saved-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: white;
}
.saved-item:hover { border-color: var(--primary); }

.saved-item__main { flex: 1; min-width: 0; }
.saved-item__title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.saved-item__meta {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-top: 2px;
}

.saved-item__actions {
  display: flex;
  gap: 4px;
}

.saved-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Print/PDF */
@media print {
  .app-nav, .form-pane, .preview-pane__head { display: none; }
  .preview-pane { padding: 0; background: white; }
  .preview-doc { box-shadow: none; padding: 24px; }
}

/* ============================================
   Pro features: badges, plan status, gating
   ============================================ */
.badge-pro {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white;
  margin-left: 4px;
  vertical-align: middle;
}

.usage--pro {
  background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
  color: white !important;
  border-color: transparent !important;
}

.modal__inner--wide { max-width: 720px; }

.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }
.settings-section h4 {
  margin: 0 0 12px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.plan-status {
  padding: 10px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.plan-status--pro {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(124, 58, 237, 0.08));
  border-color: var(--primary);
  color: var(--primary);
}

/* Template switch */
.template-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-left: auto;
}
.template-btn {
  background: transparent;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.template-btn:hover { color: var(--text); background: var(--bg-alt); }
.template-btn.is-active {
  background: var(--primary);
  color: white;
}
.template-btn.is-active .badge-pro {
  background: rgba(255, 255, 255, 0.25);
}
.template-btn.is-locked { opacity: 0.6; }
.template-btn.is-locked:hover { opacity: 1; }

/* Channel tabs (closing message modal) */
.channel-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-alt);
  border-radius: 8px;
  margin-bottom: 8px;
}
.channel-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.channel-tab:hover { color: var(--text); }
.channel-tab.is-active {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   PDF templates: Moderno (Pro) y Minimal (Pro)
   ============================================ */

/* MODERNO: header con bloque de color completo, totales destacados */
.preview-doc.template-moderno {
  padding: 0;
  overflow: hidden;
}
.preview-doc.template-moderno .doc__head {
  background: var(--brand-color, #2563eb);
  margin: 0;
  padding: 40px 56px;
  border-bottom: none;
  color: white;
}
.preview-doc.template-moderno .doc__brand-text { color: white; }
.preview-doc.template-moderno .doc__brand-text small { color: rgba(255, 255, 255, 0.8); }
.preview-doc.template-moderno .doc__logo {
  background: rgba(255, 255, 255, 0.18);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.preview-doc.template-moderno .doc__meta h1 {
  color: white;
  font-size: 2.2rem;
  font-weight: 800;
}
.preview-doc.template-moderno .doc__meta p { color: rgba(255, 255, 255, 0.9); }
.preview-doc.template-moderno .doc__parties,
.preview-doc.template-moderno .doc__table,
.preview-doc.template-moderno .doc__totals,
.preview-doc.template-moderno .doc__notas,
.preview-doc.template-moderno .doc__foot {
  margin-left: 56px;
  margin-right: 56px;
}
.preview-doc.template-moderno .doc__parties { margin-top: 32px; }
.preview-doc.template-moderno .doc__table thead th {
  background: var(--bg-alt);
  color: var(--text);
  border-bottom: 3px solid var(--brand-color, #2563eb);
}
.preview-doc.template-moderno .doc__totals .row--total {
  background: var(--brand-color, #2563eb);
  font-size: 1.3rem;
  padding: 18px 16px;
  border-radius: 12px;
}
.preview-doc.template-moderno .doc__foot { padding-bottom: 30px; }

/* MINIMAL: solo negro/gris, serif, muy limpio */
.preview-doc.template-minimal {
  font-family: Georgia, "Times New Roman", serif;
  color: #1a1a1a;
}
.preview-doc.template-minimal .doc__head {
  border-bottom: 1px solid #1a1a1a;
  padding-bottom: 18px;
}
.preview-doc.template-minimal .doc__logo {
  background: #1a1a1a !important;
  border-radius: 4px;
}
.preview-doc.template-minimal .doc__meta h1 {
  color: #1a1a1a;
  font-weight: 400;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
}
.preview-doc.template-minimal .doc__table thead th {
  background: transparent;
  color: #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  border-top: 1px solid #1a1a1a;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
  padding: 8px 10px;
}
.preview-doc.template-minimal .doc__table tbody td {
  border-bottom: 1px dotted #ccc;
}
.preview-doc.template-minimal .doc__concepto { font-weight: 400; font-style: italic; }
.preview-doc.template-minimal .doc__totals .row--total {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  font-weight: 700;
}
.preview-doc.template-minimal .doc__party h3 { color: #1a1a1a; }

/* ============================================
   PDF templates: keep brand color sync
   ============================================ */
