/* =========================================================
   Proshop - estilos del panel de administracion
   Reutiliza variables y tema definidos en styles.css
   ========================================================= */

/* ---------- Tema oscuro/apagado SOLO para los paneles ----------
   La web publica mantiene su morado vibrante; aqui lo hacemos mas
   oscuro y opaco para un look de "consola de trabajo". */
body.admin, body.admin-login {
  background: linear-gradient(160deg, #241634 0%, #190f28 55%, #110a1d 100%) fixed;
  background-color: #150d22;
}

/* ---------- Login ---------- */
.admin-login { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; display: grid; place-items: center; padding: 2rem 1.25rem; }
.login-card {
  width: min(100%, 400px);
  background: var(--surface); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem; box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.5rem; }
.brand-mark-icon { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.login-brand strong { display: block; font-family: var(--display); font-size: 1.25rem; }
.login-brand span { color: var(--muted); font-size: .85rem; }
.login-error {
  background: rgba(251, 113, 133, .12); border: 1px solid rgba(251, 113, 133, .4);
  color: #fecdd3; padding: .6rem .8rem; border-radius: 10px; font-size: .9rem; margin: 0 0 1rem;
}
.login-back { display: block; text-align: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.login-back:hover { color: var(--text); }
.login-remember { display: flex; align-items: center; gap: .5rem; font-size: .88rem; color: var(--muted); margin: .2rem 0 1.1rem; cursor: pointer; }
.login-remember input { width: auto; margin: 0; }

/* ================== LAYOUT CON MENU LATERAL ================== */
.admin { min-height: 100vh; }
.admin-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: rgba(0, 0, 0, .22);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.2rem; border-bottom: 1px solid var(--border);
}
.sidebar-brand-text { font-family: var(--display); font-weight: 800; font-size: 1.1rem; }
.admin-tag {
  font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  background: var(--primary-2); color: #06231a; padding: .12rem .4rem; border-radius: 6px; vertical-align: middle;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: .9rem .7rem; overflow-y: auto; flex: 1; }
.sidebar-section {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); opacity: .8; padding: .9rem .6rem .35rem;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .7rem; border-radius: 10px;
  color: var(--muted); font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.sidebar-nav a.is-active {
  background: rgba(47, 227, 166, .14);
  color: var(--primary-2);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary-2);
}
.si { width: 1.2em; display: inline-flex; align-items: center; justify-content: center; opacity: .85; }
.si svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav a.is-active .si { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--primary-2); color: #06231a;
  font-size: .7rem; font-weight: 800; padding: .1rem .45rem; border-radius: 999px;
}

.sidebar-foot { padding: .9rem 1rem; border-top: 1px solid var(--border); display: grid; gap: .5rem; }
.sidebar-foot a, .sidebar-foot button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; font: inherit; cursor: pointer;
  color: var(--muted); font-size: .88rem; padding: .35rem 0;
}
.sidebar-foot a:hover, .sidebar-foot button:hover { color: var(--text); }
.sidebar-foot form { margin: 0; }

.sidebar-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 39; }

/* ---------- Cuerpo ---------- */
.admin-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.6rem;
  background: rgba(30, 20, 45, .72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.15rem; font-family: var(--display); }
.topbar-user { margin-left: auto; color: var(--muted); font-size: .9rem; }
.sidebar-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: 0; cursor: pointer; padding: 4px; }
.sidebar-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

.admin-main { padding: 1.8rem 1.6rem 4rem; flex: 1; }

