﻿:root {
  color-scheme: light;
  --bg: #0f172a;
  --bg-soft: #111827;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #0f172a;
  --text-soft: #475569;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #14b8a6;
  --shadow: 0 25px 70px rgba(15, 23, 42, 0.18);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  background: radial-gradient(1200px 800px at 85% -10%, rgba(37, 99, 235, 0.25), transparent),
    radial-gradient(900px 600px at -10% 20%, rgba(20, 184, 166, 0.2), transparent),
    #eef2ff;
  color: var(--text);
  min-height: 100vh;
}

.page {
  display: flex;
  flex-direction: column;
}

.shell {
  width: min(1100px, 92vw);
  margin: 80px auto;
  display: grid;
  gap: 28px;
}

.shell-form {
  width: 100%;
  margin: 40px auto 80px;
  display: flex;
  justify-content: center;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  position: relative;
  overflow: hidden;
  animation: fadeIn 0.6s ease;
}

.shell-form>.panel {
  width: min(920px, 92vw);
}

.panel-header {
  margin-bottom: 24px;
}

.panel-header h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
}

.panel-header p {
  margin: 0;
  color: var(--text-soft);
}

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

.brand img {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-soft);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 6vw;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  z-index: 20;
}

.topbar .brand strong {
  display: block;
  font-size: 1rem;
}

.topbar .brand span {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.topbar .brand img {
  height: 32px;
}

.form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.form-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
  max-width: 860px;
  margin: 0 auto;
}

.card {
  background: var(--panel-strong);
  border-radius: 14px;
  padding: 22px;
  display: grid;
  gap: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.card-center {
  text-align: center;
  justify-items: center;
}

.card-center .radio-group {
  justify-content: center;
}

.card-center .field {
  width: min(520px, 100%);
}

.card-center .field.inline {
  grid-template-columns: 1fr;
}

.card-wide {
  grid-column: 1 / -1;
}

.card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.field {
  display: grid;
  gap: 8px;
}

.field.inline {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

label {
  font-weight: 600;
  color: var(--text);
}

input,
select,
textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.98rem;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Sales form fields should be uppercase */
#formVendas input:not([type="email"]):not([type="date"]),
#formVendas select,
#formVendas textarea {
  text-transform: uppercase;
}

input[type="email"] {
  text-transform: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  resize: vertical;
}

input.valid,
select.valid,
textarea.valid {
  border-color: #16a34a;
}

input.invalid,
select.invalid,
textarea.invalid {
  border-color: #dc2626;
}

.radio-group {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.radio-group input {
  margin: 0;
}

.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #fff;
}

.inline-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-icon {
  font-size: 1.2rem;
}

.status-icon.valid {
  color: #16a34a;
}

.status-icon.invalid {
  color: #dc2626;
}

.status-icon.registered {
  color: #2563eb;
}

.message {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.message.valid {
  color: #16a34a;
}

.message.invalid {
  color: #dc2626;
}

.produtos {
  display: grid;
  gap: 10px;
}

.produtos label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.04);
}

.produtos input[type="number"] {
  width: 90px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.25);
}

.btn.primary:hover {
  background: var(--primary-strong);
  transform: translateY(-1px);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--text);
}

.btn.soft {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary-strong);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
  grid-column: 1 / -1;
}

.form-actions .btn {
  min-width: 180px;
}

.chip {
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 10px;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.page-login {
  display: flex;
  align-items: center;
}

.login-card {
  display: grid;
}

.login-aside {
  background: linear-gradient(160deg, rgba(37, 99, 235, 0.95), rgba(15, 23, 42, 0.95));
  color: #fff;
}

.login-aside h2 {
  margin-top: 0;
  font-size: 1.8rem;
}

.login-aside p {
  color: rgba(226, 232, 240, 0.85);
}

.login-aside .features {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.login-aside .features li {
  display: flex;
  gap: 10px;
  align-items: center;
}

.login-aside .features li::before {
  content: '•';
  color: var(--accent);
  font-weight: 800;
}

.login-aside .glow {
  position: absolute;
  inset: -30% 30% auto auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(20, 184, 166, 0.7), transparent 70%);
  filter: blur(6px);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: min(720px, 95vw);
  display: grid;
  gap: 16px;
}

.modal-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-card pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 12px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 1100px) {
  .shell {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

@media (max-width: 900px) {
  .topbar {
    padding: 16px 4vw;
  }

  .shell {
    width: 92vw;
    margin: 30px auto;
  }

  .panel {
    padding: 24px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px;
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .topbar .brand {
    justify-content: center;
  }

  .shell {
    width: 98vw;
    margin: 15px auto;
    gap: 12px;
  }

  .panel {
    padding: 16px 10px;
    /* Reduzi padding lateral */
    border-radius: 12px;
    width: 100% !important;
    /* Força largura total */
  }

  .card {
    padding: 16px 10px;
    /* Reduzi padding lateral */
    gap: 12px;
    width: 100% !important;
    /* Impede transbordo */
    overflow: hidden;
    /* Garante que conteúdo interno não vaze */
  }

  .form-grid {
    gap: 12px;
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .form-actions .btn {
    width: 100%;
    min-width: unset;
  }

  /* Ajuste para campos inline no mobile */
  .inline-input {
    flex-wrap: wrap;
    /* Garante que ícones ou botões internos quebrem linha se necessário */
  }

  .field.inline {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Ajuste específico para grupos de rádio transbordando */
  .radio-group {
    gap: 6px;
    display: grid;
    /* Muda para grid para controle total da largura */
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .radio-group label {
    padding: 10px;
    font-size: 0.82rem;
    justify-content: center;
    width: 100%;
  }

  .btn-row {
    justify-content: center;
    gap: 6px;
    width: 100%;
  }

  .btn-row .btn {
    flex: 1 1 calc(50% - 6px);
    /* Faz os botões ocuparem metade da linha */
    padding: 10px 4px;
    font-size: 0.8rem;
  }

  .produtos label {
    padding: 8px;
    font-size: 0.82rem;
    width: 100%;
  }

  /* Ajuste de inputs para não 'empurrarem' a tela */
  input,
  select,
  textarea {
    max-width: 100%;
    box-sizing: border-box;
  }

  .login-card,
  .login-aside {
    padding: 24px 16px;
  }
}

/* Ajuste crítico para telas muito pequenas (ex: Galaxy S20, iPhone SE) */
@media (max-width: 400px) {
  .shell {
    width: 100vw;
    margin: 10px 0;
  }

  .panel {
    border-radius: 0;
    /* Remove arredondamento para ganhar espaço lateral */
    padding: 12px 8px;
  }

  .card {
    border-radius: 8px;
    padding: 12px 8px;
  }

  .brand img {
    height: 32px;
    /* Logo menor em telas minúsculas */
  }
}