/* =========================================================
   1. MODAL GENÉRICO (Estrutura Base)
========================================================= */
.pc-modal, .modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  /* Transição suave de abertura via opacity+visibility */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  will-change: opacity;
}
/* Quando o JS remove o hidden → adiciona is-open para animar */
.pc-modal:not([hidden]), .modal:not([hidden]) {
  opacity: 1;
  visibility: visible;
}
.pc-modal[hidden], .modal[hidden] { display: none !important; }

.modal-backdrop, .pc-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  /* blur reduzido para 2px — 4px custa um frame inteiro no compositor */
  backdrop-filter: blur(2px);
  will-change: transform;
}

.modal-content.pc-modal-content {
  box-sizing: border-box;
  display: flex; flex-direction: column;
  position: relative; z-index: 10;
  max-width: 600px;
  width: 95%;
  max-height: 90vh;
  background: var(--surface, #fff);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  /* Animação do box: translateY + scale para sensação premium */
  transform: translateY(12px) scale(0.98);
  transition: transform 0.18s ease;
  will-change: transform;
  padding: 0;
  overflow: hidden;
}
.pc-modal:not([hidden]) .modal-content.pc-modal-content,
.modal:not([hidden]) .modal-content.pc-modal-content {
  transform: translateY(0) scale(1);
}

/* Remove a keyframe animation anterior — agora usamos transition */
@keyframes modalSlideIn {
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Área de Scroll (Conteúdo) */
.modal-body-scroll {
    padding: 20px 24px;
    overflow-y: auto;
    flex-grow: 1;
    overscroll-behavior: contain;
}

/* Botão Fechar */
.modal-close {
  position: absolute; top: 16px; right: 16px; z-index: 20;
  border: none; background: var(--surface-2, #F1F5F9); color: var(--muted, #64748B);
  border-radius: 50%; width: 32px; height: 32px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: .15s;
}
.modal-close:hover { background: var(--surface-3, #E2E8F0); color: var(--brand-secondary, #0F172A); }
.modal-close svg { width: 16px; height: 16px; }

/* Títulos */
.modal-title {
  margin: 0;
  color: var(--brand-secondary, #0F172A);
  font-weight: 700;
  padding: 20px 24px 0;
  font-size: 1.25rem;
}

/* =========================================================
   2. DETALHES DA COTA (Layout Financeiro)
========================================================= */

/* --- Linha 1: Administradora e Segmento --- */
.top-row-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.info-col {
  background: var(--surface-2, #F8FAFC);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.info-label {
  font-size: 0.7rem; text-transform: uppercase; color: var(--muted, #64748B); font-weight: 700; letter-spacing: 0.5px;
}
.info-value {
  font-size: 0.95rem; font-weight: 600; color: var(--brand-secondary, #0F172A); line-height: 1.2;
}
.info-value-icon {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.95rem; font-weight: 600; color: var(--brand-secondary, #0F172A); line-height: 1.2;
}
.info-value-icon svg {
  width: 18px; height: 18px; color: var(--brand-primary, #3B82F6); flex-shrink: 0;
}

/* --- Linha 2: Crédito e Entrada (Destaque Azul) --- */
.values-row-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.value-col {
  background: var(--surface-2, #EFF6FF); /* Azul bem claro */
  border: 1px solid var(--border, #DBEAFE);
  border-radius: 8px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.value-col .info-label { color: var(--brand-primary, #60A5FA); } /* Label azulado */
.value-main {
  font-size: 1.25rem;
  font-weight: 800; color: var(--brand-primary, #1D4ED8); line-height: 1.1;
}

.modal-divider {
  border: 0; border-top: 1px solid var(--border, #E2E8F0); margin: 20px 0;
}

/* --- Grid Principal (Novos Campos) --- */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr; /* Mobile: 1 coluna */
  gap: 12px;
  margin-bottom: 16px;
}

/* Estilo de "Cartão" para cada item do grid */
.modal-grid > div {
  background: var(--surface-2, #F8FAFC);
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 0; /* Previne overflow de texto */
}

/* [IMPORTANTE] Remove itens vazios (hidden via JS) */
.modal-grid > div[hidden],
.modal-grid > div[style*="display: none"] {
  display: none !important;
}

.modal-grid dt {
  color: var(--muted, #64748B); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; margin-bottom: 2px;
}
.modal-grid dd {
  margin: 0; color: var(--brand-secondary, #334155); font-size: 0.95rem; font-weight: 600; overflow-wrap: anywhere; line-height: 1.3;
}

/* Observação ocupa largura total e tem fundo diferente */
.modal-grid .full-width {
  grid-column: 1 / -1;
  background: var(--surface, #FFF);
  border: 1px dashed var(--border, #CBD5E1);
  margin-top: 8px;
}
.modal-grid .full-width dd {
    font-weight: 400; color: var(--brand-secondary, #475569); font-size: 0.9rem;
}

/* --- Breakpoints para o Grid --- */
@media (min-width: 600px) {
    .modal-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet: 2 colunas */
    }
}
@media (min-width: 1024px) {
    .modal-grid {
        grid-template-columns: repeat(3, 1fr); /* Desktop: 3 colunas (Ideal para muitos campos) */
    }
}


/* --- Accordion Junção (Combo) --- */
#pc-modal-combo[hidden] { display: none !important; }

.combo-accordion {
  border: 1px solid var(--border, #E2E8F0); border-radius: 8px;
  overflow: hidden; margin-top: 12px; background: var(--surface, #fff);
}
.combo-summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface-2, #F1F5F9); cursor: pointer;
  font-weight: 600; color: var(--brand-secondary, #334155); font-size: 0.95rem; transition: background .15s;
}
.combo-summary:hover { background: var(--surface-3, #E2E8F0); }
.combo-summary::-webkit-details-marker { display: none; }

.combo-count { font-weight: 400; color: var(--muted, #64748B); margin-left: 6px; font-size: 0.85rem; }
.combo-chevron {
  display: flex; align-items: center; color: var(--muted, #94A3B8); transition: transform .2s;
}
.combo-accordion[open] .combo-chevron { transform: rotate(180deg); }

.combo-content { padding: 16px; border-top: 1px solid var(--border, #E2E8F0); background: var(--surface, #fff); }

.combo-lista { display: flex; flex-direction: column; gap: 10px; }
.combo-item {
  border: 1px solid var(--border, #E2E8F0); border-radius: 8px; padding: 10px; background: var(--surface-2, #FAFCFF);
}
.combo-item__head {
  display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem; color: var(--brand-secondary, #1E293B);
  border-bottom: 1px solid var(--surface-2, #F1F5F9); padding-bottom: 6px; margin-bottom: 6px;
}
.combo-item__meta {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.combo-item__tag {
  background: var(--surface-3, #E2E8F0); border-radius: 4px; padding: 2px 8px; font-size: 0.75rem; color: var(--brand-secondary, #475569); font-weight: 500;
}

/* --- Footer do Modal --- */
.modal-footer {
    padding: 16px 24px;
    background: var(--surface-2, #F8FAFC);
    border-top: 1px solid var(--border, #E2E8F0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.modal-footer__left { display: flex; align-items: center; gap: 8px; }
.modal-footer__actions { display: flex; gap: 12px; align-items: center; }

/* Botões do Footer */
.modal-footer .btn {
  gap: 8px; padding: 0 20px; height: 44px;
  border-radius: 8px; font-weight: 600; font-size: 0.95rem;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; border: none; text-decoration: none;
}

/* =========================================================
   3. RESPONSIVO (Detalhes)
========================================================= */
@media (max-width: 600px) {
  .top-row-info, .values-row-info {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .modal-footer {
    flex-direction: column-reverse;
    gap: 16px; padding: 16px;
  }
  .modal-footer__actions {
    flex-direction: column; width: 100%;
  }
  .modal-footer__left {
    width: 100%; justify-content: center;
  }
  .modal-footer .btn { width: 100%; }
}

/* =========================================================
   4. MODAL RESERVA
========================================================= */
#reserva-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
#reserva-form .form-row {
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
#reserva-form .form-row.full, 
#reserva-form .form-row:has(textarea) { 
    grid-column: 1 / -1; 
}

#reserva-form label {
  font-size: 0.9rem; font-weight: 600; color: var(--brand-secondary, #334155);
}
#reserva-form input[type="text"],
#reserva-form input[type="tel"],
#reserva-form input[type="email"],
#reserva-form textarea {
  width: 100%;
  border: 1px solid var(--border, #CBD5E1); border-radius: 8px;
  background: var(--surface, #fff); color: var(--brand-secondary, #0F172A);
  padding: 10px 12px; font-size: 0.95rem; outline: none;
  transition: border-color .15s;
}
#reserva-form input:focus,
#reserva-form textarea:focus {
  border-color: var(--brand-primary, #3B82F6); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
#reserva-form textarea { min-height: 100px; resize: vertical; }

#reserva-feedback {
  grid-column: 1 / -1; margin-top: 8px; padding: 12px;
  border-radius: 8px; display: none; font-size: 0.9rem;
}
#reserva-feedback.is-visible { display: block; }
#reserva-feedback.is-error { background: var(--danger, #FEF2F2); color: var(--danger, #B91C1C); border: 1px solid var(--danger, #FECACA); }
#reserva-feedback.is-success { background: var(--success, #F0FDF4); color: var(--success, #15803D); border: 1px solid var(--success, #BBF7D0); }

@media (max-width: 600px) {
  #reserva-form { grid-template-columns: 1fr; }
}

/* =========================================================
   5. MODAL FILTROS
========================================================= */
.cl-no-scroll { overflow: hidden; }

.cotas-modal {
  position: fixed; inset: 0;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}
.cotas-modal.is-open {
  opacity: 1;
  visibility: visible;
}
.cotas-modal__backdrop {
  position: absolute; inset: 0;
  /* Sem backdrop-filter:blur — é o maior gargalo de GPU em transições CSS */
  background: rgba(10, 22, 42, 0.72);
}
.cotas-modal__dialog {
  position: relative; max-width: 500px; width: 90%;
  margin: 48px auto; background: var(--surface, #FFF);
  border-radius: 16px;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.22);
  padding: 0;
  overflow: hidden;
  /* Apenas translateY — scale() força layout recalc em alguns browsers */
  transform: translateY(14px);
  transition: transform 0.14s ease;
  will-change: transform;
}
.cotas-modal.is-open .cotas-modal__dialog {
  transform: translateY(0);
}

/* --- Header --- */
.cotas-modal__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border, #d6e5ec);
  background: var(--surface-2, #F8FBFF);
}
.cotas-modal__header h2 {
  font-size: 1rem; font-weight: 700; margin: 0;
  color: var(--brand-secondary, #0A2A54);
  letter-spacing: -0.01em;
}
.cotas-modal__close {
  background: var(--surface-3, #EFF6FB);
  border: 1px solid var(--border, #d6e5ec);
  border-radius: 50%;
  width: 30px; height: 30px;
  cursor: pointer; color: var(--muted, #6B7280);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.cotas-modal__close:hover {
  background: var(--border, #d6e5ec);
  color: var(--brand-secondary, #0A2A54);
}

/* --- Body --- */
.cotas-modal__body {
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
  max-height: calc(90vh - 160px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cotas-modal__form { display: contents; }

.cotas-filter-field { display: flex; flex-direction: column; gap: 5px; }
.cotas-filter-field label {
  font-size: 0.75rem; font-weight: 700;
  color: var(--muted, #6B7280);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.cotas-filter-field input,
.cotas-filter-field select {
  border: 1.5px solid var(--border, #d6e5ec);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  background: var(--surface, #fff);
  color: var(--brand-secondary, #0A2A54);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.cotas-filter-field 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='%236B7280' 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;
}
.cotas-filter-field input:focus,
.cotas-filter-field select:focus {
  border-color: var(--brand-primary, #22B2D6);
  box-shadow: 0 0 0 3px rgba(34, 178, 214, 0.14);
}
.cotas-filter-field--inline { display: flex; flex-direction: row; gap: 12px; }
.cotas-filter-field--inline > div { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.cotas-filter-field--inline label {
  font-size: 0.75rem; font-weight: 700;
  color: var(--muted, #6B7280);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Crédito: faixa mín / máx com prefixo R$ */
.cotas-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.cotas-filter-field--credito-range {
  gap: 8px;
}
.cotas-credito-range__title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted, #6B7280);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cotas-credito-range__shell {
  border: 1.5px solid var(--border, #d6e5ec);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface, #fff);
}
.cotas-filter-field--credito-range.has-error .cotas-credito-range__shell {
  border-color: #e24b4a;
}
.cotas-credito-range__row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
}
.cotas-credito-range__group {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cotas-credito-range__de,
.cotas-credito-range__ate {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted, #6B7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cotas-credito-range__ate {
  display: none;
}
.cotas-credito-range__dash {
  flex: 0 0 auto;
  padding-bottom: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted, #6B7280);
  line-height: 1;
}
.cotas-credito-range__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border, #d6e5ec);
  border-radius: 8px;
  background: var(--surface, #fff);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cotas-filter-field--credito-range .cotas-credito-range__input-wrap input {
  border: none;
  border-radius: 8px;
  padding: 10px 12px 10px 6px;
  margin: 0;
  flex: 1;
  min-width: 0;
  background: transparent;
  box-shadow: none;
}
.cotas-filter-field--credito-range .cotas-credito-range__input-wrap input:focus {
  outline: none;
  box-shadow: none;
}
.cotas-credito-range__input-wrap:focus-within {
  border-color: var(--brand-primary, #22B2D6);
  box-shadow: 0 0 0 3px rgba(34, 178, 214, 0.14);
}
.cotas-credito-range__currency {
  flex-shrink: 0;
  padding-left: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted, #6B7280);
}
.cotas-filter-field--credito-range.has-error .cotas-credito-range__input-wrap--invalid,
.cotas-filter-field--credito-range.has-error .cotas-credito-range__input-wrap--invalid:focus-within {
  border-color: #e24b4a;
  box-shadow: none;
}
.cotas-credito-range__error {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e24b4a;
}
.cotas-credito-range__error[hidden] {
  display: none !important;
}
.cotas-filter-apply:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
  pointer-events: none;
}
.cotas-filter-apply:disabled:hover {
  transform: none;
  filter: none;
  box-shadow: none;
}

@media (max-width: 479px) {
  .cotas-credito-range__row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .cotas-credito-range__dash {
    display: none;
  }
  .cotas-credito-range__ate {
    display: block;
  }
  .cotas-credito-range__group--max .cotas-credito-range__ate {
    order: -1;
  }
  .cotas-credito-range__group {
    align-items: stretch;
  }
  .cotas-credito-range__de {
    margin-bottom: 0;
  }
}

/* --- Footer --- */
.cotas-modal__footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border, #d6e5ec);
  background: var(--surface-2, #F8FBFF);
}
.cotas-modal__footer-left { display: flex; align-items: center; }
.cotas-modal__footer-right { display: flex; align-items: center; gap: 8px; }

/* Botao Aplicar — destaque principal */
.cotas-filter-apply {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px;
  padding: 10px 22px;
  font-size: 0.9rem; font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #1E9EC0, var(--brand-primary, #22B2D6));
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 178, 214, 0.30);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.cotas-filter-apply:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 178, 214, 0.42);
  filter: brightness(1.05);
}
.cotas-filter-apply:active { transform: none; filter: brightness(0.96); }

/* Botao Limpar — secundario discreto, hover vermelho */
.cotas-filter-reset {
  display: inline-flex; align-items: center;
  background: none;
  border: 1.5px solid var(--border, #d6e5ec);
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.82rem; font-weight: 600;
  color: var(--muted, #6B7280);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.cotas-filter-reset:hover {
  border-color: var(--danger, #C63D39);
  color: var(--danger, #C63D39);
  background: rgba(198, 61, 57, 0.05);
}

/* Botao Fechar — ghost neutro */
.cotas-modal__btn-fechar {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px solid var(--border, #d6e5ec);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.88rem; font-weight: 600;
  color: var(--brand-secondary, #0A2A54);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cotas-modal__btn-fechar:hover {
  background: var(--surface-3, #EFF6FB);
  border-color: #c8d4e0;
}

@media (max-width: 480px) {
  .cotas-modal__footer {
    flex-direction: column-reverse; gap: 10px; padding: 14px 16px;
  }
  .cotas-modal__footer-left,
  .cotas-modal__footer-right { width: 100%; }
  .cotas-modal__footer-right { flex-direction: column-reverse; }
  .cotas-filter-apply,
  .cotas-modal__btn-fechar,
  .cotas-filter-reset { width: 100%; justify-content: center; }
  .cotas-modal__body { padding: 16px; }
  .cotas-modal__header { padding: 16px; }
}

