/* ===========================================
   Portal Propuestas Odonto Excellence
   =========================================== */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Calibri, sans-serif;
  color: #1F2937; background: #F3F4F6;
  -webkit-font-smoothing: antialiased;
}

/* ===========================================
   Navbar
   =========================================== */
.navbar {
  background: #0E7490; color: white; padding: 12px 24px;
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar .brand { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.navbar .brand small { font-weight: 400; opacity: 0.85; font-size: 13px; margin-left: 8px; }
.navbar nav a {
  color: white; text-decoration: none; margin-left: 20px;
  font-size: 14px; opacity: 0.9; transition: opacity 0.15s;
}
.navbar nav a:hover { opacity: 1; }
.navbar .user-badge {
  background: rgba(255,255,255,0.15); padding: 6px 12px; border-radius: 6px;
  margin-left: 16px; font-size: 13px;
}

/* ===========================================
   Layout: editor splitpane
   =========================================== */
.app-layout {
  display: grid; grid-template-columns: 380px 1fr;
  height: calc(100vh - 52px); overflow: hidden;
}
.editor-sidebar {
  background: white; border-right: 1px solid #E5E7EB;
  overflow-y: auto; padding: 20px;
}
.preview-area {
  overflow-y: auto; padding: 32px; background: #E5E7EB;
}

/* ===========================================
   Form controls
   =========================================== */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12px; font-weight: 600;
  color: #6B7280; text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 12px; border: 1px solid #D1D5DB;
  border-radius: 6px; font-size: 14px; font-family: inherit;
  background: white; transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: #0E7490; box-shadow: 0 0 0 3px rgba(14,116,144,0.15);
}
.field textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border: none; border-radius: 6px;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: #0E7490; color: white; }
.btn-primary:hover { background: #155E75; }
.btn-secondary { background: #F3F4F6; color: #1F2937; border: 1px solid #E5E7EB; }
.btn-secondary:hover { background: #E5E7EB; }
.btn-success { background: #047857; color: white; }
.btn-success:hover { background: #065F46; }
.btn-ghost { background: transparent; color: #6B7280; }
.btn-ghost:hover { color: #1F2937; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Paste zone */
.paste-zone {
  border: 2px dashed #0E7490; border-radius: 8px;
  padding: 24px 16px; text-align: center; cursor: pointer;
  background: #ECFEFF; color: #0E7490; font-weight: 600;
  transition: all 0.15s; margin-bottom: 16px;
}
.paste-zone:hover { background: #CFFAFE; }
.paste-zone.has-image { padding: 8px; background: white; border-style: solid; }
.paste-zone img { max-width: 100%; border-radius: 4px; display: block; }
.paste-zone .hint { font-size: 12px; color: #6B7280; font-weight: 400; margin-top: 8px; }

/* Loading */
.loading {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; color: #6B7280; font-size: 13px;
}
.spinner {
  width: 14px; height: 14px; border: 2px solid #E5E7EB;
  border-top-color: #0E7490; border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Procedures list */
.proc-list { margin-top: 8px; }
.proc-item {
  display: grid; grid-template-columns: 1fr 100px 30px; gap: 6px;
  padding: 6px 0; border-bottom: 1px solid #F3F4F6; font-size: 13px;
  align-items: center;
}
.proc-item .name { font-weight: 500; }
.proc-item .detail { color: #6B7280; font-size: 11px; }
.proc-item input { padding: 4px 8px; font-size: 12px; text-align: right; }
.proc-item .remove {
  background: transparent; border: none; color: #B91C1C; cursor: pointer;
  font-size: 16px; padding: 0;
}
.proc-item .remove:hover { color: #7F1D1D; }

.sidebar-section {
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid #F3F4F6;
}
.sidebar-section h3 {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: #0E7490; margin: 0 0 10px 0;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ===========================================
   Login page
   =========================================== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0E7490 0%, #155E75 100%);
}
.login-card {
  background: white; border-radius: 12px; padding: 40px;
  width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.login-card h1 {
  margin: 0 0 8px 0; font-size: 22px; color: #1F2937;
}
.login-card p { color: #6B7280; font-size: 14px; margin: 0 0 24px 0; }
.login-error {
  background: #FEF2F2; color: #B91C1C; padding: 10px 14px;
  border-radius: 6px; font-size: 13px; margin-bottom: 16px;
  border-left: 3px solid #B91C1C;
}

/* ===========================================
   Tabela de histórico
   =========================================== */
.data-table {
  background: white; border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.data-table table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px; font-size: 12px;
  text-transform: uppercase; color: #6B7280; font-weight: 600;
  background: #F9FAFB; border-bottom: 1px solid #E5E7EB;
}
.data-table td {
  padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #F3F4F6;
}
.data-table tr:hover td { background: #F9FAFB; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }
.container h1 { font-size: 22px; margin-bottom: 20px; }

/* ===========================================
   EL DOCUMENTO (preview e impresión)
   =========================================== */
.doc {
  background: white;
  width: 8.5in;
  margin: 0 auto;
  padding: 0.5in;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  font-size: 10pt;
  color: #1F2937;
  line-height: 1.45;
}

/* Cabecera del documento */
.doc-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-bottom: 10px;
  border-bottom: 3px solid #0E7490;
  margin-bottom: 14px;
}
.doc-header .title-group h1 {
  font-size: 20pt; font-weight: 700; color: #1F2937;
  margin: 0 0 4px 0; letter-spacing: -0.3px;
}
.doc-header .title-group .sub { font-size: 10pt; color: #6B7280; }
.doc-header .title-group .sub em { font-style: italic; }
.doc-header .preparedby {
  text-align: right; font-size: 9pt; color: #6B7280;
}
.doc-header .preparedby .by-name {
  font-weight: 600; color: #1F2937; font-size: 10pt;
}
.doc-header .logo {
  font-weight: 800; font-size: 11pt; color: #0E7490;
  letter-spacing: 0.5px;
}

.doc-intro {
  font-size: 10pt; line-height: 1.5; margin-bottom: 12px;
}
.doc-intro strong.brand { color: #0E7490; }

/* Captura de tela da secretária */
.doc-screenshot {
  background: #F9FAFB; border: 1px solid #E5E7EB; border-radius: 6px;
  padding: 8px; margin-bottom: 14px;
}
.doc-screenshot .caption {
  font-size: 8pt; color: #6B7280; text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 600; margin-bottom: 6px;
}
.doc-screenshot img {
  max-width: 100%; display: block; border-radius: 3px;
  border: 1px solid #E5E7EB;
}

/* Fases */
.phase {
  display: grid;
  grid-template-columns: 50px 150px 1fr 75px;
  gap: 0;
  margin-bottom: 8px;
  page-break-inside: avoid;
  break-inside: avoid;
}
.phase-badge {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: white; padding: 8px 4px;
}
.phase-badge .label { font-size: 7pt; font-weight: 700; letter-spacing: 1px; opacity: 0.9; }
.phase-badge .num { font-size: 22pt; font-weight: 800; line-height: 1; margin-top: 2px; }

.phase-img {
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
}
.phase-img svg { width: 100%; height: auto; max-height: 110px; }

.phase-text { padding: 10px 12px; }
.phase-text .title {
  font-size: 10pt; font-weight: 700; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.phase-text .sublabel {
  font-size: 7.5pt; font-weight: 700; color: #6B7280;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 6px; margin-bottom: 2px;
}
.phase-text .desc { font-size: 9pt; line-height: 1.4; color: #1F2937; }
.phase-text .desc.italic { font-style: italic; }
.phase-text .proc { font-size: 8pt; color: #1F2937; line-height: 1.35; }

.phase-qr {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 4px;
}
.phase-qr .qr-label {
  font-size: 7.5pt; font-weight: 700; margin-bottom: 4px;
  display: flex; align-items: center; gap: 3px;
}
.phase-qr svg { width: 55px; height: 55px; }
.phase-qr .hint {
  font-size: 6pt; font-style: italic; color: #6B7280;
  text-align: center; margin-top: 3px; line-height: 1.2;
}

/* Paleta de fases */
.phase-1 .phase-badge { background: #B91C1C; }
.phase-1 .phase-img, .phase-1 .phase-text, .phase-1 .phase-qr { background: #FEF2F2; }
.phase-1 .phase-text .title { color: #B91C1C; }
.phase-1 .phase-qr .qr-label { color: #B91C1C; }

.phase-2 .phase-badge { background: #C2410C; }
.phase-2 .phase-img, .phase-2 .phase-text, .phase-2 .phase-qr { background: #FFF7ED; }
.phase-2 .phase-text .title { color: #C2410C; }
.phase-2 .phase-qr .qr-label { color: #C2410C; }

.phase-3 .phase-badge { background: #0E7490; }
.phase-3 .phase-img, .phase-3 .phase-text, .phase-3 .phase-qr { background: #ECFEFF; }
.phase-3 .phase-text .title { color: #0E7490; }
.phase-3 .phase-qr .qr-label { color: #0E7490; }

.phase-4 .phase-badge { background: #047857; }
.phase-4 .phase-img, .phase-4 .phase-text, .phase-4 .phase-qr { background: #ECFDF5; }
.phase-4 .phase-text .title { color: #047857; }
.phase-4 .phase-qr .qr-label { color: #047857; }

/* Seção "Por qué la secuencia importa" */
.section-title {
  font-size: 13pt; font-weight: 700; color: #0E7490;
  margin: 16px 0 8px 0;
}
.section-intro { font-size: 9.5pt; margin-bottom: 8px; }

/* Tabela comparativa */
.compare-table {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid #E5E7EB; border-radius: 4px; overflow: hidden;
  margin-bottom: 14px;
}
.compare-table .h {
  padding: 8px 12px; color: white; font-weight: 700; font-size: 9pt;
}
.compare-table .h-ok { background: #047857; }
.compare-table .h-bad { background: #B91C1C; }
.compare-table .c { padding: 7px 12px; font-size: 8.5pt; }
.compare-table .c-ok { background: #ECFDF5; }
.compare-table .c-bad { background: #FEF2F2; }
.compare-table .c + .c { border-top: 1px solid #E5E7EB; }

/* Caixa de alerta */
.alert-box {
  background: #FEF2F2;
  border-left: 6px solid #B91C1C;
  border-top: 1px solid #B91C1C;
  border-right: 1px solid #B91C1C;
  border-bottom: 1px solid #B91C1C;
  padding: 14px 18px;
  border-radius: 3px;
  margin-bottom: 14px;
  page-break-inside: avoid; break-inside: avoid;
}
.alert-box .alert-title {
  font-size: 11pt; font-weight: 700; color: #B91C1C;
  margin-bottom: 8px;
}
.alert-box .alert-item {
  font-size: 9pt; line-height: 1.45; margin-bottom: 5px;
}
.alert-box .alert-item strong { color: #1F2937; }
.alert-box .alert-rule {
  font-size: 9pt; font-weight: 700; color: #B91C1C;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #FCA5A5;
}
.alert-box .alert-rule span { color: #1F2937; }

/* Bloco de investimento */
.invest-box {
  background: #F5F3FF; border: 2px solid #6D28D9;
  padding: 18px; border-radius: 6px;
  page-break-inside: avoid; break-inside: avoid;
}
.invest-box h2 {
  font-size: 14pt; font-weight: 700; color: #6D28D9;
  margin: 0 0 4px 0;
}
.invest-box .total {
  font-size: 10pt; margin-bottom: 10px;
}
.invest-box .total b {
  font-size: 14pt; color: #6D28D9;
}
.invest-box .rationale {
  font-size: 9pt; line-height: 1.5; margin-bottom: 12px;
}

.pay-options {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin-bottom: 12px;
}
.pay-card {
  background: white; border-radius: 5px; overflow: hidden;
  border: 1px solid #E5E7EB;
}
.pay-card .pay-head {
  color: white; padding: 8px; text-align: center;
}
.pay-card .pay-head .opt-label { font-size: 7.5pt; font-weight: 700; opacity: 0.85; letter-spacing: 0.5px; }
.pay-card .pay-head .opt-title { font-size: 10pt; font-weight: 700; margin-top: 2px; }
.pay-card .pay-badge {
  padding: 10px; text-align: center;
}
.pay-card .pay-badge .big { font-size: 14pt; font-weight: 800; }
.pay-card .pay-badge .sub { font-size: 7.5pt; color: #6B7280; font-style: italic; margin-top: 2px; }
.pay-card .pay-value {
  padding: 10px; text-align: center; border-top: 1px solid #F3F4F6;
}
.pay-card .pay-value .lbl { font-size: 7.5pt; color: #6B7280; }
.pay-card .pay-value .val { font-size: 12pt; font-weight: 800; margin-top: 3px; }
.pay-card .pay-value .foot { font-size: 7.5pt; color: #6B7280; font-style: italic; margin-top: 3px; }
.pay-card .pay-note {
  background: #F9FAFB; padding: 7px; text-align: center;
  font-size: 7.5pt; color: #6B7280;
}

.pay-card.opt-1 .pay-head { background: #B45309; }
.pay-card.opt-1 .pay-badge { background: #FEF3C7; }
.pay-card.opt-1 .pay-badge .big { color: #B45309; }
.pay-card.opt-1 .pay-value .val { color: #B45309; }
.pay-card.opt-1 .pay-value .ahorro { color: #B45309; font-weight: 700; font-size: 8pt; }

.pay-card.opt-2 .pay-head { background: #6D28D9; }
.pay-card.opt-2 .pay-badge { background: #F5F3FF; }
.pay-card.opt-2 .pay-badge .big { color: #6D28D9; }
.pay-card.opt-2 .pay-value .val { color: #6D28D9; }

.pay-card.opt-3 .pay-head { background: #047857; }
.pay-card.opt-3 .pay-badge { background: #ECFDF5; }
.pay-card.opt-3 .pay-badge .big { color: #047857; }
.pay-card.opt-3 .pay-value .val { color: #047857; }

.invest-closing {
  font-size: 9pt; margin-top: 8px;
}
.invest-closing strong.cta { color: #6D28D9; }

/* Observación personalizada */
.observations {
  background: #FFFBEB; border-left: 4px solid #D97706;
  padding: 10px 14px; border-radius: 3px; margin-bottom: 14px;
  font-size: 9.5pt; line-height: 1.5;
}
.observations .obs-title {
  font-weight: 700; color: #92400E; font-size: 8pt;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}

/* Presets de parcelas */
.installments-presets {
  display: flex; gap: 4px; margin-top: 6px;
}
.preset-btn {
  flex: 1; padding: 4px 0; font-size: 11px; font-weight: 600;
  border: 1px solid #DDD6FE; border-radius: 4px;
  background: white; color: #6D28D9; cursor: pointer;
  font-family: inherit; transition: all 0.1s;
}
.preset-btn:hover { background: #EDE9FE; }
.preset-btn.active { background: #6D28D9; color: white; border-color: #6D28D9; }

/* Badge protésico na lista lateral */
.protesico-badge {
  display: inline-block;
  background: #FEF3C7; color: #92400E;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px;
  border: 1px solid #FCD34D;
  vertical-align: middle; margin-left: 4px;
}

/* Nota de somente leitura para secretárias */
.readonly-note {
  background: #F0F9FF; color: #0369A1;
  border: 1px solid #BAE6FD; border-radius: 4px;
  padding: 6px 10px; font-size: 11px;
  margin-bottom: 8px;
}

/* Breakdown protésico/financiável no documento */
.invest-breakdown {
  margin: 6px 0 10px 0;
  padding: 8px 12px;
  background: #FFFBEB; border: 1px solid #FCD34D;
  border-radius: 4px;
}
.breakdown-item {
  font-size: 9pt; line-height: 1.6;
}
.breakdown-prot { color: #92400E; }
.breakdown-fin { color: #065F46; }
.breakdown-item b { font-size: 10pt; }

/* Caixa informativa separação protésico */
.non-financiable-note {
  background: #FFF7ED; border-left: 4px solid #F97316;
  padding: 8px 12px; border-radius: 3px;
  font-size: 8.5pt; color: #7C2D12;
  line-height: 1.5; margin-bottom: 10px;
}

/* ===========================================
   @media print — CSS crítico para exportação PDF
   =========================================== */
@media print {
  @page {
    size: letter;
    margin: 0;
  }
  body { background: white; }
  .no-print { display: none !important; }
  .app-layout { display: block; height: auto; overflow: visible; }
  .preview-area { padding: 0; background: white; overflow: visible; }
  .doc {
    box-shadow: none; margin: 0; padding: 0.5in;
    width: 100%;
  }
  .phase { page-break-inside: avoid; break-inside: avoid; }
  .alert-box, .invest-box, .compare-table, .doc-screenshot {
    page-break-inside: avoid; break-inside: avoid;
  }
}
