/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  background-color: #dff0f5;
  color: #1a3540;
  font-family: 'Lato', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
header {
  text-align: center;
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: #ffffff;
}

.site-logo {
  height: 36px;
  width: auto;
  display: block;
  margin: 0 auto;
}

.tagline {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 300;
  color: #5a8a95;
  letter-spacing: 0.04em;
}

/* ─── App Layout ────────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "controls preview"
    "pay      preview";
  gap: 2rem;
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  align-items: start;
}

/* ─── Section Title ─────────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #3a8090;
  margin-bottom: 0.75rem;
}

/* ─── Controls Panel ────────────────────────────────────────────────────────── */
.controls-panel {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 2rem;
  background: #ffffff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 2px 16px rgba(0,150,170,0.10);
}

/* ─── Pay Wrap ──────────────────────────────────────────────────────────────── */
.pay-wrap {
  grid-area: pay;
  align-self: start;
}

/* ─── Upload Zone ───────────────────────────────────────────────────────────── */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.75rem 1.5rem;
  border: 2px dashed #333;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background-color: #141414;
  text-align: center;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: #c9a84c;
  background-color: rgba(201, 168, 76, 0.05);
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-icon {
  width: 36px;
  height: 36px;
  color: #444;
  transition: color 0.2s;
}

.upload-zone:hover .upload-icon,
.upload-zone.drag-over .upload-icon {
  color: #c9a84c;
}

.upload-label {
  font-size: 0.9rem;
  color: #888;
  font-weight: 400;
}

.upload-zone.has-image .upload-label {
  color: #c9a84c;
}

.upload-hint {
  font-size: 0.7rem;
  color: #444;
  letter-spacing: 0.05em;
}

/* ─── Fields ────────────────────────────────────────────────────────────────── */
.fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field-row {
  display: flex;
  gap: 0.75rem;
}

.field-row .field-group {
  flex: 1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-group label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #3a8090;
}

.field-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background-color: #f0f9fb;
  border: 1px solid #b8dde5;
  border-radius: 8px;
  color: #1a3540;
  font-family: 'Lato', sans-serif;
  font-size: 16px;
  font-weight: 400;
  transition: border-color 0.2s, outline 0.2s;
  outline: none;
}

.field-group input::placeholder {
  color: #9abec8;
}

.field-group input:focus {
  border-color: #00C7C7;
  outline: 2px solid rgba(0, 199, 199, 0.2);
  outline-offset: 0;
}

/* ─── Download Button ───────────────────────────────────────────────────────── */
#btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #c9a84c, #a8862e);
  color: #0f0f0f;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#btn-download svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(201, 168, 76, 0.35);
}

#btn-download:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ─── Preview Panel ─────────────────────────────────────────────────────────── */
.preview-panel {
  grid-area: preview;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.canvas-wrapper {
  background-color: #c8e8ef;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 150, 170, 0.2);
}

#preview-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.preview-hint {
  font-size: 0.68rem;
  color: #5a8a95;
  text-align: center;
  letter-spacing: 0.04em;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem;
  border-top: 1px solid rgba(0,0,0,0.08);
  color: #5a8a95;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-top: auto;
  background: #ffffff;
}

/* ─── Pay Button ────────────────────────────────────────────────────────────── */
#btn-pay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, #c9a84c, #a8862e);
  color: #0f0f0f;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#btn-pay svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#btn-pay:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(201, 168, 76, 0.35);
}

#btn-pay:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-price {
  margin-left: auto;
  font-size: 0.9rem;
  font-weight: 700;
  background: rgba(0,0,0,0.15);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ─── Modal Overlay ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay[hidden] {
  display: none;
}

/* ─── Modal Box ─────────────────────────────────────────────────────────────── */
.modal-box {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

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

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.modal-title-group h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #f5f5f5;
}

.pix-badge {
  background: #32bcad;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #555;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: #f5f5f5;
  background: #2a2a2a;
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

/* ─── PIX States ────────────────────────────────────────────────────────────── */
.pix-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.pix-state[hidden] {
  display: none;
}

/* Loading */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #2a2a2a;
  border-top-color: #c9a84c;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#pix-loading p {
  color: #666;
  font-size: 0.9rem;
}

/* Pending */
.modal-price {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: #c9a84c;
  line-height: 1;
}

.pix-qrcode {
  width: 200px;
  height: 200px;
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.pix-instructions {
  font-size: 0.8rem;
  color: #666;
  line-height: 1.5;
  max-width: 300px;
}

.pix-code-wrap {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}

.pix-code-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: #888;
  font-family: monospace;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

.pix-copy-btn {
  padding: 0.6rem 1rem;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #c9a84c;
  font-family: 'Lato', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.04em;
}

.pix-copy-btn:hover {
  background: #333;
  color: #f5f5f5;
}

.pix-copy-btn.copied {
  color: #4caf50;
}

.pix-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-top: 0.5rem;
  border-top: 1px solid #222;
}

.pix-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: #888;
}

.pix-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c9a84c;
  animation: pulse-dot 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

.pix-timer {
  font-size: 0.78rem;
  color: #555;
}

.pix-timer strong {
  color: #c9a84c;
  font-variant-numeric: tabular-nums;
}

.pix-timer.expiring strong {
  color: #e57373;
}

/* Success */
.success-icon {
  width: 64px;
  height: 64px;
  background: rgba(76, 175, 80, 0.12);
  border: 2px solid #4caf50;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 32px;
  height: 32px;
  stroke: #4caf50;
}

#pix-success h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: #f5f5f5;
}

.success-sub {
  font-size: 0.85rem;
  color: #666;
}

.btn-download-final {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.75rem;
  background: linear-gradient(135deg, #c9a84c, #a8862e);
  color: #0f0f0f;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 0.25rem;
}

.btn-download-final svg {
  width: 18px;
  height: 18px;
}

.btn-download-final:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(201, 168, 76, 0.35);
}

/* Error */
.pix-error-msg {
  color: #e57373;
  font-size: 0.9rem;
}

.pix-retry-btn {
  padding: 0.65rem 1.5rem;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #f5f5f5;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.pix-retry-btn:hover {
  background: #333;
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  .app-layout {
    grid-template-columns: 300px 1fr;
  }
}

@media (max-width: 599px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "controls"
      "preview"
      "pay";
    padding: 1.25rem;
    gap: 1.5rem;
  }

  .preview-panel {
    grid-row: auto;
  }

  .controls-panel {
    position: static;
  }
}
