/* ============================================================
   MiKiosco WebApp — main.css
   Diseno responsive mobile-first, mismo estilo que la app Android
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:           #0F0F14;
  --surface:      #1A1A24;
  --surface-2:    #22222E;
  --border:       #2A2A3A;

  --yellow:       #F5C842;
  --yellow-dim:   rgba(245, 200, 66, 0.18);
  --yellow-dark:  #C9A21A;

  --green:        #4CAF82;
  --green-dim:    rgba(76, 175, 130, 0.18);

  --red:          #F5524A;
  --red-dim:      rgba(245, 82, 74, 0.18);

  --blue:         #5B8CF5;
  --blue-dim:     rgba(91, 140, 245, 0.18);

  --bs-usd:       #4FC3F7;
  --bs-eur:       #E1A8FF;

  --text:         #E8E8F0;
  --text-dim:     #B8B8C8;
  --muted:        #7878A0;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
  --radius-xl:    20px;

  --shadow:       0 4px 12px rgba(0,0,0,0.4);

  --topbar-h:     60px;
  --bottombar-h:  64px;
  --content-max:  1100px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; padding: 0; }
input, textarea, select { background: none; border: none; outline: none; }
ul, ol { list-style: none; padding: 0; margin: 0; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }

[hidden] { display: none !important; }

/* ── Splash ────────────────────────────────────────────────── */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; background: var(--bg); z-index: 9999;
}
.splash-logo { font-size: 64px; }
.splash-title {
  font-size: 22px; font-weight: 700;
  color: var(--yellow); letter-spacing: 1px;
}

/* ── Spinners ──────────────────────────────────────────────── */
.spinner, .spinner-sm {
  border-radius: 50%;
  border-style: solid;
  border-color: var(--border);
  border-top-color: var(--yellow);
  animation: spin 0.8s linear infinite;
}
.spinner    { width: 36px; height: 36px; border-width: 4px; }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screen layout ─────────────────────────────────────────── */
.screen { min-height: 100vh; }

/* ── Login ─────────────────────────────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-logo {
  font-size: 56px; text-align: center; margin-bottom: 8px;
}
.login-title {
  font-size: 28px; text-align: center;
  color: var(--yellow); margin-bottom: 4px;
  letter-spacing: 1px;
}
.login-subtitle {
  text-align: center; color: var(--muted);
  margin: 0 0 24px; font-size: 13px;
}
.login-footer {
  text-align: center; color: var(--muted);
  margin-top: 20px; font-size: 11px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  color: var(--text-dim); font-size: 12px;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-control, .form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
  border-color: var(--yellow);
  background: rgba(245, 200, 66, 0.04);
}
.form-group input::placeholder,
.form-control::placeholder { color: var(--muted); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-help { font-size: 11px; color: var(--muted); margin-top: 4px; }

.password-wrap { position: relative; }
.pwd-toggle {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); font-size: 18px;
  cursor: pointer; color: var(--muted);
}

.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  border: 1px solid transparent;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { display: flex; width: 100%; }

.btn-primary { background: var(--yellow); color: #111; }
.btn-primary:hover:not(:disabled) { background: #FFD84A; transform: translateY(-1px); }

.btn-success { background: var(--green); color: #111; }
.btn-success:hover:not(:disabled) { background: #5FD198; }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #FF6A60; }

.btn-outline {
  background: transparent; color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--yellow); color: var(--yellow);
}

.btn-ghost {
  background: transparent; color: var(--text-dim);
}
.btn-ghost:hover:not(:disabled) { color: var(--yellow); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 22px; font-size: 15px; }

.btn-spinner { margin-left: 6px; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-avatar {
  width: 38px; height: 38px;
  background: var(--yellow-dim); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-tienda {
  font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.version-badge {
  background: var(--yellow-dim); color: var(--yellow);
  font-size: 9px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px;
}
.topbar-right { display: flex; gap: 4px; align-items: center; }

/* BCV indicator pill */
.bcv-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 10px;
  font-size: 10px; font-weight: 700;
  color: var(--yellow);
  transition: all 0.15s;
  white-space: nowrap;
}
.bcv-pill:hover { border-color: var(--yellow); }
.bcv-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--yellow); flex-shrink: 0;
}
.bcv-pill.loaded .bcv-dot { background: var(--green); }
.bcv-pill.error  .bcv-dot { background: var(--red); }
@media (max-width: 480px) {
  .bcv-pill #bcv-pill-txt { display: none; }
}
.icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  font-size: 18px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn-danger:hover { background: var(--red-dim); }

