/* Panel de administración — diseño tipo aplicación (sidebar en computadora, barra inferior en móvil) */
body.admin-page {
  --bg: #07070a;
  --bg-card: #101015;
  --bg-raised: #14141a;
  --border: #24242c;
  --border-soft: #1b1b22;
  --text: #f5f5f7;
  --text-dim: #8d8d99;
  --accent: #ff2d55;
  --accent-soft: rgba(255, 45, 85, 0.13);
  --ok: #22c55e;
  --radius: 16px;
  --side-w: 252px;
  --side-bg: linear-gradient(180deg, #0c0c10, #09090c);
  --header-bg: rgba(7, 7, 10, 0.85);
  --bottom-bg: rgba(10, 10, 14, .92);
  --glow: rgba(255, 45, 85, 0.09);
  --soft: rgba(255,255,255,.04);
  --shadow: 0 12px 30px rgba(0,0,0,.25);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(1000px 420px at 80% -8%, var(--glow), transparent 60%), var(--bg);
  background-attachment: fixed;
}

/* ---------- Barra superior ---------- */
.admin-page .admin-header {
  position: sticky; top: 0; z-index: 30;
  max-width: none; margin: 0;
  padding: 12px 20px;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.admin-page .admin-header .logo img { height: 36px; width: 36px; border-radius: 10px; }
.admin-page .admin-header h1 { font-size: 1.05rem; font-weight: 700; }
.admin-page .btn-logout { border-radius: 10px; padding: 8px 14px; font-size: 0.8rem; color: var(--text-dim); background: var(--bg-card); }
.admin-page .btn-logout:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Login ---------- */
.admin-page .login-screen { padding: 12vh 20px; }
.admin-page .login-form {
  max-width: 380px; padding: 34px 30px; border-radius: 20px;
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-card));
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.admin-page .login-form h2 { font-size: 1.35rem; margin-bottom: 10px; }

/* ---------- Estructura ---------- */
.admin-page .admin-panel { display: block; max-width: none; margin: 0; padding: 0; gap: 0; }
.app-content { max-width: 1120px; margin: 0 auto; padding: 22px 20px 110px; }

.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w);
  z-index: 40;
  display: none;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--side-bg);
  border-right: 1px solid var(--border-soft);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 26px; }
.sidebar-brand img { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; }
.sidebar-brand strong { display: block; font-size: 1.15rem; font-weight: 800; letter-spacing: .2px; }
.sidebar-brand small { display: block; font-size: .58rem; letter-spacing: 1.3px; color: var(--text-dim); margin-top: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 13px 16px; border-radius: 12px;
  font-weight: 500; font-size: .95rem; font-family: inherit; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 21px; height: 21px; flex-shrink: 0; }
.nav-item:hover { color: var(--text); background: var(--soft); }
.nav-item.active {
  color: #fff; font-weight: 700;
  background: linear-gradient(90deg, rgba(255,45,85,.34), rgba(255,45,85,.12));
  border-color: rgba(255,45,85,.28);
}
.nav-item.active svg { color: var(--accent); }
.sidebar-store {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px; border-radius: 12px; border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-size: .9rem; background: var(--bg-card);
  transition: border-color .15s;
}
.sidebar-store:hover { border-color: var(--accent); }
.sidebar-store svg { width: 18px; height: 18px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--bottom-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: none; color: var(--text-dim);
  padding: 8px 4px; border-radius: 14px; max-width: 90px;
  font-weight: 500; font-size: .68rem; font-family: inherit; cursor: pointer;
}
.bnav-item svg { width: 22px; height: 22px; }
.bnav-item.active { color: var(--accent); background: var(--accent-soft); }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  body.is-auth .admin-header { margin-left: var(--side-w); }
  body.is-auth .admin-header .logo { display: none; }
  body.is-auth .admin-panel { margin-left: var(--side-w); }
  .app-content { padding-bottom: 60px; }
}

/* ---------- Vistas ---------- */
.view-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -.3px; margin-bottom: 18px; }
.view > .admin-section + .admin-section { margin-top: 18px; }
.sub-h { font-size: 1rem !important; }

.hero-title { font-size: 2.1rem; font-weight: 800; letter-spacing: -.8px; }
.hero-sub { color: var(--text-dim); margin-top: 4px; }
.view-hero { margin-bottom: 14px; }
.note { margin-bottom: 16px; }

/* ---------- Tarjetas ---------- */
.admin-page .admin-section {
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03), var(--shadow);
}
.admin-page .admin-section h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.05rem; font-weight: 700; margin-bottom: 18px;
}
.admin-page .admin-section h2::before { content: none; }
.admin-page .section-toggle-header { margin-bottom: 16px; }
.admin-page .section-toggle-header h2 { margin-bottom: 0; }