/* ---------- Encabezado de pagina ---------- */
.page-head { margin-bottom: 1.6rem; }
.page-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .25rem; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- Stats ---------- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.15rem 1.3rem;
}
.stat-num { display: block; font-family: var(--display); font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); font-size: .82rem; }
.stat-new .stat-num { color: var(--primary-2); }
.stat-done .stat-num { color: var(--accent); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center; padding: 3.5rem 1rem;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-icon { font-size: 2.4rem; }
.empty-state h3 { margin: .6rem 0 .3rem; }
.empty-state p { color: var(--muted); margin: 0; }

/* ---------- Tablas ---------- */
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); backdrop-filter: blur(8px);
}
.leads-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 720px; }
.leads-table th, .leads-table td { padding: .8rem 1rem; text-align: left; vertical-align: top; }
.leads-table thead th {
  font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, .14); position: sticky; top: 0;
}
.leads-table tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
.leads-table tbody tr:last-child { border-bottom: 0; }
.leads-table tbody tr:hover { background: rgba(255, 255, 255, .04); }
.leads-table tr.is-done { opacity: .62; }
.leads-table a { color: var(--primary-2); }
.leads-table a:hover { text-decoration: underline; }
.prod-thumb {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
}
.prod-thumb-vacio {
  display: flex; align-items: center; justify-content: center;
  font-size: .6rem; color: var(--muted); text-align: center; line-height: 1.2; padding: 2px;
}
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.msg-cell { max-width: 320px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.badge-new { background: rgba(47, 227, 166, .16); color: var(--primary-2); border: 1px solid rgba(47, 227, 166, .4); }
.badge-done { background: rgba(192, 132, 252, .16); color: #e9d5ff; border: 1px solid rgba(192, 132, 252, .4); }
.badge-off { background: rgba(255, 255, 255, .07); color: var(--muted); border: 1px solid var(--border); }
.badge-star { background: rgba(250, 204, 21, .16); color: #fde68a; border: 1px solid rgba(250, 204, 21, .4); }

/* ---------- Botones de accion ---------- */
.actions-cell { white-space: nowrap; }
.inline-form { display: inline; margin: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; margin: 0 1px;
  border-radius: 8px; border: 1px solid var(--border); background: rgba(255, 255, 255, .05);
  color: var(--text); font-size: .8rem; font-weight: 700; cursor: pointer; transition: all .15s; text-decoration: none;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn.wa:hover { background: #25d366; border-color: #25d366; color: #fff; }
.icon-btn.mail:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.icon-btn.check:hover { background: var(--primary-2); border-color: var(--primary-2); color: #06231a; }
.icon-btn.del:hover { background: #fb7185; border-color: #fb7185; }

/* ---------- Tarjetas de plan ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.1rem; }
.plan-card {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; position: relative;
}
.plan-card.is-reco { border-color: rgba(47, 227, 166, .5); box-shadow: 0 0 0 1px rgba(47, 227, 166, .25); }
.plan-card h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.plan-price { font-family: var(--display); font-size: 1.7rem; font-weight: 800; }
.plan-price small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.plan-meta { list-style: none; padding: 0; margin: .9rem 0 0; display: grid; gap: .35rem; font-size: .87rem; color: var(--muted); }
.plan-meta b { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 40;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .admin-main { padding: 1.4rem 1.1rem 3rem; }
  .admin-topbar { padding: .8rem 1.1rem; }
  .topbar-user { display: none; }
}

/* ---------- Encabezado con boton ---------- */
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Alertas ---------- */
.alert-ok, .alert-err {
  padding: .7rem 1rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1.2rem;
}
.alert-ok { background: rgba(47,227,166,.14); border: 1px solid rgba(47,227,166,.4); color: #a7f3d0; }
.alert-err { background: rgba(251,113,133,.12); border: 1px solid rgba(251,113,133,.4); color: #fecdd3; }

/* ---------- Formularios ---------- */
.form-card {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.8rem; max-width: 720px; box-shadow: var(--shadow);
}
.form-actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }

/* ---------- Barra de progreso ---------- */
.bar { height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin-bottom: .3rem; }
.bar span { display: block; height: 100%; background: var(--primary-2); border-radius: 4px; transition: width .3s; }
.bar span.bar-alert { background: #ffb020; }
.saldo-ok { color: var(--primary-2); }

/* ---------- Registro (formulario ancho) ---------- */
.login-card-wide { width: min(100%, 480px); }

/* ---------- Medidor de saldo del cliente ---------- */
.gauge {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.6rem; margin-bottom: 1.4rem;
}
.gauge-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem; }
.gauge-num { font-family: var(--display); font-size: 2.6rem; font-weight: 800; line-height: 1; color: var(--primary-2); }
.gauge-sub { color: var(--muted); font-size: .9rem; }
.bar-lg { height: 12px; border-radius: 6px; background: rgba(255,255,255,.12); overflow: hidden; }
.bar-lg span { display: block; height: 100%; background: var(--primary-2); transition: width .4s; }
.bar-lg span.bar-alert { background: #ffb020; }
.bar-lg span.bar-full { background: #fb7185; }

/* ---------- Tarjetas de paquete para comprar ---------- */
.buy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.buy-card {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; text-align: center; transition: transform .2s, border-color .2s;
}
.buy-card:hover { transform: translateY(-4px); border-color: rgba(47,227,166,.45); }
.buy-qty { font-family: var(--display); font-size: 1.8rem; font-weight: 800; }
.buy-lbl { display: block; color: var(--muted); font-size: .8rem; margin-bottom: .7rem; }
.buy-price { font-size: 1.2rem; font-weight: 700; color: var(--primary-2); margin-bottom: .3rem; }
.buy-unit { display: block; color: var(--muted); font-size: .74rem; margin-bottom: 1rem; }
.buy-card form { margin: 0; }

/* ---------- Nombre de la empresa bajo la marca (panel cliente) ---------- */
.sidebar-brand-stack { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-empresa {
  color: #fff; font-weight: 700; font-size: .82rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 175px;
}

/* ---------- Simulador de consumo (panel admin) ---------- */
.sim-form { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; }
.sim-input {
  width: 48px; padding: .3rem .35rem; text-align: center;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font: inherit; font-size: .8rem;
}
.icon-btn.sim:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Campanita de notificaciones (panel cliente) ---------- */
.notif { position: relative; margin-left: auto; }
.notif-bell {
  position: relative; background: none; border: 0; cursor: pointer;
  font-size: 1.3rem; padding: .3rem; line-height: 1;
}
.notif-dot {
  position: absolute; top: -2px; right: -4px;
  background: #fb7185; color: #fff; font-size: .62rem; font-weight: 800;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  display: grid; place-items: center;
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 50;
  width: min(360px, 90vw);
  background: var(--surface-2); backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.notif-leer { background: none; border: 0; color: var(--primary-2); font: inherit; font-size: .78rem; cursor: pointer; }
.notif-list { max-height: 60vh; overflow-y: auto; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; }
.notif-item { padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.is-unread { background: rgba(47, 227, 166, .07); border-left: 3px solid var(--primary-2); }
.notif-item-top { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.notif-item-top strong { font-size: .92rem; }
.notif-time { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.notif-item p { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }
.notif-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.notif-actions .btn { padding: .4rem .8rem; font-size: .82rem; }
.notif-marcar { margin-top: .6rem; background: none; border: 0; color: var(--muted); font: inherit; font-size: .76rem; cursor: pointer; padding: 0; }
.notif-marcar:hover { color: var(--text); }

/* ---------- Caja "Enviar aviso" (admin) ---------- */
.aviso-box {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .4rem 1.2rem; margin-bottom: 1.6rem;
}
.aviso-box summary { cursor: pointer; font-weight: 600; padding: .7rem 0; list-style: none; }
.aviso-box summary::-webkit-details-marker { display: none; }
.aviso-box[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.aviso-form { padding-bottom: 1rem; }
.aviso-form .form-actions { justify-content: flex-start; border-top: 0; padding-top: .5rem; margin-top: .5rem; }
.aviso-form textarea, .aviso-form input, .aviso-form select {
  width: 100%; padding: .6rem .8rem; border-radius: 10px; font: inherit;
  color: var(--text); background: var(--bg-2); border: 1px solid var(--border);
}

/* ---------- Dashboard de Inicio (panel cliente) ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.1rem; }
.dash-card {
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.3rem;
}
.dash-card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.dash-card-head h3 { font-size: 1rem; margin: 0; }
.dash-card-head a { color: var(--primary-2); font-size: .82rem; }
.dash-empty { color: var(--muted); font-size: .9rem; margin: .3rem 0 0; }
.dash-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.dash-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .9rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.dash-list li:last-child { border-bottom: 0; }

/* Mini gráfico de barras (reportes) */
.mini-chart { display: flex; align-items: flex-end; gap: .5rem; height: 140px; padding-top: .5rem; }
.mini-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; height: 100%; justify-content: flex-end; }
.mini-bar { width: 70%; min-height: 3px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, var(--primary-2), var(--primary)); transition: height .3s; }
.mini-lbl { font-size: .7rem; color: var(--muted); }

/* ---------- Banner de estado de WhatsApp ---------- */
.wa-status {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.2rem 1.4rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(8px);
}
.wa-status p { margin: .15rem 0 0; font-size: .9rem; }
.wa-status strong { font-size: 1.05rem; }
.wa-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.wa-on { border-color: rgba(47,227,166,.4); }
.wa-on .wa-dot { background: #2fe3a6; box-shadow: 0 0 0 4px rgba(47,227,166,.2); }
.wa-off .wa-dot, .wa-proc .wa-dot { background: #fb7185; box-shadow: 0 0 0 4px rgba(251,113,133,.18); }
.wa-proc .wa-dot { animation: wapulse 1.4s ease-in-out infinite; }
@keyframes wapulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.wa-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
.wa-actions form { margin: 0; }