/* ── Banner ────────────────────────────────────────────────── */
.banner {
  padding: 8px 16px;
  font-size: 12px; font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.banner-warning { background: #F57F17; color: #fff; }
.banner-danger  { background: #B71C1C; color: #fff; }
.banner-info    { background: var(--blue-dim); color: var(--blue); }

/* ── Layout view ───────────────────────────────────────────── */
.view-container {
  min-height: calc(100vh - var(--topbar-h) - var(--bottombar-h));
  padding: 14px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-bottom: calc(var(--bottombar-h) + 20px);
}

/* ── Bottom navigation ─────────────────────────────────────── */
.bottombar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottombar-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around;
  z-index: 100;
}
.nav-item {
  flex: 1; max-width: 100px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  color: var(--muted);
  transition: color 0.15s;
}
.nav-item.active { color: var(--yellow); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; }

.footer {
  padding: 10px 16px;
  font-size: 10px; color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}
.card-row {
  display: flex; justify-content: space-between;
  align-items: center; gap: 10px;
}
.card-title {
  font-size: 14px; font-weight: 700;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 11px; color: var(--muted);
}

/* ── Stats grid ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.stat-label {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}
.stat-value {
  font-size: 20px; font-weight: 800;
  margin-top: 4px;
}
.stat-value.red    { color: var(--red); }
.stat-value.green  { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.blue   { color: var(--blue); }

/* ── Producto card / lista ─────────────────────────────────── */
.producto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  display: flex; gap: 12px; align-items: center;
}
.producto-emoji {
  font-size: 28px; flex-shrink: 0;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: var(--radius);
}
.producto-info { flex: 1; min-width: 0; }
.producto-nombre {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.producto-categoria {
  font-size: 11px; color: var(--muted);
}
.producto-stock-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 12px; font-size: 10px; font-weight: 700;
  margin-top: 4px;
}
.stock-ok    { background: var(--green-dim); color: var(--green); }
.stock-bajo  { background: var(--yellow-dim); color: var(--yellow); }
.stock-cero  { background: var(--red-dim); color: var(--red); }

.producto-precio { text-align: right; flex-shrink: 0; }
.producto-stock-num {
  font-size: 22px; font-weight: 800; color: var(--text);
}
.precio-usd {
  font-size: 14px; font-weight: 700; color: var(--text);
}
.precio-bs {
  font-size: 11px; font-weight: 600;
}
.precio-bs.usd { color: var(--bs-usd); }
.precio-bs.eur { color: var(--bs-eur); }

.producto-actions { display: flex; gap: 6px; }
.action-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s;
}
.action-btn:hover { border-color: var(--yellow); }
.action-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ── Buscador ──────────────────────────────────────────────── */
.search-wrap {
  position: relative; margin-bottom: 14px;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 10px 40px;
  color: var(--text);
  font-size: 14px;
}
.search-input:focus { border-color: var(--yellow); }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--muted);
  font-size: 16px; pointer-events: none;
}

/* ── Filter chips ──────────────────────────────────────────── */
.chip-row {
  display: flex; gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  color: var(--text-dim);
  transition: all 0.15s;
}
.chip.active {
  background: var(--yellow); color: #111;
  border-color: var(--yellow);
}

/* ── Carrito ───────────────────────────────────────────────── */
.cart-summary {
  position: sticky; bottom: calc(var(--bottombar-h) + 6px);
  background: var(--surface);
  border: 1px solid var(--yellow);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}
.cart-empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.cart-row {
  display: flex; justify-content: space-between;
  align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.cart-row:last-child { border-bottom: none; }
.cart-item-name { font-weight: 600; font-size: 13px; }
.cart-item-qty {
  display: flex; align-items: center; gap: 6px;
}
.qty-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px; font-weight: 700;
}

/* ── BCV / Equivalencias ───────────────────────────────────── */
.bcv-box {
  background: var(--yellow-dim);
  border: 1px solid rgba(245, 200, 66, 0.4);
  border-radius: var(--radius);
  padding: 12px; margin: 10px 0;
}
.bcv-title {
  font-size: 11px; color: var(--yellow);
  font-weight: 700; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.bcv-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 2px 0;
}
.bcv-row .label { color: var(--text-dim); font-weight: 600; }
.bcv-row .value { font-weight: 700; }

/* ── Snackbar ──────────────────────────────────────────────── */
.snackbar {
  position: fixed; bottom: calc(var(--bottombar-h) + 16px);
  left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px; font-weight: 600;
  z-index: 1000;
  max-width: 90vw;
  box-shadow: var(--shadow);
  animation: snackin 0.25s;
}
.snackbar.success { border-color: var(--green); color: var(--green); }
.snackbar.error   { border-color: var(--red);   color: var(--red); }
@keyframes snackin {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  padding: 22px;
  animation: modalin 0.25s;
}
@keyframes modalin {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 12px; color: var(--yellow);
}
.modal-actions {
  display: flex; gap: 8px; margin-top: 18px;
}
.modal-actions .btn { flex: 1; }

