/* ── Reset WordPress dentro de #em-app ────────────────── */
#em-app, #em-app * {
  box-sizing: border-box;
}
#em-app h1, #em-app h2, #em-app h3,
#em-app h4, #em-app h5, #em-app h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  padding: 0;
  border: none;
  color: inherit;
  line-height: inherit;
}
#em-app p { margin: 0; }
#em-app a { color: inherit; text-decoration: none; }
#em-app button { font-family: inherit; }
#em-app input, #em-app select { font-family: inherit; }

/* ── Pantallas ocultas por defecto ────────────────────── */
#em-app .em-screen { display: none !important; }
#em-app .em-screen.em-screen--active { display: flex !important; }
#em-app #em-screen-add.em-screen--active { display: flex !important; }
#em-app .em-overlay { display: flex; }
#em-app .em-overlay--hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   El Mandado — App Styles
   Paleta: Terracota Tica
   Principal: #BF360C | Claro: #E64A19 | Fondo: #FBE9E7
   Acento: #FFB300 | Texto: #3E2723
═══════════════════════════════════════════════════════════ */

:root {
  --em-primary:      #BF360C;
  --em-primary-dark: #8D2308;
  --em-primary-lite: #E64A19;
  --em-bg:           #FBE9E7;
  --em-bg-mid:       #F5C4B3;
  --em-accent:       #FFB300;
  --em-accent-bg:    #FFF8E1;
  --em-text:         #3E2723;
  --em-text-soft:    #8D6E63;
  --em-border:       #EFCFB7;
  --em-white:        #ffffff;
  --em-page:         #F9F5F3;
  --em-shadow:       0 2px 12px rgba(191,54,12,.12);
  --em-radius:       14px;
  --em-radius-sm:    8px;
  --em-fab-size:     56px;
  --em-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --em-whatsapp:     #25D366;
}

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

#em-app {
  font-family: var(--em-font);
  color: var(--em-text);
  background: var(--em-page);
  max-width: 430px;
  margin: 0 auto;
  min-height: 100svh;
  position: relative;
  overflow: hidden;
}

.em-screen {
  display: none;
  flex-direction: column;
  min-height: 100svh;
  position: relative;
}
.em-screen--active { display: flex; }
.em-screen-inner { padding: 20px 16px 100px; overflow-y: auto; min-height: 100svh; }

/* ── Bienvenida ─────────────────────────────────────────── */
.em-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 40px 24px;
  gap: 28px;
  background: var(--em-white);
}

.em-logo { text-align: center; }
.em-logo__icon { font-size: 64px; line-height: 1; margin-bottom: 8px; }
.em-logo__name {
  font-size: 32px; font-weight: 800;
  color: var(--em-primary);
  letter-spacing: -0.5px;
}
.em-logo__tagline { font-size: 15px; color: var(--em-text-soft); margin-top: 4px; }

.em-welcome__form { width: 100%; }
.em-welcome__actions { width: 100%; display: flex; flex-direction: column; gap: 12px; }

.em-divider {
  text-align: center; color: var(--em-text-soft); font-size: 13px; position: relative;
}
.em-divider::before, .em-divider::after {
  content: ''; position: absolute; top: 50%;
  width: 40%; height: 1px; background: var(--em-border);
}
.em-divider::before { left: 0; }
.em-divider::after  { right: 0; }

.em-join-row { display: flex; gap: 8px; }
.em-join-row .em-input { flex: 1; }

/* ── Header ─────────────────────────────────────────────── */
.em-header {
  background: var(--em-white);
  border-bottom: 1px solid var(--em-border);
  padding: 12px 16px 0;
  position: sticky; top: 0; z-index: 10;
}
.em-header__top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.em-header__title { flex: 1; }
.em-header__title h2 { font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--em-text); }

.em-code-badge {
  font-size: 11px; font-weight: 600;
  color: var(--em-primary);
  background: var(--em-bg);
  padding: 2px 8px; border-radius: 20px; letter-spacing: .5px;
}

/* ── Miembros ────────────────────────────────────────────── */
.em-members {
  display: flex; gap: -8px; padding: 4px 0 10px;
  overflow-x: auto; scrollbar-width: none;
}
.em-members::-webkit-scrollbar { display: none; }

.em-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--em-primary); color: var(--em-white);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--em-white); flex-shrink: 0; text-transform: uppercase;
}
.em-avatar--admin { background: var(--em-primary-dark); }

/* ── Chips de filtro ─────────────────────────────────────── */
.em-filter-chips {
  display: flex; gap: 6px; overflow-x: auto;
  scrollbar-width: none; padding-bottom: 10px;
}
.em-filter-chips::-webkit-scrollbar { display: none; }

