/* =====================================================
   ListaFácil v2 — styles.css
   ===================================================== */

.font-syne { font-family: 'Syne', sans-serif; }
html, body { overflow-x: hidden; max-width: 100%; }
body { font-family: 'DM Sans', sans-serif; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Inputs ── */
.input-field {
  width: 100%;
  background: #1e1e28;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.input-field:focus { border-color: #7c6fff; }
.input-field::placeholder { color: #6b7280; }
select.input-field { cursor: pointer; }

/* ── Buttons ── */
.btn-primary {
  padding: 12px;
  background: #7c6fff;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
  cursor: pointer;
}
.btn-primary:hover { background: #9285ff; }
.btn-secondary {
  padding: 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  color: #d1d5db;
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s;
  cursor: pointer;
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }
.icon-close {
  color: #9ca3af;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  cursor: pointer;
}
.icon-close:hover { background: rgba(255,255,255,0.08); color: white; }

/* ── Action buttons in header ── */
.action-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  color: #9ca3af;
  transition: all 0.15s;
  cursor: pointer;
}
.action-btn:hover { background: rgba(255,255,255,0.10); color: white; }
.action-btn.danger { background: rgba(239,68,68,0.10); }
.action-btn.danger:hover { background: rgba(239,68,68,0.20); }

/* ── Modal ── */
.modal-card {
  background: #1a1a24;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  animation: modal-in 0.18s ease;
  max-height: 92vh;
  overflow-y: auto;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Tabs ── */
.tab-active {
  background: rgba(124,111,255,0.2);
  color: #a99fff;
  font-weight: 600;
}
.tab-inactive {
  color: #6b7280;
}
.tab-inactive:hover { color: #9ca3af; }

/* ── Stat cards ── */
.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 10px 14px;
}
.stat-card.over-budget {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.06);
}

/* ── Sidebar list items ── */
.list-item-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  transition: background 0.15s; text-align: left;
}
.list-item-btn:hover { background: rgba(255,255,255,0.05); }
.list-item-btn.active { background: rgba(124,111,255,0.15); }
.list-item-btn.active .list-item-name { color: #a99fff; }
.list-item-name { flex: 1; font-size: 14px; font-weight: 500; color: #d1d5db; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-count { font-size: 11px; background: rgba(255,255,255,0.08); color: #9ca3af; border-radius: 99px; padding: 1px 7px; min-width: 22px; text-align: center; }
.list-item-btn.active .list-item-count { background: rgba(124,111,255,0.25); color: #a99fff; }

/* ── Admin / reports ── */
.admin-create-grid { display: grid; grid-template-columns: 1fr 1.2fr 1fr auto; gap: 10px; }
.admin-users-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.admin-user-row {
  display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
}
.status-pill { font-size: 11px; font-weight: 700; border-radius: 99px; padding: 4px 8px; }
.status-pill.ok { color: #34d399; background: rgba(16,185,129,0.12); }
.status-pill.off { color: #f87171; background: rgba(239,68,68,0.12); }
.report-heading { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: #ffffff; margin-bottom: 10px; }
.report-list { display: flex; flex-direction: column; gap: 6px; }
.report-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  color: #d1d5db; font-size: 14px;
}
.report-row strong { color: #ffffff; white-space: nowrap; }

/* ── Item cards ── */
.item-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  transition: all 0.15s;
  animation: item-in 0.18s ease;
  position: relative;
  touch-action: pan-y;
  will-change: transform;
}
.item-card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.item-card.swipe-right::before { opacity: 1; background: linear-gradient(90deg, rgba(16,185,129,0.24), rgba(16,185,129,0)); }
.item-card.swipe-left::before { opacity: 1; background: linear-gradient(270deg, rgba(239,68,68,0.24), rgba(239,68,68,0)); }
.item-card.swipe-reset { transition: transform 0.16s ease, background 0.15s, border-color 0.15s; }
.item-card.swipe-commit { transition: transform 0.09s ease, opacity 0.09s ease; opacity: 0.55; }
.item-card:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.10); }
.item-card.purchased { opacity: 0.50; background: rgba(16,185,129,0.04); border-color: rgba(16,185,129,0.12); }
.item-card.purchased .item-name { text-decoration: line-through; color: #6b7280; }
.item-card.dragging { opacity: 0.35; border: 1.5px dashed rgba(124,111,255,0.4); cursor: grabbing; }
.item-card.drag-over { border-color: rgba(124,111,255,0.6); box-shadow: 0 0 0 2px rgba(124,111,255,0.2); }
@keyframes item-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ── Checkbox ── */
.check-btn {
  width: 22px; height: 22px; border-radius: 7px;
  border: 1.5px solid rgba(255,255,255,0.20);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0; cursor: pointer;
}
.check-btn:hover { border-color: rgba(124,111,255,0.6); }
.check-btn.checked { background: rgba(16,185,129,0.85); border-color: transparent; }
.check-btn svg { display: none; }
.check-btn.checked svg { display: block; }

/* ── Drag handle ── */
.drag-handle { color: rgba(255,255,255,0.12); cursor: grab; flex-shrink: 0; }
.drag-handle:hover { color: rgba(255,255,255,0.30); }

/* ── Item action buttons ── */
.item-actions { display: flex; gap: 3px; opacity: 0; transition: opacity 0.15s; }
.item-card:hover .item-actions { opacity: 1; }
@media (max-width: 640px) { .item-actions { opacity: 1; } }
.icon-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 7px; transition: background 0.15s; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn.danger:hover { background: rgba(239,68,68,0.15); }
.icon-btn.danger:hover svg { color: #f87171; }

/* ── Category separator ── */
.cat-separator { display: flex; align-items: center; gap: 8px; padding: 12px 2px 4px; }
.cat-separator-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.cat-separator-line { flex: 1; height: 1px; background: rgba(255,255,255,0.05); }

/* ── Progress bar ── */
.progress-bar-track { height: 4px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, #7c6fff, #a78bfa); border-radius: 99px; transition: width 0.4s ease; }
.progress-bar-fill.over { background: linear-gradient(90deg, #ef4444, #f97316); }

/* ── Scanner ── */
.scanner-overlay {
  position: absolute; inset: 0;
  box-shadow: inset 0 0 0 2000px rgba(0,0,0,0.4);
}
.scanner-line {
  position: absolute; left: 15%; right: 15%; top: 50%;
  height: 2px; background: #7c6fff;
  box-shadow: 0 0 8px #7c6fff;
  animation: scan-line 1.8s ease-in-out infinite;
}
@keyframes scan-line {
  0%   { transform: translateY(-40px); opacity: 0.5; }
  50%  { opacity: 1; }
  100% { transform: translateY(40px); opacity: 0.5; }
}

/* ── Toasts ── */
#toast-container { position: fixed; bottom: 20px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #22222e; border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 10px 16px; font-size: 13px; color: #e5e7eb; box-shadow: 0 8px 30px rgba(0,0,0,0.3); animation: toast-in 0.25s ease forwards; pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: 280px; }
.toast.success { border-left: 3px solid #10b981; }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.info    { border-left: 3px solid #7c6fff; }
.toast.warn    { border-left: 3px solid #f59e0b; }
.toast.removing { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in  { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
@keyframes toast-out { from { opacity:1; transform: translateY(0); }    to { opacity:0; transform: translateY(8px); } }

/* ── Sidebar mobile ── */
#sidebar.open { transform: translateX(0); }

/* ── Budget btn highlight when set ── */
#btn-budget.has-budget { background: rgba(124,111,255,0.20); color: #a99fff; }

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

/* ── Safe area (notch / Dynamic Island) ── */
.safe-top { padding-top: calc(1rem + env(safe-area-inset-top)) !important; }

/* ── Splash screen ── */
.splash-screen {
  position: fixed; inset: 0; z-index: 200;
  background: #0f0f13;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px;
  transition: opacity 0.35s ease;
}
.splash-logo { animation: splash-pop 0.5s cubic-bezier(.2,.9,.3,1.3); }
.splash-title {
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; color: #ffffff;
  letter-spacing: 0.01em;
}
.splash-screen.splash-hide { opacity: 0; pointer-events: none; }
@keyframes splash-pop { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }

/* ── Bottom nav (mobile) ── */
.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40;
  display: flex; align-items: center; justify-content: space-around;
  background: #1a1a24;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  padding: 6px 8px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.bottom-nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; flex: 1; min-width: 44px; min-height: 44px;
  padding: 4px; border-radius: 14px;
  color: #6b7280; background: transparent; transition: color 0.15s;
}
.bottom-nav-btn svg { width: 21px; height: 21px; }
.bottom-nav-btn span { font-size: 10.5px; font-weight: 500; }
.bottom-nav-btn:hover, .bottom-nav-btn:active { color: #a99fff; }
.bottom-nav-center {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  margin: 0 4px;
  background: linear-gradient(155deg, #9285ff, #7c6fff);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(124,111,255,0.55), 0 0 0 5px #0f0f13;
  transform: translateY(-14px);
  transition: transform 0.15s;
}
.bottom-nav-center svg { width: 24px; height: 24px; }
.bottom-nav-center:active { transform: translateY(-14px) scale(0.93); }

/* ── Bottom sheets (mobile) ── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.6);
  align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 480px;
  background: #1a1a24;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-in 0.22s ease;
}
.sheet-handle { width: 36px; height: 4px; background: rgba(255,255,255,0.15); border-radius: 99px; margin: 4px auto 14px; }
.sheet-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; color: #ffffff; margin-bottom: 10px; padding: 0 4px; }
.sheet-action {
  width: 100%; display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 12px; border-radius: 14px;
  color: #e5e7eb; font-size: 15px; font-weight: 500; text-align: left;
  transition: background 0.15s;
}
.sheet-action:hover, .sheet-action:active { background: rgba(255,255,255,0.06); }
.sheet-action.danger { color: #f87171; }
.sheet-cancel {
  width: 100%; text-align: center; padding: 14px; margin-top: 6px;
  color: #9ca3af; font-size: 14px; font-weight: 600;
  border-top: 1px solid rgba(255,255,255,0.06);
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Mobile scroll clearance para el bottom nav flotante ── */
@media (max-width: 1023.98px) {
  .mobile-scroll-pad { padding-bottom: calc(104px + env(safe-area-inset-bottom)) !important; }

  /* Tap targets minimos ~44px y precios mas legibles en mobile */
  .icon-btn { width: 44px; height: 44px; }
  .check-btn { width: 44px; height: 44px; border-radius: 12px; }
  .action-btn { width: 44px; height: 44px; }
  .item-card { padding: 10px; gap: 8px; min-height: 68px; }
  .item-actions { opacity: 1; gap: 1px; }
  .item-subtotal { font-size: 18px !important; }

  /* El drag&drop nativo (HTML5) no funciona por touch en mobile: el handle
     ocupa espacio sin cumplir su funcion, asi que se oculta para ganar ancho. */
  .drag-handle { display: none; }
  .admin-create-grid { grid-template-columns: 1fr; }
  .admin-user-row { grid-template-columns: minmax(0,1fr); }
  .admin-user-row .btn-secondary { width: 100%; }
}

@media (max-width: 640px) {
  #modal-overlay.flex {
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
  }
  .modal-card {
    max-width: none !important;
    width: 100% !important;
    max-height: calc(92vh - env(safe-area-inset-top));
    overflow-y: auto;
    border-radius: 24px 24px 0 0;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    animation: modal-sheet-in 0.22s ease;
  }
  @keyframes modal-sheet-in { from { opacity: 1; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
}

/* ── Respeta prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .modal-card, .item-card, .sheet-card, .scanner-line, .toast {
    animation: none !important;
  }
  .splash-screen, .bottom-nav-center, .bottom-nav-btn, .icon-btn, .check-btn, .item-card {
    transition: none !important;
  }
}
