/* ============================================================
   ESTILOS GERAIS DO MODAL (Sem Tailwind)
   ============================================================ */
body.modal-body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  color: #1e293b;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  user-select: none;
  overflow: hidden;
}

/* Responsividade Body */
@media (min-width: 768px) {
  body.modal-body {
    justify-content: center;
    padding: 12px;
  }
}

@media (min-width: 1024px) {
  body.modal-body {
    padding: 16px;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* ============================================================
   CONTAINER DO MODAL
   ============================================================ */
.modal-container {
  width: 100%;
  height: 100%;
  background-color: #f0f4f9;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

@media (min-width: 768px) {
  .modal-container {
    height: 92vh;
    max-height: 920px;
    max-width: 1520px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, 0.4);
  }
}


/* ============================================================
   HEADER DO MODAL
   ============================================================ */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background-color: #15529f;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.header-top {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(37, 99, 235, 0.4);
}

@media (min-width: 640px) {
  .header-top {
    padding: 10px 16px;
  }
}

.header-title-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-icon {
  padding: 4px;
  border-radius: 4px;
  background-color: rgba(37, 99, 235, 0.6);
  color: #bae6fd;
  flex-shrink: 0;
}

.header-icon svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}

@media (min-width: 640px) {
  .header-icon svg { width: 20px; height: 20px; }
}

#modal-headline {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}

