/* ==========================================================================
   assets/css/convenios.css — ZmedPlus: Cadastro e Regras de Convênios (4 abas)
   Abas: 1 Cadastro | 2 Planos | 3 TISS | 4 Impostos
   Escopado em #cl-convenios / .cvx-* (identidade visual nativa ZmedPlus)
   ========================================================================== */
#cl-convenios .cl-rp { grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
#cl-convenios .cl-rp-itens { max-height: 70vh; }

.cvx-tabs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  padding: 6px 8px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
}
.cvx-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff; color: #475569; font: inherit; font-size: .82rem;
  font-weight: 700; cursor: pointer; transition: all .15s;
}
.cvx-tab:hover { border-color: #155785; color: #155785; }
.cvx-tab .num {
  width: 20px; height: 20px; border-radius: 50%; background: #e2e8f0; color: #334155;
  display: inline-flex; align-items: center; justify-content: center; font-size: .71rem; font-weight: 800;
}
.cvx-tab .cnt {
  padding: 1px 7px; border-radius: 999px; background: #e2e8f0; color: #334155;
  font-size: .7rem; font-weight: 800;
}
.cvx-tab .cnt:empty { display: none; }
.cvx-tab.active { background: #155785; border-color: #155785; color: #fff; box-shadow: 0 4px 12px -6px rgba(21, 87, 133, .55); }
.cvx-tab.active .num { background: #129f82; color: #fff; }
.cvx-tab.active .cnt { background: rgba(255, 255, 255, .22); color: #fff; }

.cvx-pane { display: flex; flex-direction: column; gap: 12px; }
.cvx-pane[hidden] { display: none !important; }

.cvx-sec {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 8px -5px rgba(15, 42, 68, .08);
}
.cvx-sec-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.cvx-sec-h b {
  font-size: .77rem; font-weight: 800; text-transform: uppercase; letter-spacing: .045em;
  color: #155785; display: inline-flex; align-items: center; gap: 7px;
}
.cvx-sec-h small { font-size: .74rem; color: #64748b; }
.cvx-sec-b { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.cvx-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 12px; align-items: end; }
.cvx-f { display: flex; flex-direction: column; gap: 4px; grid-column: span 4; min-width: 0; }
.cvx-f.c2 { grid-column: span 2; }
.cvx-f.c3 { grid-column: span 3; }
.cvx-f.c4 { grid-column: span 4; }
.cvx-f.c5 { grid-column: span 5; }
.cvx-f.c6 { grid-column: span 6; }
.cvx-f.c7 { grid-column: span 7; }
.cvx-f.c8 { grid-column: span 8; }
.cvx-f.c9 { grid-column: span 9; }
.cvx-f.c12 { grid-column: span 12; }

.cvx-f > label {
  font-size: .71rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #475569;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.cvx-f > label .cvx-hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: #64748b; font-size: .71rem; }
.cvx-f input:not([type=checkbox]):not([type=radio]):not([type=file]),
.cvx-f select,
.cvx-f textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px;
  font: inherit; font-size: .85rem; color: #0f2942; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.cvx-f input:focus, .cvx-f select:focus, .cvx-f textarea:focus {
  outline: none; border-color: #129f82; box-shadow: 0 0 0 3px rgba(18, 159, 130, .15);
}
.cvx-f textarea { resize: vertical; min-height: 62px; }
.cvx-inp-row { display: flex; gap: 6px; align-items: stretch; }
.cvx-inp-row input { flex: 1; min-width: 0; }
.cvx-cep-btn {
  padding: 0 11px; border-radius: 8px; border: 1px solid #cbd5e1; background: #f1f5f9;
  color: #155785; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.cvx-cep-btn:hover { background: #e6f7f5; border-color: #129f82; color: #0f766e; }

/* Toggle switches estilizados (Regras TISS e Retenções) */
.cvx-sw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.cvx-sw {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc;
  cursor: pointer; transition: all .15s; user-select: none;
}
.cvx-sw:hover { border-color: #93c5fd; background: #f1f7fb; }
.cvx-sw:has(input:checked) { border-color: #129f82; background: #f0fdfa; }
.cvx-sw input {
  appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 999px;
  background: #cbd5e1; position: relative; flex-shrink: 0; cursor: pointer; transition: background .18s; margin: 0;
}
.cvx-sw input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .18s;
}
.cvx-sw input:checked { background: #129f82; }
.cvx-sw input:checked::after { transform: translateX(16px); }
.cvx-sw-txt { display: flex; flex-direction: column; min-width: 0; }
.cvx-sw-txt b { font-size: .82rem; color: #0f2942; line-height: 1.25; }
.cvx-sw-txt small { font-size: .71rem; color: #64748b; line-height: 1.25; margin-top: 1px; }

/* Chips de campos obrigatórios extras */
.cvx-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cvx-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  border: 1px solid #cbd5e1; background: #fff; font-size: .78rem; font-weight: 700; color: #334155; cursor: pointer;
}
.cvx-chip:has(input:checked) { background: #e6f7f5; border-color: #129f82; color: #0f687a; }
.cvx-chip input { margin: 0; accent-color: #129f82; }

/* Numeração Automática de Guia (3 cards) */
.cvx-auto-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cvx-auto-card {
  border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 11px 12px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 9px; transition: all .15s;
}
.cvx-auto-card.on { background: #fff; border-color: #129f82; box-shadow: 0 4px 12px -8px rgba(18, 159, 130, .45); }
.cvx-auto-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cvx-auto-head b { font-size: .82rem; color: #155785; display: inline-flex; align-items: center; gap: 6px; }
.cvx-auto-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cvx-auto-fields .full { grid-column: 1 / -1; }
.cvx-auto-card:not(.on) .cvx-auto-fields { opacity: .55; }
.cvx-auto-fields label { font-size: .68rem; font-weight: 800; text-transform: uppercase; color: #64748b; display: block; margin-bottom: 3px; }
.cvx-auto-fields input {
  width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 7px; font: inherit;
  font-size: .84rem; color: #0f2942; background: #fff; font-variant-numeric: tabular-nums;
}

/* Aba Planos: Honorário (+/-) e Tabela de Planos */
.cvx-sinal {
  display: inline-flex; border: 1px solid #cbd5e1; border-radius: 8px; overflow: hidden; background: #f8fafc;
}
.cvx-sinal button {
  border: 0; background: transparent; padding: 7px 11px; font: inherit; font-size: .82rem;
  font-weight: 800; color: #475569; cursor: pointer;
}
.cvx-sinal button.on { background: #155785; color: #fff; }
.cvx-sinal button.on[data-s="+"] { background: #0f766e; }
.cvx-sinal button.on[data-s="-"] { background: #dc2626; }

.cvx-pbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.cvx-pacts { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cvx-ptbl-wrap { overflow-x: auto; border: 1px solid #e2e8f0; border-radius: 10px; }
.cvx-ptbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
.cvx-ptbl th {
  background: #155785; color: #fff; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; padding: 8px 9px; text-align: left; white-space: nowrap;
}
.cvx-ptbl th.n, .cvx-ptbl td.n { text-align: right; font-variant-numeric: tabular-nums; }
.cvx-ptbl th.c, .cvx-ptbl td.c { text-align: center; }
.cvx-ptbl td { padding: 8px 9px; border-bottom: 1px solid #eef2f6; color: #1e293b; vertical-align: middle; }
.cvx-ptbl tbody tr { cursor: pointer; transition: background .12s; }
.cvx-ptbl tbody tr:hover { background: #f1f7fb; }
.cvx-ptbl tbody tr.sel { background: #e6f7f5; }
.cvx-ptbl tbody tr.inativo { opacity: .6; }
.cvx-st {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 800; text-transform: uppercase;
  background: #dcfce7; color: #166534;
}
.cvx-st.off { background: #fee2e2; color: #991b1b; }

/* Aba Impostos */
.cvx-imp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cvx-imp-card {
  border: 1px solid #e2e8f0; border-radius: 11px; padding: 11px 12px; background: #fff;
  display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, background .15s;
}
.cvx-imp-card.ret { border-color: #129f82; background: #f0fdfa; }
.cvx-imp-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.cvx-imp-top b { font-size: .88rem; color: #0f2942; }
.cvx-imp-top small { font-size: .71rem; color: #64748b; display: block; }
.cvx-imp-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cvx-imp-pct {
  display: inline-flex; align-items: center; gap: 4px; width: 105px;
}
.cvx-imp-pct input {
  width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 7px; font: inherit;
  font-size: .86rem; font-weight: 700; text-align: right; color: #0f2942; background: #fff;
}
.cvx-imp-resumo {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 12px; color: #fff;
  background: linear-gradient(95deg, #10325a 0%, #155785 55%, #129f82 100%);
}
.cvx-imp-kpis { display: flex; gap: 18px; flex-wrap: wrap; }
.cvx-imp-kpi span { display: block; font-size: .68rem; text-transform: uppercase; opacity: .82; font-weight: 700; }
.cvx-imp-kpi b { font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cvx-imp-presets { display: flex; gap: 7px; flex-wrap: wrap; }
.cvx-imp-presets button {
  border: 1px solid #cbd5e1; background: #fff; color: #155785; padding: 5px 11px; border-radius: 999px;
  font: inherit; font-size: .74rem; font-weight: 700; cursor: pointer;
}
.cvx-imp-presets button:hover { background: #e6f7f5; border-color: #129f82; }

@media (max-width: 1120px) {
  .cvx-auto-grid, .cvx-imp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .cvx-f, .cvx-f.c2, .cvx-f.c3, .cvx-f.c4, .cvx-f.c5, .cvx-f.c6, .cvx-f.c7, .cvx-f.c8, .cvx-f.c9 { grid-column: span 12; }
  .cvx-sw-grid, .cvx-auto-grid, .cvx-imp-grid { grid-template-columns: 1fr; }
}
