@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
  --bg: #14151c;
  --bg-elevated: #1c1e28;
  --ink: #eef0f6;
  --ink-dim: #9198ac;
  --accent: #3b5bfd;
  --accent-2: #6c63ff;
  --danger: #ff5470;
  --radius-lg: 22px;
  --radius-md: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

h1, h2, h3, .display {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

/* --- Header --- */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 28px 24px 8px;
}

.topbar .eyebrow {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 2px;
}

.topbar h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
}

.count-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink-dim);
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: 999px;
}

/* --- Card stack / grid --- */
#cards-container {
  padding: 12px 20px 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  margin-top: 18vh;
  text-align: center;
  color: var(--ink-dim);
  padding: 0 32px;
}

.empty-state .glyph {
  font-size: 40px;
  margin-bottom: 10px;
  opacity: 0.8;
}

.empty-state p {
  line-height: 1.5;
}

.card-item {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.15s ease;
}

.card-item:active {
  transform: scale(0.98);
}

.card-item::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), rgba(255,255,255,0) 55%);
}

.card-item .store-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 19px;
  margin: 0 0 6px;
}

.card-item .code-preview {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  opacity: 0.85;
  letter-spacing: 0.02em;
}

.card-item .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

.card-item .fmt-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.18);
  padding: 4px 9px;
  border-radius: 999px;
}

.card-item .tap-hint {
  font-size: 12px;
  opacity: 0.75;
}

/* --- FAB --- */
.fab {
  position: fixed;
  right: 22px;
  bottom: calc(24px + var(--safe-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(59, 91, 253, 0.45);
  z-index: 40;
}
.fab:active { transform: scale(0.94); }

/* --- Overlays (add card / full screen) --- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  animation: overlay-in 0.18s ease;
}

.overlay[hidden] {
  display: none;
}

@keyframes overlay-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 6px;
}

.overlay-header h2 {
  font-size: 19px;
  margin: 0;
}

.icon-btn {
  background: var(--bg-elevated);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 20px 30px;
}

/* --- Form --- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--ink);
  padding: 13px 14px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-family: inherit;
}

.field input.mono {
  font-family: 'JetBrains Mono', monospace;
}

.color-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.swatch.selected {
  border-color: #fff;
}

.scan-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  border: 1px dashed rgba(255,255,255,0.18);
}

.primary-btn {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.primary-btn:active { opacity: 0.85; }

.danger-btn {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid rgba(255, 84, 112, 0.35);
  margin-top: 10px;
}

#scanner-region {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  background: #000;
}

/* --- Full screen card view (para escanear en caja) --- */
.full-card-overlay {
  background: #fff;
  color: #14151c;
}

.full-card-overlay .overlay-header h2 {
  color: #14151c;
}

.full-card-overlay .icon-btn {
  background: #f0f1f5;
  color: #14151c;
}

.full-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 20px;
}

.full-card-body .store-name-big {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 24px;
}

.full-card-body canvas, .full-card-body img {
  max-width: 100%;
}

.full-card-body .code-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  letter-spacing: 0.05em;
  color: #4a4d5c;
}

.full-card-body .notes-text {
  font-size: 14px;
  color: #6a6d7c;
  text-align: center;
  padding: 0 20px;
}

.toast {
  position: fixed;
  bottom: calc(30px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
