/* ══════════════════════════════════════════════
   StockPro — Mobile-first UI
   Activo cuando body.mobile-mode
   ══════════════════════════════════════════════ */

/* Ocultar desktop cuando mobile-mode */
body.mobile-mode > nav,
body.mobile-mode #app,
body.mobile-mode #chat-sidebar { display: none !important; }

/* ── Contenedor principal ─────────────────────── */
#mobile-app {
  display: none;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  position: fixed;
  inset: 0;
  z-index: 100;
  font-family: 'Barlow', system-ui, sans-serif;
}
body.mobile-mode #mobile-app { display: flex; }

/* ── Header ──────────────────────────────────── */
.mob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 2px solid var(--amber);
  flex-shrink: 0;
  min-height: 52px;
}
.mob-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--amber);
}
.mob-logo img { max-height: 32px; max-width: 100px; object-fit: contain; }
.mob-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.mob-user { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; color: var(--text2); }
.mob-user {
  font-size: .75rem;
  color: var(--text2);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mob-cart-btn {
  position: relative;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--text);
  transition: background .15s;
}
.mob-cart-btn:active { background: var(--bg3); }
.mob-cart-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--amber);
  color: #000;
  font-size: .65rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
}

/* ── Área de contenido ───────────────────────── */
.mob-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

/* ── Tabs de contenido ───────────────────────── */
.mob-tab { display: none; height: 100%; flex-direction: column; }
.mob-tab.active { display: flex; }

/* ── Búsqueda de productos ───────────────────── */
.mob-search-wrap {
  padding: 12px 14px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mob-search {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.mob-search:focus { border-color: var(--amber); }

/* ── Resultados ──────────────────────────────── */
.mob-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-product-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color .15s;
  cursor: pointer;
}
.mob-product-card:active { border-color: var(--amber); }
.mob-product-info { flex: 1; min-width: 0; }
.mob-product-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mob-product-code { font-size: .75rem; color: var(--text3); }
.mob-product-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--amber);
  white-space: nowrap;
}
.mob-product-stock { font-size: .75rem; color: var(--text2); }

.mob-qty-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.mob-qty-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background .15s;
}
.mob-qty-btn:active { background: var(--amber); color: #000; }
.mob-qty-val {
  font-size: .95rem;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}
.mob-add-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  font-size: 1.4rem;
  font-weight: 900;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  flex-shrink: 0;
  transition: filter .15s;
}
.mob-add-btn:active { filter: brightness(1.2); }

.mob-empty {
  text-align: center;
  color: var(--text3);
  padding: 48px 24px;
  font-size: .95rem;
  line-height: 1.8;
}

/* ── Carrito ──────────────────────────────────── */
.mob-cart-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-cart-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mob-cart-item-info { flex: 1; min-width: 0; }
.mob-cart-item-name { font-weight: 600; font-size: .9rem; }
.mob-cart-item-sub  { font-size: .78rem; color: var(--text2); margin-top: 2px; }
.mob-cart-item-total{ font-weight: 700; color: var(--amber); white-space: nowrap; }
.mob-cart-item-del  {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--danger, #f87171);
  padding: 4px;
  border-radius: 6px;
  touch-action: manipulation;
}
.mob-cart-footer {
  padding: 14px 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mob-total {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--amber);
}

/* ── Checkout / Cobrar ────────────────────────── */
.mob-checkout-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mob-checkout-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.mob-checkout-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text3);
  margin-bottom: 12px;
}
.mob-pago-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mob-pago-btn {
  padding: 14px 8px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg3);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  transition: all .15s;
}
.mob-pago-btn.selected {
  border-color: var(--amber);
  background: rgba(245,166,35,.12);
  color: var(--amber);
}
.mob-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}
.mob-input:focus { border-color: var(--amber); }
.mob-confirm-btn {
  width: 100%;
  padding: 18px;
  background: var(--amber);
  color: #000;
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  letter-spacing: .5px;
  touch-action: manipulation;
  transition: filter .15s;
  margin-top: 4px;
}
.mob-confirm-btn:active { filter: brightness(1.1); }
.mob-confirm-btn:disabled { opacity: .5; }

/* ── Historial ────────────────────────────────── */
.mob-historial-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-sale-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mob-sale-info { flex: 1; }
.mob-sale-num  { font-size: .75rem; color: var(--text3); font-family: monospace; }
.mob-sale-fecha{ font-size: .8rem; color: var(--text2); }
.mob-sale-tipo { font-size: .75rem; color: var(--text3); }
.mob-sale-total{ font-size: 1rem; font-weight: 700; color: var(--amber); white-space: nowrap; }

