/* style.css - Estilos visuais, tela de senha e regras de impressao A4 */

:root {
  --primary: #1e293b;
  --primary-hover: #0f172a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --border-color: #cbd5e1;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================
   TELA DE BLOQUEIO POR SENHA (LOGIN 1251)
   ======================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 16px;
}

.login-box {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-badge {
  display: inline-block;
  background: #facc15;
  color: #854d0e;
  font-weight: 900;
  font-size: 1.5rem;
  padding: 10px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  border: 2px solid #eab308;
}

.login-badge-img {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.logo-badge-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  object-fit: cover;
  border: 1px solid #cbd5e1;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 0.88rem;
  color: #64748b;
  margin-bottom: 24px;
}

.login-form {
  text-align: left;
}

.login-form input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 700;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.login-form input[type="password"]:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.login-error {
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 10px;
  text-align: center;
  border: 1px solid #fecaca;
}

/* ========================================================
   CABECALHO E LAYOUT PRINCIPAL
   ======================================================== */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: #facc15;
  color: #854d0e;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  border: 1px solid #eab308;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.main-layout {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
}

@media (max-width: 1080px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* ========================================================
   FORMULARIO
   ======================================================== */
.form-panel {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  height: fit-content;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: #0f172a;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  transition: all 0.2s;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px 0;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.checkbox-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

input.input-valido {
  border-color: #16a34a !important;
  background-color: #f0fdf4 !important;
}

input.input-invalido {
  border-color: #dc2626 !important;
  background-color: #fef2f2 !important;
}

.doc-feedback {
  font-size: 0.76rem;
  font-weight: 600;
  margin-top: 4px;
  min-height: 16px;
  display: block;
  transition: all 0.2s ease;
}

.doc-feedback.valido {
  color: #15803d;
}

.doc-feedback.invalido {
  color: #b91c1c;
}


/* ========================================================
   PREVIEW DA NOTA PROMISSORIA
   ======================================================== */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.preview-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-carne {
  background: #e0e7ff;
  color: #3730a3;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.parcelas-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.nav-arrow-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  color: #1e293b;
}

.nav-arrow-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.seletor-parcelas {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  max-width: 480px;
  padding: 4px 2px;
}

.btn-parcela {
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-parcela:hover {
  border-color: #94a3b8;
}

.btn-parcela.ativo {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.preview-svg-container {
  width: 100%;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-svg-container svg {
  width: 100%;
  max-width: 860px;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
}

/* ========================================================
   BOTOES
   ======================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #15803d;
  box-shadow: 0 4px 8px rgba(22, 163, 74, 0.25);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: transparent;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.btn-outline:hover {
  background: #f8fafc;
  color: #0f172a;
}

.btn-install {
  background: #0f766e;
  color: #ffffff;
  border: 1px solid #115e59;
}

.btn-install:hover {
  background: #115e59;
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.3);
}

@keyframes piscarVermelhoAlerta {
  0%, 100% {
    background-color: #dc2626 !important;
    border-color: #b91c1c !important;
    color: #ffffff !important;
    box-shadow: 0 0 18px rgba(220, 38, 38, 0.9) !important;
    transform: scale(1.06);
  }
  50% {
    background-color: #991b1b !important;
    border-color: #7f1d1d !important;
    color: #ffffff !important;
    box-shadow: 0 0 4px rgba(220, 38, 38, 0.3) !important;
    transform: scale(1);
  }
}

.btn-piscar-alerta {
  animation: piscarVermelhoAlerta 0.45s ease-in-out infinite !important;
}

.btn-danger-sm {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-sm:hover {
  background: #fecaca;
}

.btn-action-sm {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-action-sm:hover {
  background: #c7d2fe;
}

.info-box {
  background: #fefce8;
  border: 1px solid #fef08a;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: #713f12;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
}

/* ========================================================
   MODAL DE HISTORICO
   ======================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-box {
  background: #ffffff;
  border-radius: 16px;
  width: 95%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid #e2e8f0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-fechar {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}

.btn-fechar:hover {
  color: #0f172a;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-search {
  margin-bottom: 16px;
}

.modal-search input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  outline: none;
}

.tabela-container {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.tabela-historico {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tabela-historico th,
.tabela-historico td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}

.tabela-historico th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.tabela-historico tr:hover {
  background: #f8fafc;
}

.tabela-historico td.col-data,
.tabela-historico th.col-data {
  white-space: nowrap;
}

.tabela-historico td.col-emitente,
.tabela-historico th.col-emitente {
  white-space: nowrap;
}

.tabela-historico td.col-acoes,
.tabela-historico th.col-acoes {
  white-space: nowrap;
  width: 160px;
}

.acoes-botoes-container {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-action-sm {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-action-sm:hover {
  background: #dbeafe;
  color: #1e40af;
}

.btn-danger-sm {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-danger-sm:hover {
  background: #fee2e2;
  color: #991b1b;
}


/* ========================================================
   TOAST DE NOTIFICACAO
   ======================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 10000;
  animation: slideUp 0.3s ease-out;
}

.toast.sucesso {
  background: #16a34a;
}

.toast.erro {
  background: #dc2626;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================================
   REGRAS DE IMPRESSAO EM FOLHA A4 (3 NOTAS POR PAGINA)
   ======================================================== */
#area-impressao {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }

  body {
    background: transparent !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .login-overlay,
  #modal-historico,
  .app-header,
  .main-layout,
  footer,
  .toast {
    display: none !important;
  }

  #area-impressao {
    display: block !important;
    width: 190mm !important;
    max-width: 190mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  .item-impressao-nota {
    width: 190mm !important;
    max-width: 190mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .nota-svg-wrapper {
    width: 190mm !important;
    max-width: 190mm !important;
    height: 87mm !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 auto !important;
  }

  .nota-svg-wrapper svg {
    width: 190mm !important;
    max-width: 190mm !important;
    height: 87mm !important;
    display: block !important;
  }

  .linha-corte-a4 {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    height: 5mm !important;
    margin: 0.5mm auto !important;
    width: 190mm !important;
    color: #475569 !important;
    font-size: 10pt !important;
  }

  .icone-tesoura {
    font-size: 12pt !important;
    line-height: 1 !important;
  }

  .traco-pontilhado {
    flex: 1 !important;
    border-bottom: 1.5px dashed #64748b !important;
    height: 1px !important;
  }

  .quebra-de-pagina-a4 {
    page-break-after: always !important;
    break-after: page !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}