.modal-fullscreen {
  background: #000;
  width: 100vw; max-width: 100vw;
  height: 100vh; max-height: 100vh;
  border-radius: 0; padding: 0;
  display: flex; flex-direction: column;
}
.modal-fullscreen img {
  width: 100%; height: 100%;
  object-fit: contain; flex: 1;
}
.modal-close-fs {
  position: absolute; top: 12px; right: 12px;
  width: 44px; height: 44px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%; color: #fff;
  font-size: 24px; z-index: 10;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin: 10px 0;
}
.alert-error   { background: var(--red-dim);   color: var(--red);   border: 1px solid rgba(245,82,74,0.3); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(76,175,130,0.3); }
.alert-info    { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,200,66,0.3); }

/* ── Empty state ───────────────────────────────────────────── */
.empty {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ── Factura card ──────────────────────────────────────────── */
.factura-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--yellow);
  border-radius: var(--radius-lg);
  padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: border-color 0.15s;
}
.factura-card:hover { border-color: var(--yellow); }
.factura-card.vencida { border-left-color: var(--red); }
.factura-card.pagada  { border-left-color: var(--green); }

.factura-header {
  display: flex; justify-content: space-between;
  align-items: start; gap: 8px; margin-bottom: 8px;
}
.factura-proveedor { font-weight: 700; font-size: 14px; }
.factura-numero { font-size: 11px; color: var(--muted); }
.factura-badge {
  padding: 3px 10px; border-radius: 12px;
  font-size: 10px; font-weight: 700;
  white-space: nowrap;
}

.factura-monto-block {
  display: flex; justify-content: space-between;
  align-items: end; gap: 10px;
}
.factura-monto {
  font-size: 22px; font-weight: 800;
}
.factura-bs-line {
  font-size: 11px; font-weight: 600;
}
.factura-bs-line.usd { color: var(--bs-usd); }
.factura-bs-line.eur { color: var(--bs-eur); }
.factura-fecha {
  font-size: 11px; margin-top: 4px;
  color: var(--muted);
}
.factura-fecha.warning { color: var(--yellow); }
.factura-fecha.vencida { color: var(--red); }
.factura-fecha.pagada  { color: var(--green); }

.progress-bar {
  height: 5px; background: var(--surface-2);
  border-radius: 3px; overflow: hidden; margin-top: 10px;
}
.progress-fill {
  height: 100%; background: var(--green);
  transition: width 0.3s;
}
.progress-info {
  display: flex; justify-content: space-between;
  font-size: 10px; font-weight: 700; margin-top: 4px;
}

.factura-actions {
  display: flex; gap: 6px; margin-left: auto;
}

/* ── Tabla ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; overflow-x: auto;
}
.table {
  width: 100%; border-collapse: collapse;
}
.table th {
  background: var(--surface-2);
  padding: 10px 12px; text-align: left;
  font-size: 11px; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  white-space: nowrap;
}
.table td {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.table tr:hover td { background: var(--surface-2); }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.tab {
  padding: 10px 16px; font-size: 13px;
  font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab.active { color: var(--yellow); border-bottom-color: var(--yellow); }

/* ── Floating action button (FAB) ──────────────────────────── */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottombar-h) + 16px);
  background: var(--yellow); color: #111;
  border-radius: 28px;
  padding: 14px 20px;
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow);
  z-index: 50;
  transition: transform 0.15s;
}
.fab:hover { transform: translateY(-2px); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (min-width: 768px) {
  .view-container { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .producto-card { padding: 14px 18px; }
  .producto-emoji { width: 52px; height: 52px; font-size: 32px; }
  .producto-nombre { font-size: 15px; }
}

@media (min-width: 1024px) {
  body { font-size: 15px; }
  .topbar { padding: 0 24px; }
  .modal { max-width: 600px; }
  .modal.modal-wide { max-width: 900px; }
}

/* Forzar tap target minimo en movil */
@media (pointer: coarse) {
  .btn, .icon-btn, .action-btn, .nav-item, .chip { min-height: 40px; }
}

/* Scroll suave */
html { scroll-behavior: smooth; }

/* Prevenir zoom de iOS al hacer focus en input */
@media screen and (max-width: 600px) {
  input, select, textarea { font-size: 16px; }
}

/* Hide scrollbar pero permitir scroll */
.scroll-y { overflow-y: auto; }
.scroll-y::-webkit-scrollbar { width: 6px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