/* ---------- Estadísticas ---------- */
.admin-page .stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.admin-page .stat-card {
  flex-direction: row; align-items: center; gap: 14px;
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-card));
  border: 1px solid var(--border); border-radius: 14px; padding: 18px;
  overflow: visible;
}
.admin-page .stat-card::after { content: none; }
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.stat-icon svg { width: 22px; height: 22px; }
.ic-red { background: linear-gradient(135deg, #ff4d6d, #e11d48); box-shadow: 0 8px 20px rgba(225,29,72,.35); }
.ic-green { background: linear-gradient(135deg, #34d399, #16a34a); box-shadow: 0 8px 20px rgba(34,197,94,.3); }
.ic-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 8px 20px rgba(59,130,246,.3); }
.ic-amber { background: linear-gradient(135deg, #fbbf24, #ea580c); box-shadow: 0 8px 20px rgba(245,158,11,.3); }
.stat-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.admin-page .stat-value { font-size: 1.55rem; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.admin-page .stat-label { font-size: .75rem; text-transform: none; letter-spacing: 0; color: var(--text-dim); }

.inicio-grid { display: grid; grid-template-columns: 1fr 1fr 290px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .inicio-grid { grid-template-columns: 1fr 1fr; } .quick-actions { grid-column: 1 / -1; } }
@media (max-width: 760px) {
  .admin-page .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .admin-page .stat-card { flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px; }
  .admin-page .stat-value { font-size: 1.35rem; }
  .inicio-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.7rem; }
}

.donut-wrap { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.admin-page .donut-chart { width: 150px; height: 150px; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.donut-center strong { font-size: 1.25rem; font-weight: 800; }
.donut-center span { font-size: .75rem; color: var(--text-dim); }
.admin-page .legend-label { text-transform: capitalize; }

.admin-page .breakdown-bar { background: var(--bg); border-color: var(--border-soft); height: 8px; }
.admin-page .breakdown-fill { background: linear-gradient(90deg, #be123c, var(--accent)); }

.quick-actions { display: flex; flex-direction: column; gap: 10px; }
.quick-actions h2 { margin-bottom: 6px; }
.qa {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  font-weight: 500; font-size: .92rem; font-family: inherit; cursor: pointer; text-align: left;
  transition: border-color .15s, transform .12s;
}
.qa svg { width: 19px; height: 19px; flex-shrink: 0; }
.qa:hover { border-color: var(--accent); transform: translateY(-1px); }
.qa-primary { background: linear-gradient(180deg, #ff3b62, var(--accent)); border-color: transparent; font-weight: 700; box-shadow: 0 8px 22px rgba(255,45,85,.3); }

/* ---------- Controles ---------- */
.admin-page input[type="text"], .admin-page input[type="number"], .admin-page input[type="url"],
.admin-page input[type="email"], .admin-page input[type="password"], .admin-page select {
  font-family: inherit; border-radius: 12px; background: var(--bg); transition: border-color .15s, box-shadow .15s;
}
.admin-page input:focus, .admin-page select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.admin-page .product-form { background: var(--bg); border-color: var(--border-soft); border-radius: 14px; }
.admin-page .sale-search-input, .admin-page .admin-search-box,
.admin-page .category-add-row input, .admin-page .admin-list-filters select { background: var(--bg); border-radius: 12px; }
.admin-page .admin-search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.admin-page .btn-primary {
  border-radius: 12px; padding: 12px 22px;
  background: linear-gradient(180deg, #ff3b62, var(--accent));
  box-shadow: 0 8px 20px rgba(255,45,85,.28); transition: transform .12s, box-shadow .15s;
}
.admin-page .btn-primary:hover { opacity: 1; transform: translateY(-1px); box-shadow: 0 12px 26px rgba(255,45,85,.4); }
.admin-page .btn-secondary { border-radius: 12px; padding: 11px 18px; font-weight: 600; background: var(--bg); }
.admin-page .btn-small { border-radius: 9px; padding: 8px 13px; font-weight: 600; background: var(--bg); }
.admin-page #toggleProductFormBtn, .admin-page #toggleSaleBtn {
  background: linear-gradient(180deg, #ff3b62, var(--accent)); border-color: transparent; color: #fff;
}

/* ---------- Productos ---------- */
.admin-page .admin-product-list { gap: 12px; }
.admin-page .admin-product-row {
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: 14px; padding: 12px 14px; gap: 16px;
}
.admin-page .admin-product-row:hover { border-color: var(--border); }
.admin-page .admin-product-thumb { width: 72px; height: 72px; border-radius: 12px; }
.admin-page .admin-product-info { gap: 6px; min-width: 0; }
.admin-page .admin-product-info strong { font-size: 1rem; font-weight: 700; }
.product-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.product-price { font-size: 1.05rem; font-weight: 800; }
.product-price small { font-size: .74rem; font-weight: 500; color: var(--text-dim); }
.admin-page .admin-product-info .product-sub { font-size: .76rem; color: var(--text-dim); }
.admin-page .admin-product-actions { flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; text-transform: capitalize; white-space: nowrap;
}
.admin-page .admin-product-info span.badge { color: inherit; font-size: .72rem; }
.badge-cat { background: rgba(255,45,85,.14); color: #ff6b87; border: 1px solid rgba(255,45,85,.25); }
.badge-on { background: rgba(34,197,94,.14); color: #4ade80; border: 1px solid rgba(34,197,94,.3); }
.badge-off { background: rgba(255,255,255,.07); color: var(--text-dim); border: 1px solid var(--border); }
.badge-pend { background: rgba(245,158,11,.14); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }

/* ---------- Pedidos ---------- */
.admin-page .admin-order-row {
  background: var(--bg); border: 1px solid var(--border-soft); border-left: 3px solid var(--border);
  border-radius: 14px; padding: 16px 18px;
}
.admin-page .admin-order-row.status-vendido { border-left-color: var(--ok); }
.admin-page .admin-order-row.status-pendiente { border-left-color: #f59e0b; }
.order-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-page .order-head .badge { color: inherit; }
.admin-page .order-head .badge-on { color: #4ade80; }
.admin-page .order-head .badge-pend { color: #fbbf24; }
.admin-page .order-head .badge-off { color: var(--text-dim); }
.admin-page .order-btn { border-radius: 10px; background: var(--bg-card); }
.admin-page .order-total { font-weight: 700; }

.admin-page .category-chip { background: var(--bg); border-color: var(--border); }
.admin-page .crop-modal { border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.admin-page .upload-box { border-radius: 14px; background: var(--bg); transition: border-color .15s, background .15s; }
.admin-page .upload-box:hover { background: var(--accent-soft); }

@media (max-width: 600px) {
  .app-content { padding: 16px 14px 110px; }
  .admin-page .admin-section { padding: 16px; border-radius: 14px; }
  .admin-page .admin-product-row { flex-wrap: wrap; }
  .admin-page .admin-product-info { flex: 1 1 calc(100% - 100px); }
  .admin-page .admin-product-row > .badge { order: 2; }
  .admin-page .admin-product-actions { width: 100%; justify-content: flex-start; }
  .view-title { font-size: 1.3rem; }
  .admin-page .admin-header { padding: 10px 14px; }
}

.admin-page .section-toggle-header { gap: 12px; flex-wrap: wrap; }
.admin-page .section-toggle-header .btn-secondary { white-space: nowrap; }

/* ---------- Botón de modo claro/oscuro ---------- */
.btn-theme {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-dim);
  transition: color .15s, border-color .15s;
}
.btn-theme:hover { color: var(--text); border-color: var(--accent); }
.btn-theme svg { width: 18px; height: 18px; }
.btn-theme .ico-sun { display: none; }
html[data-theme="light"] .btn-theme .ico-sun { display: inline-flex; }
html[data-theme="light"] .btn-theme .ico-moon { display: none; }
.admin-page .admin-header { gap: 10px; }
.admin-page .admin-header h1 { flex: 1; }

/* ---------- Selector Oscuro / Claro de la tienda ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-dim);
  font-weight: 600; font-size: .88rem; font-family: inherit;
}
.seg-btn svg { width: 18px; height: 18px; }
.seg-btn.active { color: #fff; border-color: transparent; background: linear-gradient(180deg, #ff3b62, var(--accent)); box-shadow: 0 8px 20px rgba(255,45,85,.28); }

/* ---------- Panel en modo claro ---------- */
html[data-theme="light"] body.admin-page {
  --bg: #f4f4f7;
  --bg-card: #ffffff;
  --bg-raised: #ffffff;
  --border: #e2e2e8;
  --border-soft: #ececf1;
  --text: #16161a;
  --text-dim: #6c6c78;
  --accent-soft: rgba(255, 45, 85, 0.10);
  --side-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.88);
  --bottom-bg: rgba(255, 255, 255, 0.94);
  --glow: rgba(255, 45, 85, 0.07);
  --soft: rgba(0,0,0,.045);
  --shadow: 0 8px 24px rgba(20,20,40,.06);
  color-scheme: light;
}
html[data-theme="light"] .admin-page .login-form { box-shadow: 0 20px 50px rgba(20,20,40,.12); }
html[data-theme="light"] .admin-page .crop-modal { background: #fff; }
html[data-theme="light"] .nav-item.active { color: var(--accent); }
html[data-theme="light"] .badge-cat { color: #e11d48; }
html[data-theme="light"] .badge-on { color: #15803d; }
html[data-theme="light"] .badge-pend { color: #b45309; }
html[data-theme="light"] .admin-page .order-head .badge-on { color: #15803d; }
html[data-theme="light"] .admin-page .order-head .badge-pend { color: #b45309; }

.theme-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .theme-row { grid-template-columns: 1fr; } }


/* Venta manual: foto redonda del producto */
.sale-thumb {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  border: 1px solid var(--border); display: inline-block;
}
.sale-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-page .sale-result-item { gap: 12px; padding: 8px 14px 8px 10px; }
.sale-result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sale-result-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sale-result-text small { color: var(--text-dim); font-size: 0.74rem; }
.admin-page .sale-selected-product { display: flex; align-items: center; gap: 12px; }