.em-chip {
  white-space: nowrap; padding: 6px 14px; border-radius: 20px;
  border: 1.5px solid var(--em-border);
  background: var(--em-white); color: var(--em-text-soft);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; flex-shrink: 0;
}
.em-chip:hover   { border-color: var(--em-primary); color: var(--em-primary); }
.em-chip--active { background: var(--em-primary); border-color: var(--em-primary); color: var(--em-white); }

/* ── Lista de productos ──────────────────────────────────── */
.em-product-list {
  flex: 1; overflow-y: auto; padding: 12px 16px 120px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--em-page);
}

.em-product-item {
  background: var(--em-white);
  border-radius: var(--em-radius-sm);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--em-border);
  transition: transform .2s, opacity .2s;
  position: relative; overflow: hidden; cursor: pointer; user-select: none;
}
.em-product-item:hover { transform: translateY(-1px); box-shadow: var(--em-shadow); }
.em-product-item--bought { opacity: .55; }
.em-product-item--bought .em-product-name { text-decoration: line-through; }

.em-product-item::after {
  content: '✅'; position: absolute; right: -50px; top: 50%;
  transform: translateY(-50%); font-size: 22px; transition: right .2s;
}
.em-product-item.swiping::after { right: 14px; }

.em-product-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--em-border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .15s;
}
.em-product-item--bought .em-product-check {
  background: var(--em-primary); border-color: var(--em-primary); color: #fff;
}
.em-product-check::after { content: ''; }
.em-product-item--bought .em-product-check::after { content: '✓'; font-size: 13px; font-weight: 700; }

.em-product-info { flex: 1; min-width: 0; }
.em-product-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--em-text); }
.em-product-meta { font-size: 12px; color: var(--em-text-soft); margin-top: 2px; }
.em-product-price { font-size: 13px; font-weight: 600; color: var(--em-primary); white-space: nowrap; }

.em-product-delete {
  background: none; border: none; color: var(--em-text-soft);
  font-size: 16px; cursor: pointer; padding: 4px; opacity: 0; transition: opacity .15s;
}
.em-product-item:hover .em-product-delete { opacity: 1; }

/* ── Empty state ─────────────────────────────────────────── */
.em-empty-state {
  text-align: center; padding: 60px 20px; color: var(--em-text-soft);
}
.em-empty-state__icon { font-size: 56px; display: block; margin-bottom: 12px; }

/* ── Footer ──────────────────────────────────────────────── */
.em-footer {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: var(--em-white); border-top: 1px solid var(--em-border);
  padding: 10px 20px 20px;
  display: flex; align-items: center; justify-content: space-between; z-index: 9;
}
.em-total { font-size: 15px; color: var(--em-text-soft); }
.em-total strong { color: var(--em-primary); font-size: 17px; }

/* ── FAB ─────────────────────────────────────────────────── */
.em-fab {
  position: fixed; bottom: 72px; right: calc(50% - 215px + 16px);
  width: var(--em-fab-size); height: var(--em-fab-size); border-radius: 50%;
  background: var(--em-primary); color: var(--em-white); border: none;
  font-size: 28px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 16px rgba(191,54,12,.40); z-index: 10;
  transition: transform .15s, background .15s;
  display: flex; align-items: center; justify-content: center;
}
.em-fab:hover { background: var(--em-primary-dark); transform: scale(1.08); }
.em-fab:active { transform: scale(.96); }

/* ── Botones ─────────────────────────────────────────────── */
.em-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: var(--em-radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer; border: none; transition: all .15s;
}
.em-btn--primary  { background: var(--em-primary); color: var(--em-white); }
.em-btn--primary:hover  { background: var(--em-primary-dark); }
.em-btn--secondary { background: var(--em-bg); color: var(--em-primary); }
.em-btn--secondary:hover { background: var(--em-bg-mid); }
.em-btn--ghost { background: transparent; color: var(--em-text-soft); }
.em-btn--ghost:hover { background: var(--em-page); }
.em-btn--outline { background: transparent; border: 1.5px solid var(--em-primary); color: var(--em-primary); }
.em-btn--outline:hover { background: var(--em-bg); }
.em-btn--block { width: 100%; }
.em-btn--sm { padding: 8px 14px; font-size: 13px; }
.em-btn--whatsapp { background: var(--em-whatsapp); color: var(--em-white); }
.em-btn--whatsapp:hover { background: #1da851; }
.em-btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 6px; color: var(--em-text-soft); border-radius: 8px;
}
.em-btn-icon:hover { background: var(--em-page); }
.em-btn-back {
  background: none; border: none; cursor: pointer;
  font-size: 15px; color: var(--em-primary); font-weight: 600;
  padding: 0 0 16px; display: flex; align-items: center; gap: 4px;
}

