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

/* ── Variables globales ──────────────────────────────────────────────────────── */
:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2333;
  --surface:   #21262d;
  --border:    #30363d;
  --green:     #22c55e;
  --green-dark:#16a34a;
  --green-dim: rgba(34,197,94,.12);
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --text:      #e6edf3;
  --text-muted:#8b949e;
  --text-dim:  #484f58;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

/* ── Layout principal ────────────────────────────────────────────────────────── */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.top {
  height: 64px;
  min-height: 64px;
  background: linear-gradient(135deg, #0f172a 0%, #1a2744 60%, #0d2137 100%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  position: relative;
  box-shadow: 0 2px 16px rgba(0,0,0,.5);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--green), #15803d);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(34,197,94,.3);
  flex-shrink: 0;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
}

.header-subtitle {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#auth-area {
  font-size: .82rem;
  color: #d1fae5;
}

.header-cart {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.25);
  padding: 6px 14px;
  border-radius: 20px;
  transition: all .2s;
  font-size: .9rem;
  white-space: nowrap;
}
.header-cart:hover {
  background: rgba(34,197,94,.22);
  border-color: rgba(34,197,94,.5);
}

#cart-badge {
  background: var(--red);
  color: #fff;
  border-radius: 50%;
  padding: 1px 6px;
  font-size: .72rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* ── Middle ──────────────────────────────────────────────────────────────────── */
.middle {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .25s ease, min-width .25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  background: none;
  color: var(--text-muted);
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: .95rem;
  transition: color .2s, background .2s;
}
.toggle-btn:hover { background: var(--bg3); color: var(--text); }

.btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  color: var(--text-muted);
  border: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-size: .88rem;
  font-family: inherit;
  text-align: left;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
}
.btn .nav-icon { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.btn .nav-label { flex: 1; }
.btn:hover {
  background: var(--bg3);
  color: var(--text);
  border-left-color: var(--border);
}
.btn.active {
  background: var(--green-dim);
  color: var(--green);
  border-left-color: var(--green);
}

/* ── Content (iframe) ────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.right {
  flex: 1;
  background: var(--bg);
  overflow: hidden;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.bottom {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 0 28px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-left {
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-left strong { color: var(--text); }

.footer-right {
  font-size: .78rem;
  color: var(--text-dim);
}

.footer-sep {
  color: var(--text-dim);
}

/* ── Container interno (páginas dentro del iframe) ───────────────────────────── */
.container-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Títulos ─────────────────────────────────────────────────────────────────── */
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

/* ── Stat cards ──────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon  { font-size: 1.8rem; margin-bottom: 8px; }
.stat-value { font-size: 2.2rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; letter-spacing: .3px; }

.stat-card.accent .stat-value { color: var(--green); }

/* ── Products grid ───────────────────────────────────────────────────────────── */
.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(34,197,94,.3);
}

