/* Reset e configurações gerais */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
  color: #e0f7ff;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

/* Efeitos de fundo tecnológico - OCULTAR NO PDF */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(44, 123, 229, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(100, 255, 218, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(155, 81, 224, 0.1) 0%, transparent 50%);
  z-index: -1;
  animation: pulse 20s ease-in-out infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

/* Container principal futurista - COMPACTO */
.box {
  max-width: 480px; /* Reduzido de 520px */
  margin: 15px auto;
  background: rgba(16, 24, 40, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px; /* Reduzido de 30px */
  border-radius: 16px; /* Reduzido de 20px */
  border: 1px solid rgba(100, 255, 218, 0.2);
  box-shadow: 
    0 15px 30px rgba(0, 0, 0, 0.3),
    0 0 60px rgba(44, 123, 229, 0.08),
    inset 0 0 15px rgba(100, 255, 218, 0.05);
  position: relative;
  overflow: hidden;
}

/* Remover efeito hover no PDF */
@media screen {
  .box {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  
  .box:hover {
    transform: translateY(-3px);
    box-shadow: 
      0 20px 40px rgba(0, 0, 0, 0.4),
      0 0 80px rgba(44, 123, 229, 0.12),
      inset 0 0 20px rgba(100, 255, 218, 0.08);
  }
}

.box::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, 
    rgba(44, 123, 229, 0.4),
    rgba(100, 255, 218, 0.4),
    rgba(155, 81, 224, 0.4),
    rgba(44, 123, 229, 0.4));
  border-radius: 18px;
  z-index: -1;
  animation: borderGlow 3s linear infinite;
  background-size: 400% 400%;
}

@keyframes borderGlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Título mais compacto */
h1 {
  text-align: center;
  margin-bottom: 20px; /* Reduzido de 30px */
  font-size: 24px; /* Reduzido de 28px */
  font-weight: 700;
  background: linear-gradient(90deg, #2c7be5, #64ffda);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  padding-bottom: 10px; /* Reduzido de 15px */
}

h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px; /* Reduzido de 100px */
  height: 2px; /* Reduzido de 3px */
  background: linear-gradient(90deg, transparent, #64ffda, transparent);
  border-radius: 2px;
}

/* Labels mais compactos */
label {
  display: block;
  margin-top: 15px; /* Reduzido de 20px */
  font-weight: 600;
  font-size: 13px; /* Reduzido de 14px */
  color: #a0c8ff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px; /* Reduzido de 8px */
}

/* Inputs e selects mais compactos */
input, select {
  width: 100%;
  padding: 10px 12px; /* Reduzido de 14px 16px */
  margin-top: 4px; /* Reduzido de 6px */
  border-radius: 8px; /* Reduzido de 10px */
  border: 1px solid rgba(100, 255, 218, 0.2);
  background: rgba(16, 24, 40, 0.9);
  color: #e0f7ff;
  font-size: 14px; /* Reduzido de 16px */
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:focus, select:focus {
  outline: none;
  border-color: #64ffda;
  box-shadow: 
    0 0 0 2px rgba(100, 255, 218, 0.15),
    inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Parâmetros avançados mais compactos */
.parametros-avancados {
  margin-top: 20px; /* Reduzido de 24px */
  background: rgba(16, 24, 40, 0.7);
  border-radius: 10px; /* Reduzido de 12px */
  border: 1px solid rgba(100, 255, 218, 0.15);
  padding: 15px; /* Reduzido de 20px */
  position: relative;
  overflow: hidden;
}

.parametros-avancados::before {
  content: '⚙️';
  position: absolute;
  top: 15px; /* Ajustado */
  left: 15px; /* Ajustado */
  font-size: 16px; /* Reduzido de 18px */
}

.parametros-avancados label {
  margin-left: 25px; /* Reduzido de 30px */
  margin-top: 12px; /* Ajustado */
}

.parametros-avancados .linha {
  margin-left: 25px; /* Reduzido de 30px */
}

.parametros-avancados h3 {
  color: #64ffda;
  margin-bottom: 15px; /* Reduzido de 20px */
  padding-left: 25px; /* Reduzido de 30px */
  font-size: 14px; /* Reduzido de 16px */
}

/* Layout de linha ajustado */
.linha {
  display: flex;
  gap: 10px; /* Reduzido de 12px */
  align-items: center;
  flex-wrap: wrap;
}

.linha input {
  flex: 1;
  min-width: 0;
}

.linha button {
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 110px; /* Reduzido de 120px */
  padding: 10px 12px; /* Reduzido de 14px 16px */
  font-size: 13px; /* Reduzido de 14px */
}

/* Botões mais compactos */
button {
  padding: 12px 18px; /* Reduzido de 16px 24px */
  border: none;
  border-radius: 8px; /* Reduzido de 10px */
  background: linear-gradient(135deg, #2c7be5 0%, #6a11cb 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px; /* Reduzido de 16px */
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Efeito hover apenas para tela */
@media screen {
  button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: 0.5s;
  }
  
  button:hover::before {
    left: 100%;
  }
  
  button:hover {
    transform: translateY(-2px);
    box-shadow: 
      0 8px 16px rgba(44, 123, 229, 0.25),
      0 0 20px rgba(100, 255, 218, 0.15);
  }
}

button:active {
  transform: translateY(0);
}

#btn-cdi-api {
  background: linear-gradient(135deg, #9b51e0 0%, #bb6bd9 100%);
}

#btn-ipca-api {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  min-width: 110px;
}

#btn-calcular {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
}

#btn-pdf {
  background: linear-gradient(135deg, #e74c3c 0%, #e67e22 100%);
}

/* Área de ações mais compacta */
.acoes {
  display: flex;
  gap: 12px; /* Reduzido de 15px */
  margin-top: 25px; /* Reduzido de 30px */
}

/* Resultados mais compactos */
#res {
  margin-top: 20px; /* Reduzido de 25px */
  background: rgba(16, 24, 40, 0.8);
  padding: 18px; /* Reduzido de 24px */
  border-radius: 12px; /* Reduzido de 15px */
  border: 1px solid rgba(100, 255, 218, 0.15);
  box-shadow: 
    inset 0 0 15px rgba(0, 0, 0, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

#res::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px; /* Reduzido de 5px */
  height: 100%;
  background: linear-gradient(to bottom, #2c7be5, #64ffda);
}

/* Aviso */
.aviso {
  display: block;
  margin-top: 15px; /* Reduzido de 20px */
  font-size: 11px; /* Reduzido de 12px */
  color: #8a9ba8;
  text-align: center;
  padding: 10px; /* Reduzido de 12px */
  background: rgba(16, 24, 40, 0.6);
  border-radius: 6px; /* Reduzido de 8px */
  border: 1px solid rgba(139, 92, 246, 0.08);
}

/* Footer */
.footer {
  margin-top: 30px; /* Reduzido de 40px */
  text-align: center;
  padding: 15px; /* Reduzido de 20px */
  position: relative;
}

.footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 180px; /* Reduzido de 200px */
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(100, 255, 218, 0.25), transparent);
}

.footer a {
  color: #64ffda;
  text-decoration: none;
  font-size: 13px; /* Reduzido de 14px */
  transition: all 0.2s ease;
  padding: 6px 12px; /* Reduzido de 8px 16px */
  border-radius: 5px; /* Reduzido de 6px */
  display: inline-block;
}

@media screen {
  .footer a:hover {
    color: #fff;
    background: rgba(100, 255, 218, 0.1);
    transform: translateY(-1px);
  }
}

/* ==================== ESTILOS DE IMPRESSÃO/PDF (CRÍTICO) ==================== */
@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
  
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 12px !important;
    min-height: auto !important;
    overflow: visible !important;
  }
  
  body::before,
  .box::before,
  h1::after,
  #res::before,
  .footer::before,
  button::before {
    display: none !important;
  }
  
  .box {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    border: 1px solid #cccccc !important;
    box-shadow: none !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    border-radius: 8px !important;
    position: static !important;
    transform: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  
  h1 {
    background: #000000 !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: #000000 !important;
    background-clip: initial !important;
    font-size: 18px !important;
    margin-bottom: 15px !important;
    text-align: center !important;
  }
  
  label {
    color: #333333 !important;
    font-weight: 600 !important;
    margin-top: 10px !important;
    font-size: 11px !important;
  }
  
  input, select {
    background: #f8f8f8 !important;
    color: #000000 !important;
    border: 1px solid #dddddd !important;
    box-shadow: none !important;
    pointer-events: none !important;
    padding: 6px 8px !important;
    font-size: 12px !important;
    border-radius: 4px !important;
  }
  
  .parametros-avancados {
    background: #f0f0f0 !important;
    border: 1px solid #dddddd !important;
    margin-top: 12px !important;
    padding: 10px !important;
    border-radius: 6px !important;
  }
  
  .parametros-avancados::before {
    display: none !important;
  }
  
  .parametros-avancados label,
  .parametros-avancados .linha,
  .parametros-avancados h3 {
    margin-left: 0 !important;
    padding-left: 0 !important;
  }
  
  .parametros-avancados h3 {
    color: #000000 !important;
    font-size: 12px !important;
    margin-bottom: 10px !important;
  }
  
  .linha {
    gap: 8px !important;
  }
  
  button, .footer, .aviso, 
  .btn-loading, .status-mensagem {
    display: none !important;
  }
  
  #res {
    background: #f9f9f9 !important;
    border: 1px solid #dddddd !important;
    box-shadow: none !important;
    margin-top: 15px !important;
    padding: 12px !important;
    border-radius: 6px !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  
  #res p {
    margin-bottom: 5px !important;
    line-height: 1.3 !important;
    font-size: 11px !important;
  }
  
  /* Garantir que tudo caiba em uma página A4 */
  html, body {
    height: auto !important;
    overflow: visible !important;
  }
  
  .conteudo-pdf {
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 8px !important;
  }
}