/* ── Stock ────────────────────────────────────── */
.mob-stock-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mob-stock-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.mob-stock-card.low-stock { border-color: #f87171; }
.mob-stock-name { font-weight: 600; font-size: .9rem; }
.mob-stock-code { font-size: .75rem; color: var(--text3); }
.mob-stock-qty  {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--green, #4ade80);
  white-space: nowrap;
}
.mob-stock-card.low-stock .mob-stock-qty { color: #f87171; }

/* ── Bottom nav ───────────────────────────────── */
.mob-nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mob-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  transition: color .15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.mob-nav-btn .mob-nav-icon { font-size: 1.3rem; line-height: 1; }
.mob-nav-btn.active { color: var(--amber); }
.mob-nav-btn:active { color: var(--amber); }

/* ── FAB Configuración ───────────────────────── */
.mob-config-fab {
  position: fixed;
  bottom: 72px;   /* justo encima del nav */
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.35);
  z-index: 150;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s, transform .1s;
}
.mob-config-fab:active { transform: scale(.92); }
/* Resaltar cuando el tab config está activo */
body.mobile-mode .mob-config-fab.active {
  background: var(--amber);
  color: #000;
  border-color: var(--amber);
}

/* ── Botón de voz flotante ────────────────────── */
.mob-voice-fab {
  position: fixed;
  bottom: 82px;
  right: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(245,166,35,.45);
  z-index: 200;
  transition: transform .15s, box-shadow .15s;
  touch-action: manipulation;
}
.mob-voice-fab:active { transform: scale(.93); }
.mob-voice-fab.listening {
  animation: mob-pulse 1s ease-in-out infinite;
  background: #ef4444;
  box-shadow: 0 4px 24px rgba(239,68,68,.5);
}
@keyframes mob-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}

/* ── Burbuja de voz ──────────────────────────── */
.mob-voice-bubble {
  position: fixed;
  bottom: 150px;
  left: 16px;
  right: 80px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  z-index: 200;
  font-size: .9rem;
  line-height: 1.5;
  max-height: 40vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.mob-voice-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--amber);
  margin-bottom: 6px;
}
.mob-voice-q  { color: var(--text2); font-size: .85rem; margin-bottom: 8px; }
.mob-voice-a  { color: var(--text); }

/* ── Toast mobile ────────────────────────────── */
.mob-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: .88rem;
  font-weight: 600;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.mob-toast.ok    { color: var(--green, #4ade80); border-color: rgba(74,222,128,.3); }
.mob-toast.error { color: #f87171; border-color: rgba(248,113,113,.3); }
.mob-toast.info  { color: var(--amber); border-color: rgba(245,166,35,.3); }
.mob-toast.show  { opacity: 1; }

/* ── Chat ────────────────────────────────────── */
.mob-chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mob-chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}
.mob-chat-bubble.mob-chat-user    { align-self: flex-end; align-items: flex-end; }
.mob-chat-bubble.mob-chat-assistant { align-self: flex-start; }
.mob-chat-bubble-inner {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.mob-chat-user .mob-chat-bubble-inner {
  background: var(--amber);
  color: #000;
  border-bottom-right-radius: 4px;
}
.mob-chat-assistant .mob-chat-bubble-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.mob-chat-typing .mob-chat-bubble-inner {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text3);
  font-style: italic;
}
.mob-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.mob-chat-voice-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  touch-action: manipulation;
}
.mob-chat-voice-btn.listening {
  background: #ef4444;
  border-color: #ef4444;
  animation: mob-pulse 1s ease-in-out infinite;
}
.mob-chat-voice-btn.speaking {
  background: var(--amber);
  border-color: var(--amber);
}
.mob-chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 9px 14px;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}
.mob-chat-input:focus { border-color: var(--amber); }
.mob-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
}

/* ── Configuración ───────────────────────────── */
.mob-config-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.mob-config-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.mob-config-title {
  font-weight: 700;
  font-size: .82rem;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}
.mob-config-label {
  display: block;
  font-size: .78rem;
  color: var(--text2);
  margin: 8px 0 4px;
}
.mob-config-label:first-of-type { margin-top: 0; }

/* ── Action sheet botones ────────────────────── */
.mob-sheet-btn {
  width: 100%;
  padding: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  font-family: inherit;
}
.mob-sheet-btn:active { opacity: .75; }

/* ── Inputs sin zoom en iOS ──────────────────── */
@media screen and (max-width: 768px) {
  input[type="text"], input[type="email"],
  input[type="number"], input[type="password"],
  input[type="search"], select, textarea {
    font-size: 16px !important;
  }
}