.card-img-wrap {
  width: 100%;
  height: 180px;
  background: var(--bg3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.card-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card-img-wrap.no-img::after {
  content: '📦';
  font-size: 3rem;
  opacity: .4;
}

.card-body {
  padding: 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-body h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.desc      { font-size: .78rem; color: var(--text-muted); margin: 0 0 8px; line-height: 1.4; }
.price     { font-size: 1.15rem; font-weight: 700; color: var(--green); margin: 4px 0 2px; }
.stock-info { font-size: .73rem; color: var(--text-dim); margin-bottom: 10px; }

.promo-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .3px;
}

/* ── Botones de tarjeta ──────────────────────────────────────────────────────── */
.buttons {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

.buttons button {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  font-size: .78rem;
  font-weight: 600;
  font-family: inherit;
  transition: opacity .15s, transform .1s;
}
.buttons button:hover  { opacity: .88; }
.buttons button:active { transform: scale(.97); }

.info-btn { background: #2563eb; }
.cart-btn { background: var(--green); }

/* ── Loading / empty ─────────────────────────────────────────────────────────── */
.loading-msg, .no-products {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: .95rem;
}

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 24px;
  font-size: .85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

/* ── Floating cart button ────────────────────────────────────────────────────── */
.cart-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--green);
  color: #fff;
  border-radius: 28px;
  padding: 12px 20px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(34,197,94,.35);
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 999;
  transition: background .2s, box-shadow .2s;
  border: none;
  font-family: inherit;
}
.cart-fab:hover {
  background: var(--green-dark);
  box-shadow: 0 6px 20px rgba(34,197,94,.45);
}

/* ── Checkout ────────────────────────────────────────────────────────────────── */
.checkout-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 20px;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 28px;
  font-size: .85rem;
}
.cart-table th, .cart-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.cart-table thead {
  background: var(--bg3);
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cart-table tfoot { background: var(--surface); }
.total-label { text-align: right; font-weight: 600; color: var(--text-muted); }
.total-value { font-weight: 700; font-size: 1.05rem; color: var(--green); }

.qty-cell { white-space: nowrap; }
.qty-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: .95rem;
  color: var(--text);
  transition: background .15s;
}
.qty-btn:hover { background: var(--surface); }

.del-btn {
  background: rgba(239,68,68,.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  transition: background .15s;
}
.del-btn:hover { background: rgba(239,68,68,.2); }

.checkout-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.checkout-form h2 { font-size: 1rem; color: var(--text); margin-bottom: 18px; }
.checkout-form label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.checkout-form input[type="text"],
.checkout-form input[type="email"],
.checkout-form input[type="tel"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .2s, box-shadow .2s;
}
.checkout-form input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

.radio-group { display: flex; gap: 20px; margin: 10px 0; font-size: .88rem; }
.radio-group label { font-weight: 400; cursor: pointer; color: var(--text-muted); text-transform: none; letter-spacing: 0; }

.submit-btn {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s;
}
.submit-btn:hover:not(:disabled) { background: var(--green-dark); }
.submit-btn:disabled { background: var(--text-dim); cursor: default; }

.submit-error {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  border-radius: 7px;
  font-size: .85rem;
}

/* ── Pantalla éxito pedido ───────────────────────────────────────────────────── */
.order-success {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  gap: 14px;
}
.success-icon { font-size: 3.5rem; }
.order-success h2 { font-size: 1.5rem; font-weight: 700; }
.success-detail { color: var(--text-muted); max-width: 380px; font-size: .9rem; }

/* ── Dashboard / inicio ──────────────────────────────────────────────────────── */
.welcome-msg { color: var(--text-muted); margin-bottom: 26px; font-size: .9rem; }

.hint-msg {
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: .83rem;
  color: #fcd34d;
}
.hint-msg code {
  background: rgba(245,158,11,.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
}

/* ── Filtros ─────────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all .15s;
  font-family: inherit;
}
.chip:hover { background: var(--bg3); color: var(--text); }
.chip.active {
  background: var(--green-dim);
  border-color: rgba(34,197,94,.4);
  color: var(--green);
}

/* ── Buscador ────────────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.search-bar input {
  flex: 1;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .88rem;
  font-family: inherit;
  transition: border-color .2s;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--green);
}
.search-bar input::placeholder { color: var(--text-dim); }

/* ── Sugerencias form ────────────────────────────────────────────────────────── */
.sugerencia-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 620px;
  margin: 0 auto;
}
.sugerencia-form h2 { margin-bottom: 8px; }
.sugerencia-form .sub { color: var(--text-muted); font-size: .85rem; margin-bottom: 22px; }
.sugerencia-form label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.sugerencia-form input,
.sugerencia-form textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color .2s, box-shadow .2s;
}
.sugerencia-form input:focus,
.sugerencia-form textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}
.sugerencia-form textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}
.optional-tag {
  font-size: .72rem;
  color: var(--text-dim);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Mensajes de estado ──────────────────────────────────────────────────────── */
.msg-ok {
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.3);
  color: #86efac;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 14px;
}
.msg-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 14px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .middle { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; height: auto; flex-direction: row; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar.collapsed { width: 100%; min-width: 100%; height: auto; }
  .toggle-btn { display: none; }
  .btn { flex: 0 0 auto; padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; justify-content: center; }
  .btn .nav-label { display: none; }
  .btn.active { border-bottom-color: var(--green); border-left-color: transparent; }
  .bottom { justify-content: center; text-align: center; }
  .footer-left { justify-content: center; }
}
