/* ============================================
   BODEGA APP — Identidad Profesional
   Teal + Amber, moderno, mobile-first
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --primary-glow: rgba(13, 148, 136, 0.15);
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-alt: #f5f5f4;
  --text: #0c0a09;
  --text-secondary: #44403c;
  --text-muted: #a8a29e;
  --text-muted-light: #d6d3d1;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,.08), 0 4px 10px -4px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 40px -8px rgba(0,0,0,.12);
  --nav-height: 68px;
  --header-height: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

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

/* ============================================
   SCREENS
   ============================================ */
.screen { display: none; }
.screen.active { display: block; }

/* ============================================
   LOGIN — Pantalla completa con fondo
   ============================================ */
#screen-login {
  display: none;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0f172a 0%, #134e4a 50%, #0d9488 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

#screen-login::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: radial-gradient(ellipse at 30% 20%, rgba(13, 148, 136, 0.15) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 50%);
  pointer-events: none;
}

#screen-login.active { display: flex; }

.login-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 44px 32px 36px;
  box-shadow: var(--shadow-xl);
  text-align: center;
  border: 1px solid rgba(255,255,255,.1);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.login-brand-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #0d9488, #0f766e);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.25);
  margin-bottom: 16px;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}

.login-title span { color: var(--primary); }

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 4px 0 32px;
  font-weight: 400;
}

.login-form { text-align: left; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.form-group input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: all .2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-group input::placeholder { color: var(--text-muted-light); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  text-align: center;
  padding: 10px;
  background: var(--danger-bg);
  border-radius: var(--radius-xs);
  display: none;
}

.login-error:not(.hidden) { display: block; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(13, 148, 136, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) { transform: scale(.97); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 8px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: var(--danger); color: white; }

.btn-success {
  background: linear-gradient(135deg, var(--success), #15803d);
  color: white;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.btn-success:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(22, 163, 74, 0.4); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}

.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

/* ============================================
   APP LAYOUT
   ============================================ */
#screen-app {
  padding-top: var(--header-height);
  padding-bottom: calc(var(--nav-height) + 20px);
  min-height: 100dvh;
}

/* HEADER */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 6px; }

.header-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-right: 4px;
}

.header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-title span { color: var(--primary); }

.header-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  line-height: 1;
  transition: all .2s;
}

.header-btn:hover { background: var(--surface-alt); color: var(--text); }

/* BOTTOM NAV */
.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: center;
  justify-content: space-around;
  padding: 0 4px;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text-muted-light);
  transition: all .2s;
  min-width: 52px;
  position: relative;
}

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

.nav-item.active::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

.nav-icon { font-size: 22px; line-height: 1; transition: transform .2s; }
.nav-item.active .nav-icon { transform: scale(1.1); }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2px; }

/* ============================================
   CONTENT
   ============================================ */
.app-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  animation: fadeIn .2s ease;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  border: 1px solid var(--border-light);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-subtitle { font-size: 12px; color: var(--text-muted); }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow-sm);
  text-align: center;
  border: 1px solid var(--border-light);
  transition: all .2s;
}

.stat-card:active { transform: scale(.97); }

.stat-icon { font-size: 24px; margin-bottom: 6px; display: block; }

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.stat-good { color: var(--success); }
.stat-warn { color: var(--warning); }
.stat-bad { color: var(--danger); }

/* Highlight card */
.card-highlight {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
}

.card-highlight .card-title { color: rgba(255,255,255,.85); }
.card-highlight .stat-value { color: white; }
.card-highlight .stat-label { color: rgba(255,255,255,.7); }

/* ============================================
   LISTS
   ============================================ */
.item-list { list-style: none; }

.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.item-list li:last-child { border-bottom: none; }

.item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.item-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.item-value {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

/* ============================================
   SEARCH
   ============================================ */
.search-bar {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px 50% no-repeat;
  margin-bottom: 14px;
  outline: none;
  transition: all .2s;
}

.search-bar:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  gap: 4px;
}

.badge-success { background: var(--success-bg); color: #15803d; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); }

/* ============================================
   MODAL (Bottom Sheet)
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  animation: fadeIn .2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.22,1,.36,1);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: -12px auto 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  float: right;
  background: var(--surface-alt);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.modal-close:hover { background: var(--border); color: var(--text); }

/* ============================================
   POS / VENTAS
   ============================================ */
.pos-products {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.pos-product {
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}

.pos-product:active {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(.96);
}

.pos-product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.pos-product-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  margin-top: 3px;
  letter-spacing: -0.3px;
}

.pos-product-stock {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Cart */
.cart-container {
  background: linear-gradient(135deg, var(--bg), var(--surface));
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-header-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-header-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 4px 10px;
  border-radius: 20px;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.cart-item:last-child { border-bottom: none; }

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-rate {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.cart-item-qty-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: all .15s;
}

.cart-item-qty-btn:active { background: var(--surface-alt); }

.cart-item-qty-value {
  font-size: 15px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.cart-item-subtotal {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  margin-left: 12px;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--text-muted-light);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all .15s;
}

.cart-item-remove:hover { color: var(--danger); background: var(--danger-bg); }

.cart-total {
  display: flex;
  justify-content: space-between;
  padding: 16px 0 12px;
  border-top: 2px solid var(--text);
  margin-top: 4px;
}

.cart-total-label { font-size: 16px; font-weight: 600; }

.cart-total-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Payment methods */
.payment-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 16px;
}

.payment-btn {
  padding: 12px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}

.payment-btn:hover { border-color: var(--primary-light); }

.payment-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ============================================
   TYPOGRAPHY HELPERS
   ============================================ */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* ============================================
   LOADING
   ============================================ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 12px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
  #screen-login { padding: 48px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .pos-products { grid-template-columns: repeat(4, 1fr); }
  .payment-methods { grid-template-columns: repeat(4, 1fr); }

  .bottom-nav {
    max-width: 400px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
