/* ═══════════════════════════════════════════════════════════════
   app.css — Variables, reset, layout base, navbar, offline banner
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --color-primary:        #E31837;
  --color-primary-dark:   #B01229;
  --color-primary-light:  #FF4D6A;

  --color-bg:             #F5F5F5;
  --color-surface:        #FFFFFF;
  --color-text:           #1A1A1A;
  --color-text-secondary: #666666;
  --color-border:         #E0E0E0;

  --color-success:        #2E7D32;
  --color-warning:        #F57C00;
  --color-error:          #C62828;
  --color-offline:        #757575;

  --font:                 -apple-system, BlinkMacSystemFont, "Segoe UI",
                          Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:            "Courier New", Courier, monospace;

  --radius:               8px;
  --radius-sm:            4px;
  --radius-lg:            12px;

  --shadow:               0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:            0 2px 6px rgba(0,0,0,.14);

  --transition:           150ms ease;

  --navbar-h:             56px;
  --safe-bottom:          env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

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

input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
}

/* ── Layout base ────────────────────────────────────────────────── */
#app {
  min-height: 100dvh;
  padding-bottom: calc(var(--navbar-h) + var(--safe-bottom));
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.page--full {
  max-width: 100%;
  padding: 0;
}

/* ── Offline banner ─────────────────────────────────────────────── */
#offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--color-offline);
  color: #fff;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.3;
}

#offline-banner[hidden] {
  display: none;
}

#offline-banner svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* Empujar contenido hacia abajo cuando banner visible */
body:has(#offline-banner:not([hidden])) #app {
  padding-top: 44px;
}

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--navbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  box-shadow: 0 -1px 4px rgba(0,0,0,.08);
}

.navbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--color-text-secondary);
  font-size: .6875rem;
  font-weight: 500;
  min-height: 48px;
  position: relative;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.navbar__item:active {
  background: var(--color-bg);
}

.navbar__item.active {
  color: var(--color-primary);
}

.navbar__item svg {
  width: 22px;
  height: 22px;
}

/* Badge sobre ícono del carrito */
.navbar__badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--color-primary);
  color: #fff;
  font-size: .6875rem;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Header de página ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 8px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header__back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.page-header__back:active {
  background: var(--color-bg);
}

.page-header__back svg {
  width: 20px;
  height: 20px;
}

.page-header__title {
  font-size: 1.0625rem;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-header__subtitle {
  font-size: .8125rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Search bar ─────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 49;
}

.search-bar__input {
  flex: 1;
  height: 40px;
  padding: 0 12px 0 36px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  font-size: .9375rem;
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition);
}

.search-bar__input:focus {
  border-color: var(--color-primary);
}

.search-bar__icon {
  position: absolute;
  left: 28px;
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary);
  pointer-events: none;
}

.search-bar__wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

/* ── Category tabs ──────────────────────────────────────────────── */
.category-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: .8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.category-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

/* ── Sync badge ─────────────────────────────────────────────────── */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--color-warning);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.sync-badge svg {
  width: 12px;
  height: 12px;
}

/* ── Utilidades ─────────────────────────────────────────────────── */
.text-primary   { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-error     { color: var(--color-error); }

.text-sm   { font-size: .875rem; }
.text-xs   { font-size: .75rem; }
.text-lg   { font-size: 1.125rem; }

.font-bold   { font-weight: 700; }
.font-medium { font-weight: 500; }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }

.w-full  { width: 100%; }
.hidden  { display: none !important; }

.surface {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.divider {
  height: 1px;
  background: var(--color-border);
  margin: 0;
}

/* Estado vacío */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--color-text-secondary);
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: .4;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.empty-state__text {
  font-size: .875rem;
  line-height: 1.5;
}