/* Classe especial para exportação PDF via script */
.pdf-export {
  padding: 15px !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  background: white !important;
  color: black !important;
}

.pdf-export h1 {
  font-size: 18px !important;
  margin-bottom: 15px !important;
  color: black !important;
}

.pdf-export label {
  font-size: 11px !important;
  margin-top: 10px !important;
  color: #333 !important;
}

.pdf-export input, .pdf-export select {
  padding: 6px 8px !important;
  font-size: 12px !important;
  background: #f8f8f8 !important;
  color: black !important;
  border: 1px solid #ccc !important;
}

.pdf-export .parametros-avancados {
  padding: 10px !important;
  margin-top: 12px !important;
  background: #f0f0f0 !important;
}

.pdf-export #res {
  padding: 12px !important;
  margin-top: 15px !important;
  background: #f9f9f9 !important;
}

/* Loading states (apenas tela) */
@media screen {
  .btn-loading {
    position: relative;
    color: transparent !important;
    opacity: 0.8;
  }
  
  .btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px; /* Reduzido de 20px */
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  
  @keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
  }
}

/* Mensagens de status (apenas tela) */
@media screen {
  .status-mensagem {
    position: fixed;
    top: 15px; /* Ajustado */
    right: 15px; /* Ajustado */
    padding: 12px 16px; /* Reduzido */
    background: rgba(16, 24, 40, 0.95);
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px; /* Reduzido */
    color: #64ffda;
    font-size: 13px; /* Reduzido */
    z-index: 1000;
    animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-out 2.7s forwards;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    max-width: 280px; /* Reduzido */
  }
  
  @keyframes slideIn {
    from {
      transform: translateX(100%);
      opacity: 0;
    }
    to {
      transform: translateX(0);
      opacity: 1;
    }
  }
  
  @keyframes fadeOut {
    to {
      opacity: 0;
      transform: translateY(-15px);
    }
  }
}

