/* ============================================================
   Panel administrativo MIL HOJAS - estilo POS cafetería
   ============================================================ */
:root {
  --crema: #f7efe3;
  --panel: #ffffff;
  --fondo: #f3ece2;
  --cafe: #6f4e37;
  --cafe-osc: #3f2d21;
  --dorado: #c9a227;
  --marron: #8d6e63;
  --texto: #3a2c22;
  --texto-suave: #7a6a5c;
  --borde: #e7ddd0;
  --ok: #2e7d4f;
  --ok-bg: #e6f4ec;
  --warn: #b9770e;
  --warn-bg: #fbf0db;
  --error: #c0392b;
  --error-bg: #fbeae8;
  --info-bg: #eaf2fb;
  --sombra: 0 6px 24px rgba(63, 45, 33, 0.1);
  --sombra-sm: 0 2px 8px rgba(63, 45, 33, 0.08);
  --radio: 14px;
  --sidebar: 248px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', system-ui, 'Segoe UI', sans-serif; background: var(--fondo); color: var(--texto); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.oculto { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--cafe), var(--cafe-osc)); }
.login-card { background: #fff; border-radius: 22px; box-shadow: var(--sombra); width: 100%; max-width: 410px; padding: 40px 34px; }
.login-card .logo { text-align: center; font-size: 3rem; margin-bottom: 8px; }
.login-card h1 { font-family: 'Playfair Display', serif; text-align: center; font-size: 1.5rem; color: var(--cafe-osc); margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--texto-suave); font-size: .9rem; margin-bottom: 28px; }
.login-card label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--cafe-osc); }
.login-card .campo { margin-bottom: 18px; }
.login-card input { width: 100%; padding: 13px 15px; border: 1.5px solid var(--borde); border-radius: 12px; font-size: 1rem; transition: border .2s; }
.login-card input:focus { outline: none; border-color: var(--cafe); }
.login-error { background: var(--error-bg); color: var(--error); padding: 10px 14px; border-radius: 10px; font-size: .88rem; margin-bottom: 16px; }
.login-hint { margin-top: 20px; font-size: .78rem; color: var(--texto-suave); text-align: center; line-height: 1.5; }
.login-volver { display:block; text-align:center; margin-top:18px; color:var(--texto-suave); font-size:.85rem; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--cafe-osc); color: #efe5d8; display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transition: transform .25s ease; }
.sidebar .brand { padding: 22px 22px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .ico { font-size: 1.8rem; }
.sidebar .brand .txt { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.sidebar nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 11px; color: #d8c8b8;
  font-weight: 500; font-size: .94rem; margin-bottom: 3px; transition: all .15s; }
.sidebar nav a .ico { font-size: 1.25rem; width: 24px; text-align: center; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.activo { background: var(--cafe); color: #fff; box-shadow: var(--sombra-sm); }
.sidebar .user-box { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .user-box .nom { font-weight: 600; font-size: .92rem; }
.sidebar .user-box .rol { font-size: .76rem; color: #b6a695; text-transform: capitalize; }
.sidebar .user-box .salir { margin-top: 10px; display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; color: #e7b9b2; }
.sidebar .user-box .salir:hover { color: #fff; }

.main { flex: 1; margin-left: var(--sidebar); display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; border-bottom: 1px solid var(--borde); padding: 14px 26px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; background: none; border: none; font-size: 1.5rem; color: var(--cafe-osc); }
.topbar h1 { font-family: 'Playfair Display', serif; font-size: 1.35rem; color: var(--cafe-osc); }
.topbar .topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .85rem; color: var(--texto-suave); }
.topbar .caja-pill { padding: 6px 14px; border-radius: 50px; font-weight: 600; font-size: .8rem; }
.caja-pill.abierta { background: var(--ok-bg); color: var(--ok); }
.caja-pill.cerrada { background: var(--warn-bg); color: var(--warn); }
.vista { padding: 26px; flex: 1; }

/* ---------- Cards / KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 26px; }
.kpi { background: #fff; border-radius: var(--radio); padding: 20px 22px; box-shadow: var(--sombra-sm); display: flex; align-items: center; gap: 16px; border: 1px solid var(--borde); }
.kpi .ico { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0; }
.kpi .ico.cafe { background: #f0e6da; } .kpi .ico.oro { background: #f8eecb; } .kpi .ico.verde { background: var(--ok-bg); } .kpi .ico.rojo { background: var(--error-bg); }
.kpi .val { font-size: 1.5rem; font-weight: 700; color: var(--cafe-osc); font-family: 'Playfair Display', serif; line-height: 1.1; }
.kpi .lbl { font-size: .82rem; color: var(--texto-suave); }

.panel { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra-sm); border: 1px solid var(--borde); margin-bottom: 22px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--borde); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; color: var(--cafe-osc); font-family: 'Playfair Display', serif; }
.panel-head .acciones { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.panel-body { padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: 11px 14px; color: var(--texto-suave); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--borde); }
td { padding: 12px 14px; border-bottom: 1px solid var(--borde); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf6f0; }
.tabla-scroll { overflow-x: auto; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--texto-suave); }
.vacio { text-align: center; padding: 40px 20px; color: var(--texto-suave); }
.vacio .em { font-size: 2.6rem; display: block; margin-bottom: 8px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: .9rem; border: 1.5px solid transparent; transition: all .15s; background: #eee; color: var(--texto); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primario { background: var(--cafe); color: #fff; }
.btn-primario:hover { background: var(--cafe-osc); }
.btn-oro { background: var(--dorado); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }
.btn-ghost { background: #fff; border-color: var(--borde); color: var(--cafe-osc); }
.btn-ghost:hover { border-color: var(--cafe); }
.btn-sm { padding: 7px 12px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Formularios ---------- */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label.lbl { display: block; font-weight: 600; font-size: .82rem; margin-bottom: 6px; color: var(--cafe-osc); }
.inp, select.inp, textarea.inp { width: 100%; padding: 11px 13px; border: 1.5px solid var(--borde); border-radius: 10px; font-size: .95rem; background: #fff; transition: border .15s; }
.inp:focus { outline: none; border-color: var(--cafe); }
textarea.inp { resize: vertical; min-height: 70px; }
.input-busca { position: relative; }
.input-busca input { padding-left: 38px; }
.input-busca::before { content: '🔍'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .5; }

/* ---------- Badges / chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 50px; font-size: .76rem; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.error { background: var(--error-bg); color: var(--error); }
.chip.info { background: var(--info-bg); color: #2c6fb5; }
.chip.gris { background: #ece5db; color: var(--texto-suave); }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.pos-prods { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra-sm); border: 1px solid var(--borde); padding: 18px; }
.pos-cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pos-cat { padding: 7px 14px; border-radius: 50px; border: 1.5px solid var(--borde); background: #fff; font-size: .82rem; font-weight: 600; color: var(--cafe); }
.pos-cat.activo { background: var(--cafe); color: #fff; border-color: var(--cafe); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto; }
.pos-prod { background: var(--crema); border: 1.5px solid var(--borde); border-radius: 13px; padding: 14px 12px; text-align: center; transition: all .12s; cursor: pointer; }
.pos-prod:hover { border-color: var(--cafe); transform: translateY(-2px); box-shadow: var(--sombra-sm); }
.pos-prod:active { transform: scale(.97); }
.pos-prod .em { font-size: 1.9rem; }
.pos-prod .nom { font-weight: 600; font-size: .85rem; margin: 6px 0 2px; color: var(--cafe-osc); line-height: 1.2; }
.pos-prod .pre { font-weight: 700; color: var(--cafe); font-size: .9rem; }
.pos-prod.sin-stock { opacity: .55; }

.pos-cart { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra-sm); border: 1px solid var(--borde); position: sticky; top: 90px; display: flex; flex-direction: column; max-height: calc(100vh - 110px); }
.pos-cart .cart-head { padding: 16px 18px; border-bottom: 1px solid var(--borde); font-weight: 700; color: var(--cafe-osc); font-family: 'Playfair Display', serif; }
.pos-cart .cart-items { flex: 1; overflow-y: auto; padding: 8px 14px; min-height: 120px; }
.cart-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--borde); }
.cart-item .ci-nom { flex: 1; font-size: .86rem; font-weight: 500; }
.cart-item .ci-pre { font-size: .76rem; color: var(--texto-suave); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--borde); background: #fff; font-weight: 700; color: var(--cafe); font-size: 1rem; line-height: 1; }
.qty .n { min-width: 22px; text-align: center; font-weight: 600; }
.ci-sub { font-weight: 700; color: var(--cafe-osc); min-width: 62px; text-align: right; font-size: .86rem; }
.ci-del { background: none; border: none; color: var(--error); font-size: 1.1rem; }
.cart-foot { padding: 16px 18px; border-top: 2px solid var(--borde); }
.cart-line { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: .9rem; }
.cart-line.total { font-size: 1.3rem; font-weight: 700; color: var(--cafe-osc); font-family: 'Playfair Display', serif; }
.metodos { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin: 12px 0; }
.metodo-btn { padding: 10px; border-radius: 10px; border: 1.5px solid var(--borde); background: #fff; font-weight: 600; font-size: .84rem; color: var(--cafe); }
.metodo-btn.activo { background: var(--cafe); color: #fff; border-color: var(--cafe); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(63,45,33,.55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-back.abierto { opacity: 1; pointer-events: auto; }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--sombra); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; transform: scale(.96); transition: transform .2s; }
.modal-back.abierto .modal { transform: scale(1); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--borde); display: flex; align-items: center; }
.modal-head h3 { font-family: 'Playfair Display', serif; color: var(--cafe-osc); font-size: 1.2rem; }
.modal-head .x { margin-left: auto; background: none; border: none; font-size: 1.5rem; color: var(--texto-suave); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--borde); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; border-left: 4px solid var(--cafe); padding: 13px 18px; border-radius: 10px; box-shadow: var(--sombra); font-size: .9rem; min-width: 240px; max-width: 360px; animation: slideIn .25s ease; }
.toast.ok { border-color: var(--ok); } .toast.error { border-color: var(--error); } .toast.warn { border-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Asistente IA (dashboard) ---------- */
.ia-card { background: linear-gradient(135deg, #fff 60%, #faf4ea); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra-sm); overflow: hidden; margin-bottom: 22px; }
.ia-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--borde); background: linear-gradient(135deg, var(--cafe), var(--cafe-osc)); color: #fff; }
.ia-head .av { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.ia-head .tit { font-family: 'Playfair Display', serif; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.ia-head .sub { font-size: .8rem; opacity: .85; }
.ia-head .est { margin-left: auto; font-size: .72rem; background: rgba(255,255,255,.18); padding: 4px 12px; border-radius: 50px; }
.ia-body { padding: 18px 22px; max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: #fffdfa; }
.ia-msg { max-width: 82%; padding: 12px 16px; border-radius: 16px; font-size: .94rem; line-height: 1.55; white-space: pre-wrap; }
.ia-msg.bot { background: var(--crema); color: var(--texto); align-self: flex-start; border-bottom-left-radius: 5px; box-shadow: var(--sombra-sm); }
.ia-msg.user { background: var(--cafe); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.ia-msg.bot strong { color: var(--cafe-osc); }
.ia-typing { align-self: flex-start; color: var(--texto-suave); font-size: .9rem; font-style: italic; padding: 6px 4px; }
.ia-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 14px; }
.ia-quick button { font-size: .82rem; padding: 7px 14px; border-radius: 50px; border: 1.5px solid var(--borde); background: #fff; color: var(--cafe); cursor: pointer; transition: all .15s; }
.ia-quick button:hover { background: var(--cafe); color: #fff; border-color: var(--cafe); }
.ia-input { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--borde); background: #fff; }
.ia-input input { flex: 1; padding: 12px 16px; border: 1.5px solid var(--borde); border-radius: 50px; font-size: .95rem; }
.ia-input input:focus { outline: none; border-color: var(--cafe); }
.ia-input button { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--cafe); color: #fff; font-size: 1.2rem; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.ia-input button:hover { background: var(--cafe-osc); }
.ia-input button:disabled { opacity: .5; cursor: not-allowed; }
.ia-off { padding: 18px 22px; color: var(--texto-suave); font-size: .9rem; }

/* ---------- Loader ---------- */
.loader { text-align: center; padding: 50px; color: var(--texto-suave); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--borde); border-top-color: var(--cafe); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) { .pos { grid-template-columns: 1fr; } .pos-cart { position: static; max-height: none; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sombra); }
  .sidebar.abierto { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: block; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
}