/* ── Inputs ──────────────────────────────────────────────── */
.em-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--em-text-soft); margin-bottom: 6px;
}
.em-optional { font-weight: 400; opacity: .7; }
.em-input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--em-border);
  border-radius: var(--em-radius-sm);
  font-size: 15px; font-family: var(--em-font);
  background: var(--em-white); color: var(--em-text);
  transition: border-color .15s; outline: none; margin-bottom: 16px;
}
.em-input:focus { border-color: var(--em-primary); }
.em-input--lg { font-size: 18px; }
.em-input--code { text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.em-input--select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238D6E63' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}

/* ── Sheet / modal flotante ──────────────────────────────── */
.em-screen#em-screen-add {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(62,39,35,.40);
  justify-content: flex-end; align-items: stretch; display: none;
}
.em-screen#em-screen-add.em-screen--active { display: flex; }

.em-modal-sheet {
  background: var(--em-white);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 40px;
  width: 100%; max-height: 92svh; overflow-y: auto;
}
.em-sheet-handle {
  width: 40px; height: 4px; background: var(--em-border);
  border-radius: 2px; margin: 0 auto 16px;
}
.em-sheet-title { font-size: 18px; font-weight: 700; margin-bottom: 18px; color: var(--em-text); }
.em-sheet-actions { display: flex; gap: 10px; margin-top: 24px; }
.em-sheet-actions .em-btn { flex: 1; }

/* ── Sugerencias ─────────────────────────────────────────── */
.em-suggestions { margin-bottom: 16px; }
.em-suggestions__label { font-size: 12px; font-weight: 600; color: var(--em-text-soft); margin-bottom: 8px; }
.em-suggestions__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.em-chip--suggestion {
  background: var(--em-bg); border-color: var(--em-bg);
  color: var(--em-primary-dark); font-size: 12px; padding: 5px 10px;
}
.em-chip--suggestion:hover { background: var(--em-bg-mid); border-color: var(--em-primary); }

/* ── Overlay / modal ─────────────────────────────────────── */
.em-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(62,39,35,.45);
  display: flex; align-items: flex-end;
}
.em-overlay--hidden { display: none; }

.em-modal {
  background: var(--em-white);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 40px;
  width: 100%; max-width: 430px; margin: 0 auto;
}
.em-modal-title   { font-size: 18px; font-weight: 700; margin-bottom: 6px; color: var(--em-text); }
.em-modal-subtitle { font-size: 15px; color: var(--em-text-soft); margin-bottom: 18px; }
.em-modal--share { text-align: center; }
.em-modal--share .em-modal-subtitle { margin-bottom: 24px; }

/* ── Share code ──────────────────────────────────────────── */
.em-share-code {
  font-size: 34px; font-weight: 800; letter-spacing: 3px;
  color: var(--em-primary); background: var(--em-bg);
  border-radius: var(--em-radius); padding: 20px; margin-bottom: 20px;
}
.em-share-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Summary ─────────────────────────────────────────────── */
.em-section-title { font-size: 22px; font-weight: 800; margin-bottom: 24px; color: var(--em-text); }
.em-summary-total {
  background: var(--em-primary); color: var(--em-white);
  border-radius: var(--em-radius); padding: 20px 24px;
  display: flex; flex-direction: column; align-items: center; margin-bottom: 24px;
}
.em-summary-total__label { font-size: 13px; opacity: .85; margin-bottom: 6px; }
.em-summary-total__amount { font-size: 36px; font-weight: 800; }
.em-summary-subhead { font-size: 15px; font-weight: 700; margin-bottom: 12px; color: var(--em-text-soft); }

.em-summary-categories { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.em-summary-cat-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--em-white); border-radius: var(--em-radius-sm);
  padding: 12px 14px; border: 1px solid var(--em-border);
}
.em-summary-cat-label { flex: 1; font-size: 14px; color: var(--em-text); }
.em-summary-cat-amount { font-size: 15px; font-weight: 700; color: var(--em-primary); }

.em-summary-members { margin-bottom: 24px; }
.em-split-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--em-bg); border-radius: var(--em-radius-sm);
  padding: 14px 16px; font-size: 14px;
}
.em-split-row strong { color: var(--em-primary); font-size: 16px; }
.em-mt-1 { margin-top: 8px; }
.em-mt-2 { margin-top: 16px; }

/* ── Toast ───────────────────────────────────────────────── */
.em-toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--em-text); color: #fff;
  padding: 10px 20px; border-radius: 24px;
  font-size: 14px; font-weight: 500; z-index: 100;
  transition: opacity .2s; white-space: nowrap;
}
.em-toast--hidden { opacity: 0; pointer-events: none; }

@media (min-width: 480px) {
  .em-fab { right: calc(50% - 215px + 16px); }
}