/* Indicador de dados atualizados (apenas tela) */
@media screen {
  .dados-atualizados {
    position: relative;
  }
  
  .dados-atualizados::after {
    content: '✓';
    position: absolute;
    right: 8px; /* Ajustado */
    top: 50%;
    transform: translateY(-50%);
    color: #27ae60;
    font-weight: bold;
    font-size: 14px; /* Reduzido de 16px */
    animation: checkFade 0.5s ease forwards;
  }
  
  @keyframes checkFade {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

/* Responsividade */
@media (max-width: 600px) {
  body {
    padding: 8px; /* Ajustado */
  }
  
  .box {
    padding: 15px; /* Ajustado */
    margin: 8px auto; /* Ajustado */
    border-radius: 12px; /* Ajustado */
  }
  
  h1 {
    font-size: 20px; /* Ajustado */
    margin-bottom: 15px; /* Ajustado */
  }
  
  .acoes {
    flex-direction: column;
    gap: 8px; /* Ajustado */
    margin-top: 20px; /* Ajustado */
  }
  
  button {
    padding: 10px; /* Ajustado */
    font-size: 13px; /* Ajustado */
  }
  
  .linha {
    flex-direction: column;
    gap: 8px; /* Ajustado */
  }
  
  .linha button {
    width: 100%;
    min-width: 100%;
  }
  
  .parametros-avancados {
    padding: 12px; /* Ajustado */
  }
  
  .parametros-avancados::before {
    top: 12px; /* Ajustado */
    left: 12px; /* Ajustado */
    font-size: 14px; /* Ajustado */
  }
  
  .parametros-avancados label,
  .parametros-avancados .linha,
  .parametros-avancados h3 {
    margin-left: 0;
    padding-left: 0;
  }
}

/* Animações de entrada (apenas tela) */
@media screen {
  input, select, button, .parametros-avancados {
    animation: slideUp 0.5s ease-out forwards;
    opacity: 0;
    transform: translateY(15px);
  }
  
  @keyframes slideUp {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Delay nas animações */
  label:nth-child(1) { animation-delay: 0.1s; }
  #valor { animation-delay: 0.15s; }
  label:nth-child(3) { animation-delay: 0.2s; }
  #produto { animation-delay: 0.25s; }
  label:nth-child(5) { animation-delay: 0.3s; }
  #prazo { animation-delay: 0.35s; }
  label:nth-child(7) { animation-delay: 0.4s; }
  #modo-taxa { animation-delay: 0.45s; }
  .parametros-avancados { animation-delay: 0.5s; }
  .acoes { animation-delay: 0.6s; }
}