/*
 * Estilos reutilizables de la app. Solo usan var(--token) de tokens.css -
 * nunca un color o medida escrita directamente aquí. Para cambiar el diseño
 * visual, edita tokens.css, no este archivo.
 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
}

.wrap {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: var(--page-padding);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: var(--space-relaxed);
  margin-bottom: var(--space-wide);
}

header h1 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin: 0;
  letter-spacing: -0.3px;
}

.biz-name {
  font-size: var(--text-base);
  color: var(--ink-soft);
}

.logout-btn {
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  padding: var(--space-tight) var(--space-comfortable);
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

section {
  margin-bottom: var(--space-section);
}

h2 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--ink-soft);
  margin: 0 0 var(--space-cozy);
  font-weight: var(--weight-semibold);
}

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: var(--space-generous);
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-tight);
  margin-top: var(--space-comfortable);
}

label:first-of-type {
  margin-top: 0;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: var(--space-compact) var(--space-comfortable);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  font-size: var(--text-base);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

select {
  width: 100%;
  padding: var(--space-compact) var(--space-comfortable);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  font-size: var(--text-base);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: inherit;
}

select:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

input[type="color"] {
  width: 52px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  background: var(--paper-raised);
  cursor: pointer;
}

.row {
  display: flex;
  gap: var(--space-comfortable);
  flex-wrap: wrap;
}

.row > div {
  flex: 1;
  min-width: 140px;
}

.phone-input {
  display: flex;
  gap: var(--space-tight);
}

.phone-input select {
  flex: 0 0 108px;
  width: auto;
}

.phone-input input {
  flex: 1;
}

.hint {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  margin-top: var(--space-hairline);
}

.error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-hairline);
  display: none;
}

button {
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  padding: var(--space-compact) var(--space-loose);
  border-radius: var(--radius-input);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  margin-top: var(--space-loose);
}

button:hover {
  opacity: 0.85;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
  gap: var(--space-relaxed);
}

.card-cell {
  display: flex;
  flex-direction: column;
  gap: var(--space-tight);
}

.card-actions {
  display: flex;
  gap: var(--space-tight);
  flex-wrap: wrap;
}

.card-actions button {
  margin-top: 0;
  font-size: var(--text-xs);
  padding: var(--space-tight) var(--space-comfortable);
}

.card-qr {
  display: none;
  padding: var(--space-comfortable);
  text-align: center;
}

.card-qr.show {
  display: block;
}

.card-qr img {
  max-width: 180px;
  width: 100%;
  height: auto;
}

.card-customers {
  font-size: var(--text-xs);
  color: var(--ink-soft);
}

.customers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-comfortable);
}

.customer-row {
  padding-bottom: var(--space-comfortable);
  border-bottom: 1px solid var(--line);
}

.customer-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.customer-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.customer-detail {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  margin-top: var(--space-hairline);
}

.location-cell {
  margin-bottom: var(--space-relaxed);
}

.location-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-comfortable);
}

.staff-list {
  margin-bottom: var(--space-comfortable);
}

.transactions-list {
  margin-top: var(--space-comfortable);
  display: flex;
  flex-direction: column;
  gap: var(--space-tight);
}

.transaction-row {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: var(--space-tight);
}

.transaction-row .transaction-amount {
  font-weight: var(--weight-semibold);
  color: var(--ink);
  flex-shrink: 0;
}

.customer-campaign {
  font-size: var(--text-xs);
  color: var(--ink-soft);
  margin-top: var(--space-hairline);
}

.progress-dots {
  display: inline-flex;
  gap: 3px;
  vertical-align: middle;
}

.progress-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-round);
  border: 1.5px solid var(--line-strong);
  display: inline-block;
}

.progress-dot.filled {
  background: var(--ink);
  border-color: var(--ink);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-relaxed);
}

.stat-tile {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: var(--space-generous);
  text-align: center;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--ink-soft);
  margin-top: var(--space-hairline);
}

.stamp-card {
  border-radius: var(--radius-card);
  padding: var(--space-loose);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.stamp-card .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-relaxed);
}

.stamp-card .biz {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  opacity: 0.85;
}

.stamp-card .reward {
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  margin-top: 2px;
}

.stamp-card .delete-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: var(--radius-round);
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
}

.stamps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-snug);
  margin-top: var(--space-tight);
}

.reward-goal {
  font-size: var(--text-sm);
  opacity: 0.9;
  margin-top: var(--space-tight);
}

.stamp-dot {
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: var(--radius-round);
  border: 1.5px dashed rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
}

.empty {
  color: var(--ink-soft);
  font-size: var(--text-base);
  padding: var(--space-spacious);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-panel);
}

.toast {
  position: fixed;
  bottom: var(--space-spacious);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-compact) var(--space-loose);
  border-radius: 8px;
  font-size: var(--text-sm);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.loading {
  color: var(--ink-soft);
  font-size: var(--text-base);
}

.hidden {
  display: none;
}

.color-field {
  flex: 0 0 90px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--paper-raised);
  border-right: 1px solid var(--line);
  padding: var(--space-generous) var(--space-comfortable);
  display: flex;
  flex-direction: column;
  gap: var(--space-tight);
}

.sidebar-header {
  padding: 0 var(--space-comfortable) var(--space-generous);
}

.nav-item {
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-align: left;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  border-radius: var(--radius-input);
  padding: var(--space-compact) var(--space-comfortable);
  margin-top: 0;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--paper);
  color: var(--ink);
}

.nav-item.active {
  background: var(--ink);
  color: var(--paper);
}

.sidebar-logout {
  margin-top: auto;
}

.content {
  flex: 1;
  min-width: 0;
  padding: var(--page-padding);
  max-width: var(--page-max-width);
}

.content h1 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-wide);
  letter-spacing: -0.3px;
}

@media (max-width: 720px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: var(--space-comfortable);
  }

  .sidebar-header {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
  }

  .sidebar-logout {
    margin-top: 0;
    margin-left: auto;
  }
}

.auth-wrap {
  max-width: 360px;
  margin: 10vh auto 0;
  padding: 0 20px;
}

.auth-wrap h1 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  margin: 0 0 var(--space-wide);
  text-align: center;
}

.create-card-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: var(--space-relaxed);
  align-items: start;
}

.create-preview-wrap {
  position: sticky;
  top: var(--space-generous);
}

.create-preview-wrap .stamp-card {
  margin-top: var(--space-tight);
}

@media (max-width: 720px) {
  .create-card-layout {
    grid-template-columns: 1fr;
  }

  .create-preview-wrap {
    position: static;
  }
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-tight);
}

.emoji-option {
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1;
  background: var(--paper-raised);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-input);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-option:hover {
  border-color: var(--ink-soft);
  opacity: 1;
}

.emoji-option.selected {
  border-color: var(--ink);
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--ink) inset;
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-tight);
}

.color-swatch {
  width: 32px;
  height: 32px;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-round);
  border: 2px solid var(--paper-raised);
  outline: 1.5px solid var(--line-strong);
  cursor: pointer;
}

.color-swatch:hover {
  opacity: 0.85;
}

.color-swatch.selected {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.color-custom-row {
  display: flex;
  align-items: center;
  gap: var(--space-tight);
  margin-top: var(--space-tight);
}

.card-face-emoji {
  font-size: var(--text-lg);
  line-height: 1;
  margin-right: var(--space-tight);
}
