:root {
  --bg: #0f0f12;
  --surface: #1a1a1f;
  --surface-2: #232329;
  --line: #2c2c33;
  --text: #f3f3f5;
  --text-dim: #9a9aa3;
  --accent: #a855f7;
  --accent-dim: #7c3aed;
  --success: #22c55e;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 15, 18, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar__brand-main {
  display: block;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 18px;
}

.topbar__brand-sub {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }

.estado {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 0;
  font-size: 15px;
}
.estado--error { color: #f87171; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--accent-dim); }

.card__img-wrap {
  aspect-ratio: 1 / 1;
  background: #000;
  overflow: hidden;
}
.card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  gap: 8px;
}

.qty {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.qty button {
  background: transparent;
  border: none;
  color: var(--text);
  width: 30px;
  height: 30px;
  font-size: 16px;
  cursor: pointer;
}
.qty button:hover { color: var(--accent); }
.qty input {
  width: 32px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-size: 14px;
}
.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.btn-add {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 16px;
  cursor: pointer;
  flex: none;
}
.btn-add:hover { background: var(--accent-dim); }
.btn-add--added { background: var(--success); }

/* Botón flotante carrito */
.fab-cart {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.4);
}
.fab-cart:hover { background: var(--accent-dim); }
#fabCount {
  display: inline-block;
  background: #fff;
  color: var(--accent-dim);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 13px;
  margin-left: 4px;
}

/* Overlay + panel carrito */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 25;
}

.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 30;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.cart-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.cart-panel__header h2 { margin: 0; font-size: 18px; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
}
.btn-icon:hover { color: var(--text); }

.cart-panel__items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.cart-item img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
}
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item__price { font-size: 12px; color: var(--text-dim); }
.cart-item__qty { font-size: 13px; color: var(--text-dim); width: 28px; text-align: center; }
.cart-item__remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
}
.cart-item__remove:hover { color: #f87171; }

.cart-panel__empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 14px;
}

.cart-panel__footer {
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}
.cart-panel__total {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}

.btn-primary {
  width: 100%;
  background: var(--success);
  color: #07210f;
  border: none;
  border-radius: 999px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
}
