/* ============================================================
   app.css — Layout principal, Bottom Nav, Header, Dark Mode Toggle
   ============================================================ */

/* ── App Shell ───────────────────────────────────────────── */
#app-shell {
  display: flex; flex-direction: column; min-height: 100dvh;
  padding-bottom: var(--nav-height);
}

/* ── Top Header ──────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; height: var(--header-h); z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}
.app-header .logo-area { display:flex; align-items:center; gap:.6rem; }
.app-header .store-logo { width:32px; height:32px; border-radius:8px; object-fit:cover; }
.app-header .store-name { font-size:1rem; font-weight:700; color:var(--primary); }
.app-header .header-actions { display:flex; align-items:center; gap:.5rem; }
.app-header .btn-icon { background:var(--surface2); color:var(--text); }

/* Indicador de sincronización */
.sync-dot { width:8px; height:8px; border-radius:50%; background:var(--success); }
.sync-dot.pending { background:var(--warning); animation:pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Bottom Navigation ───────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height);
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: stretch; z-index: 300;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer; padding: 6px 0;
  transition: all var(--transition); border: none; background: none;
  color: var(--text-muted); position: relative;
}
.nav-item .nav-icon { font-size: 1.4rem; transition: transform var(--transition); }
.nav-item .nav-label{ font-size: .65rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.nav-item.active { color: var(--primary); }
.nav-item.active .nav-icon { transform: translateY(-2px); }
.nav-item.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary);
}
/* Ripple en nav */
.nav-item:active .nav-icon { transform: scale(.9); }

/* Badge en icono de nav */
.nav-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  background: var(--danger); color: #fff; border-radius: 10px;
  font-size: .6rem; font-weight: 700; padding: 1px 5px; min-width: 16px; text-align: center;
}

/* ── Contenido Principal ─────────────────────────────────── */
#page-content {
  flex: 1; overflow-x: hidden; overflow-y: auto;
  padding: .75rem .75rem 0;
  -webkit-overflow-scrolling: touch;
}
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }

/* ── Login Screen ────────────────────────────────────────── */
#login-screen {
  position: fixed; inset: 0; z-index: 500; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
}
.login-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2rem; width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg); animation: scaleIn .3s ease;
}
.login-logo  { text-align: center; margin-bottom: 1.5rem; }
.login-logo img { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; margin-bottom: .75rem; }
.login-logo h1  { font-size: 1.3rem; font-weight: 700; }
.login-logo p   { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 1rem; }

/* ── Dark mode toggle ────────────────────────────────────── */
.dark-toggle {
  width: 44px; height: 24px; border-radius: 12px; background: var(--border);
  position: relative; cursor: pointer; border: none; transition: background var(--transition);
  flex-shrink: 0;
}
.dark-toggle.on { background: var(--primary); }
.dark-toggle::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.dark-toggle.on::after { transform: translateX(20px); }

/* ── Section titles ──────────────────────────────────────── */
.section-title { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin: 1rem 0 .5rem; }

/* ── Grid utilidades ─────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stack  { display: flex; flex-direction: column; gap: .75rem; }
.row    { display: flex; align-items: center; gap: .5rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.mt-1   { margin-top: .5rem; }
.mt-2   { margin-top: 1rem; }

/* ── Scrollbar thin ──────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Safe area bottom ────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { height: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
  #app-shell  { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align:center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3    { font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.empty-state p     { font-size: .85rem; }

/* Tablet / Desktop */
@media (min-width: 640px) {
  #page-content { padding: 1rem; max-width: 600px; margin: 0 auto; }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
