/* =========================================================
   1. MODAL GENÉRICO (Estrutura Base)
========================================================= */
.pc-modal, .modal {
  position: fixed; inset: 0; z-index: 9999; /* Z-index alto para ficar acima de tudo */
  display: flex; align-items: center; justify-content: center;
}
.pc-modal[hidden], .modal[hidden] { display: none !important; }

.modal-backdrop, .pc-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.6); /* Cor Slate escura */
  backdrop-filter: blur(4px);
}

.modal-content.pc-modal-content {
  box-sizing: border-box;
  display: flex; flex-direction: column;
  position: relative; z-index: 10;
  max-width: 600px; /* Levemente mais largo para acomodar 3 colunas */
  width: 95%;
  max-height: 90vh;
  background: var(--surface, #fff);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(10px);
  opacity: 0;
  animation: modalSlideIn 0.2s ease-out forwards;
  padding: 0; 
  overflow: hidden; 
}

@keyframes modalSlideIn {
    to { transform: translateY(0); 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; display: none; z-index: 9999;
}
.cotas-modal.is-open { display: block; }
.cotas-modal__backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(2px);
}
.cotas-modal__dialog {
  position: relative; max-width: 500px; width: 90%;
  margin: 60px auto; background: var(--surface, #FFF);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 24px;
  transform: translateY(20px); opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.cotas-modal.is-open .cotas-modal__dialog {
  transform: translateY(0); opacity: 1;
}

.cotas-modal__header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
}
.cotas-modal__header h2 { 
  font-size: 1.1rem; font-weight: 700; margin: 0; color: var(--brand-secondary, #1E293B);
}
.cotas-modal__close {
  background: var(--surface-2, #F1F5F9); border: none; border-radius: 50%;
  width: 28px; height: 28px; cursor: pointer; color: var(--muted, #64748B);
  display: inline-flex; align-items: center; justify-content: center;
}

.cotas-modal__form { display: flex; flex-direction: column; gap: 16px; }
.cotas-filter-field { display: flex; flex-direction: column; gap: 6px; }
.cotas-filter-field label { font-size: 0.85rem; font-weight: 600; color: var(--brand-secondary, #334155); }
.cotas-filter-field input, .cotas-filter-field select {
  border: 1px solid var(--border, #CBD5E1); border-radius: 6px;
  padding: 10px; font-size: 0.9rem; outline: none; background: var(--surface, #fff);
}
.cotas-filter-field--inline { display: flex; gap: 12px; }
.cotas-filter-field--inline > div { flex: 1; }

.cotas-modal__footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border, #E2E8F0);
}
.cotas-filter-apply {
  border: none; border-radius: 6px; padding: 10px 24px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  background: var(--brand-primary, #2563EB); color: var(--surface, #FFF); transition: background .15s;
}
.cotas-filter-apply:hover { background: var(--brand-primary, #1D4ED8); }

.cotas-filter-reset {
  background: none; border: none; color: var(--muted, #64748B);
  font-size: 0.85rem; cursor: pointer; text-decoration: underline;
}
.cotas-filter-reset:hover { color: var(--brand-secondary, #0F172A); }