@media (min-width: 640px) { #modal-headline { font-size: 14px; } }
@media (min-width: 768px) { #modal-headline { font-size: 16px; } }

.btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 0;
  background-color: rgba(29, 78, 216, 0.6);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-close:hover {
  background-color: #dc2626;
  color: white;
}

.btn-close:active { transform: scale(0.95); }
.btn-close svg { width: 16px; height: 16px; stroke-width: 2.5; }

/* Sub-Header (Pesquisa e Botões) */
.header-bottom {
  padding: 8px 12px;
  background-color: #0e4487;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

@media (min-width: 640px) {
  .header-bottom {
    padding: 8px 16px;
    flex-direction: row;
    align-items: center;
  }
}

.search-wrapper {
  position: relative;
  width: 100%;
}

@media (min-width: 640px) { .search-wrapper { max-width: 320px; } }
@media (min-width: 768px) { .search-wrapper { max-width: 384px; } }

.search-icon {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  display: flex;
  align-items: center;
  padding-left: 10px;
  color: #93c5fd;
  pointer-events: none;
}

.search-icon svg { width: 14px; height: 14px; }

.search-input {
  width: 100%;
  padding: 4px 12px 4px 32px;
  background-color: rgba(2, 6, 23, 0.7);
  color: white;
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 4px;
  font-size: 12px;
  outline: none;
  transition: box-shadow 0.2s;
  box-sizing: border-box;
}

.search-input::placeholder { color: rgba(147, 197, 253, 0.8); }
.search-input:focus {
  box-shadow: 0 0 0 2px #38bdf8;
  border-color: transparent;
}

.action-buttons-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

@media (min-width: 640px) { .action-buttons-wrapper { padding-bottom: 0; } }

.btn-action {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background-color: #1d4ed8;
  color: white;
  border: 1px solid rgba(96, 165, 250, 0.3);
}
.btn-primary:hover { background-color: #2563eb; }
.btn-primary:active { background-color: #1e40af; }

.btn-secondary {
  background-color: rgba(30, 64, 175, 0.9);
  color: #dbeafe;
  border: 1px solid rgba(59, 130, 246, 0.3);
}
.btn-secondary:hover { background-color: #1d4ed8; }
.btn-secondary:active { background-color: #1e3a8a; }

.btn-tertiary {
  background-color: #0284c7;
  color: white;
  border: 0;
}
.btn-tertiary:hover { background-color: #0ea5e9; }
.btn-tertiary:active { background-color: #0369a1; }


/* ============================================================
   CORPO PRINCIPAL (Main Content)
   ============================================================ */
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background-color: #f0f4f9;
  overscroll-behavior: contain;
}

@media (min-width: 640px) { .modal-content { padding: 14px; } }

.systems-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

@media (min-width: 768px) { .systems-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .systems-grid { grid-template-columns: repeat(3, 1fr); } }

.systems-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}


/* ============================================================
   CARDS DE SISTEMAS E ACCORDIONS
   ============================================================ */
.system-card {
  background-color: white;
  border: 1px solid #2b75be;
  border-radius: 4px;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.accordion-header {
  background-color: white;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.2s;
}

.accordion-header:hover { background-color: rgba(239, 246, 255, 0.5); }
.accordion-header.has-border { border-bottom: 1px solid #dbeafe; }

.system-title-wrapper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #0c4a8f;
}

@media (min-width: 640px) { .checkbox-label { font-size: 14px; } }


/* Controle de Quantidade */
.qtd-wrapper {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(56, 189, 248, 0.8);
  border-radius: 4px;
  background-color: rgba(240, 249, 255, 0.5);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.qtd-wrapper.white-bg { background-color: white; }

.btn-qtd {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: #075985;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-qtd:hover { background-color: rgba(186, 230, 253, 0.7); }
.btn-qtd:active { background-color: #7dd3fc; }

.input-qtd {
  width: 32px;
  height: 20px;
  padding: 0 2px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #1e3a8a;
  border: 0;
  background: transparent;
  outline: none;
}


/* Botão e Ícone de Expansão */
.toggle-btn {
  padding: 4px;
  background: transparent;
  border: 0;
  color: #0c4a8f;
  cursor: pointer;
}

.toggle-btn svg, .toggle-icon {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
  stroke-width: 2.5;
}

.hidden { display: none !important; }


/* ============================================================
   CONTEÚDO DOS CARDS E SUBMÓDULOS
   ============================================================ */
.accordion-content {
  padding: 8px;
}

.accordion-content.direct-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.accordion-content.direct-list-spaced {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.accordion-content.border-top {
  border-top: 1px solid #dbeafe;
}

/* Sub-Módulos */
.sub-module-box {
  border: 1px solid #4ba3e3;
  border-radius: 4px;
  background-color: white;
  margin-bottom: 8px;
  overflow: hidden;
}

.sub-module-box:last-child { margin-bottom: 0; }

.sub-module-header {
  background-color: #dcecfa;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #a9d4f5;
  cursor: pointer;
}

.sub-module-header .checkbox-label {
  font-size: 12px;
  gap: 6px;
}

.sub-module-header .toggle-icon { color: #0c4a8f; }

.sub-module-grid {
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 8px;
  row-gap: 2px;
}

@media (min-width: 640px) { .sub-module-grid { grid-template-columns: repeat(2, 1fr); } }

.sub-module-column {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sub-module-list {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}


/* Itens de Checkbox Genéricos */
.sub-item-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  cursor: pointer;
  font-size: 10.5px;
  color: #334155;
}

.sub-item-label:hover { color: #1d4ed8; }

.font-medium { font-weight: 500; }

/* Item Especial (Ex: Gourmet Mobile) */
.special-item-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 8px;
  background-color: rgba(240, 249, 255, 0.6);
  border: 1px solid #e0f2fe;
  border-radius: 4px;
}

.special-label {
  font-weight: 500;
  color: #1e293b;
  font-size: 12px;
}


/* ============================================================
   FOOTER FIXO (Ações e Contadores)
   ============================================================ */
.modal-footer {
  background-color: white;
  border-top: 1px solid #cbd5e1;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  z-index: 20;
  flex-shrink: 0;
}

@media (min-width: 640px) { .modal-footer { padding: 10px 20px; } }

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (min-width: 640px) { .footer-content { flex-direction: row; } }

.footer-counters {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #10b981;
  flex-shrink: 0;
}

.counter-highlight {
  color: #1e40af;
  font-weight: 700;
  background-color: #eff6ff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #bfdbfe;
  font-size: 12px;
}

.counter-separator { color: #94a3b8; }
.counter-total { color: #475569; }

.footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

@media (min-width: 640px) { .footer-actions { width: auto; } }

.btn-cancel {
  flex: 1;
  padding: 6px 16px;
  background-color: white;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #334155;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: background-color 0.2s;
}

@media (min-width: 640px) { .btn-cancel { flex: none; } }

.btn-cancel:hover { background-color: #f1f5f9; }
.btn-cancel:active { background-color: #e2e8f0; }

.btn-confirm {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 20px;
  background-color: #2563eb;
  color: white;
  border: 0;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.2s;
}

@media (min-width: 640px) { .btn-confirm { flex: none; } }

.btn-confirm:hover {
  background-color: #1d4ed8;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.btn-confirm:active {
  background-color: #1e40af;
  transform: scale(0.95);
}

.btn-confirm svg { width: 14px; height: 14px; stroke-width: 3; }


/* ============================================================
   ESTILOS LOCAIS — COMPONENTES
   ============================================================ */

/* Checkbox personalizado */
.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border: 1.5px solid #0284c7;
  border-radius: 3px;
  outline: none;
  transition: all .15s ease-in-out;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  background: #fff;
  flex-shrink: 0;
}
.custom-checkbox:checked,
.custom-checkbox:indeterminate { background: #0284c7; border-color: #0284c7; }
.custom-checkbox:checked::before {
  content: ''; width: 8px; height: 4.5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(.5px, -.5px);
}
.custom-checkbox:indeterminate::before {
  content: ''; width: 8px; height: 2px; background: #fff;
}
.custom-checkbox:focus-visible { box-shadow: 0 0 0 2px rgba(2,132,199,.35); }

/* Remove setas nativas dos campos numéricos */
input[type='number'] { -moz-appearance: textfield; }
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }