/* =====================================================
   APP ETIQUETAS — Base
   Reset, tipografia e helpers globais.
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
  background:
    radial-gradient(circle at top right, rgba(255, 212, 0, 0.10), transparent 26%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--ff);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: auto;
  transition: opacity .24s ease, transform .24s ease;
}

body.app-booting {
  opacity: 0;
  transform: translateY(6px);
}

body.app-ready {
  opacity: 1;
  transform: none;
}

body.modal-open {
  overflow: hidden;
}

body.is-busy:not(.modal-open) {
  overflow-y: auto;
}

a { color: var(--nv); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

input, select, textarea {
  font-size: 16px;
  color: var(--text);
}

img, svg { display: block; max-width: 100%; }

iframe {
  width: 100%;
  border: 0;
}

@media (min-width: 900px) {
  html::-webkit-scrollbar,
  body::-webkit-scrollbar {
    width: 14px;
  }
  html::-webkit-scrollbar-track,
  body::-webkit-scrollbar-track {
    background: #e2e8f0;
  }
  html::-webkit-scrollbar-thumb,
  body::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border: 3px solid #e2e8f0;
    border-radius: 999px;
  }
  html::-webkit-scrollbar-thumb:hover,
  body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
  }
}

::selection {
  background: rgba(255, 212, 0, 0.45);
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
  font-size: 22px;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

:focus-visible {
  outline: 3px solid rgba(255, 212, 0, 0.95);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 4px rgba(255, 212, 0, 0.22);
}

/* Loading overlay */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  padding: 20px;
}
.loading.show { display: flex; }
.loading-card {
  background: rgba(255,255,255,0.98);
  border-radius: 22px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--sh-lg);
  min-width: min(100%, 260px);
  max-width: 340px;
  border: 1px solid rgba(0, 65, 107, 0.08);
}
.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(0, 65, 107, 0.18);
  border-top-color: var(--nv);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0));
  transform: translateY(24px);
  background: #0f172a;
  color: #fff;
  padding: 14px 16px;
  border-radius: 18px;
  box-shadow: var(--sh-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.22s;
  z-index: 220;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0 auto;
  font-size: 14px;
  font-weight: 600;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.toast-error { background: #7f1d1d; }
.toast.toast-success { background: #14532d; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.52);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 210;
  padding: 16px;
}
.modal.show { display: flex; }
.modal-card {
  background: var(--card);
  border-radius: 24px 24px 18px 18px;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom, 0));
  max-width: 520px;
  width: 100%;
  box-shadow: var(--sh-lg);
  transform: translateY(10px);
  animation: modal-rise .18s ease forwards;
}
@keyframes modal-rise {
  to { transform: translateY(0); }
}
.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--nv);
  margin-bottom: 8px;
}
.modal-body {
  color: var(--text-2);
  margin-bottom: 18px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: stretch;
}
.modal-actions > * {
  flex: 1;
}

@media (min-width: 720px) {
  .modal {
    align-items: center;
  }
  .modal-card {
    border-radius: var(--r-lg);
    padding-bottom: 24px;
  }
  .modal-actions {
    justify-content: flex-end;
  }
  .modal-actions > * {
    flex: 0 0 auto;
    min-width: 132px;
  }
  .toast {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(24px);
  }
  .toast.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* =====================================================
   Nuvemshop — polimento de cards, chips e mobile
   ===================================================== */
.queue-card,
.hist-item,
.hist-item-inline {
  max-width: 100%;
}

.queue-main,
.hist-item-main,
.queue-head-main,
.hist-item-titleline,
.queue-subline,
.hist-meta-row {
  min-width: 0;
}

.queue-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--nv);
  background: var(--nv-50);
  border: 1px solid var(--nv-100);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.badge-pay-paid,
.badge-pay-authorized,
.badge-pay-pending,
.badge-pay-cancelled,
.badge-pay-refunded,
.badge-service-pac,
.badge-service-sedex,
.badge-service-other {
  border: 1px solid transparent;
}

.badge-pay-paid { background: #dcfce7 !important; color: #166534 !important; border-color: #bbf7d0 !important; }
.badge-pay-authorized { background: #e0f2fe !important; color: #075985 !important; border-color: #bae6fd !important; }
.badge-pay-pending { background: #fef3c7 !important; color: #92400e !important; border-color: #fde68a !important; }
.badge-pay-cancelled,
.badge-pay-refunded { background: #fee2e2 !important; color: #991b1b !important; border-color: #fecaca !important; }

.badge-service-pac,
.hist-service-pac { background: #e0f2fe !important; color: #075985 !important; border-color: #bae6fd !important; }
.badge-service-sedex,
.hist-service-sedex { background: #fef3c7 !important; color: #92400e !important; border-color: #fde68a !important; }
.badge-service-other,
.hist-service-outro { background: #f1f5f9 !important; color: #334155 !important; border-color: #e2e8f0 !important; }

.queue-card.is-not-eligible {
  opacity: .86;
}
.queue-card.is-not-eligible .queue-title,
.queue-card.is-not-eligible .queue-subline {
  color: var(--muted);
}
.queue-actions-note {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
  padding: 7px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #f8fafc;
}

@media (max-width: 640px) {
  .screen { padding-left: 12px !important; padding-right: 12px !important; }
  .toolbar,
  .hist-toolbar-card { padding: 12px !important; }
  .queue-card,
  .hist-item,
  .hist-item-inline { border-radius: 18px !important; }
  .queue-main,
  .hist-item-main { padding-right: 12px !important; }
  .queue-actions,
  .hist-item-actions-inline { display: grid !important; grid-template-columns: 1fr !important; }
  .queue-actions .btn,
  .hist-item-actions-inline .btn { width: 100% !important; min-height: 44px !important; }
  .queue-value { width: fit-content; }
  .toolbar-actions-bulk { grid-template-columns: 1fr !important; }
  .bottom-nav { left: 8px !important; right: 8px !important; }
}

@media (max-width: 420px) {
  .queue-title,
  .hist-item-titleline .hist-item-nome { font-size: 17px !important; }
  .queue-subline,
  .hist-meta-row { font-size: 12px !important; }
  .badge { font-size: 10px !important; padding-inline: 8px !important; }
}

/* Print */
@media print {
  .topbar, .bottom-nav, .sticky-actions, .toast, .loading,
  .success-actions, .hist-toolbar, .modal { display: none !important; }
  body { background: #fff; padding: 0; }
  .success-preview iframe { height: 100vh !important; }
}
