/* =========================================================
   CACHIVACHES CHATITA — Sistema de diseño
   Paleta: tinta índigo + verde bosque (marca), papel cálido de fondo
   Tipografía: Poppins (display) / Inter (cuerpo) / JetBrains Mono (datos)
   Firma visual: tarjetas de producto estilo "plancha de stickers"
   con borde troquelado (dashed) y esquinas redondeadas.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap');

:root{
  --ink:        #232946;
  --ink-soft:   #2E3768;
  --paper:      #F7F6FB;
  --paper-card: #FFFFFF;
  --coral:      #00520C;
  --coral-dark: #003D09;
  --teal:       #2CB1BC;
  --amber:      #F4A73C;
  --green:      #2FB380;
  --red:        #E5484D;
  --line:       #E7E5F1;
  --text:       #232946;
  --text-muted: #6B7094;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(35,41,70,.06), 0 1px 1px rgba(35,41,70,.04);
  --shadow-md: 0 8px 24px rgba(35,41,70,.10);
  --shadow-lg: 0 16px 40px rgba(35,41,70,.16);

  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,.font-display{ font-family: var(--font-display); letter-spacing:-.01em; }
.font-mono{ font-family: var(--font-mono); }

a{ color: var(--coral); text-decoration:none; }
a:hover{ color: var(--coral-dark); }

::selection{ background: var(--coral); color:#fff; }

/* focus visible accesible */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible{
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------
   LAYOUT APP (sidebar + contenido)
--------------------------------------------------------- */
.app-shell{
  display:flex;
  min-height:100vh;
}

.sidebar{
  width:250px;
  flex-shrink:0;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-soft) 100%);
  color:#fff;
  display:flex;
  flex-direction:column;
  position:fixed;
  top:0; bottom:0; left:0;
  z-index:1000;
  transition: transform .25s ease;
}
.sidebar-brand{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  padding:1.4rem 1.3rem 1rem;
}
.sidebar-logo{
  height:44px;
  width:auto;
  max-width:100%;
  object-fit:contain;
  display:block;
}
.sidebar-brand .mark{
  width:38px;height:38px;border-radius:12px;
  background: var(--coral);
  display:flex;align-items:center;justify-content:center;
  font-family:var(--font-display); font-weight:800; color:#fff; font-size:1.05rem;
  box-shadow: 0 4px 10px rgba(0,82,12,.45);
  transform: rotate(-6deg);
}
.sidebar-brand .name{ font-family:var(--font-display); font-weight:700; font-size:1.05rem; line-height:1.1;}
.sidebar-brand .sub{ font-size:.7rem; color:#B7BCE0; letter-spacing:.06em; text-transform:uppercase;}

.nav-section-label{
  font-size:.68rem; text-transform:uppercase; letter-spacing:.09em;
  color:#8388B8; padding: 1rem 1.3rem .35rem;
}
.sidebar-nav{ flex:1; overflow-y:auto; padding-bottom:1rem;}
.sidebar-nav .nav-link{
  display:flex; align-items:center; gap:.8rem;
  padding:.62rem 1.3rem;
  color:#D2D4EE;
  font-weight:500; font-size:.92rem;
  border-left:3px solid transparent;
  position:relative;
}
.sidebar-nav .nav-link svg{ width:18px;height:18px; flex-shrink:0; opacity:.9;}
.sidebar-nav .nav-link:hover{ background: rgba(255,255,255,.06); color:#fff; }
.sidebar-nav .nav-link.active{
  background: rgba(0,82,12,.16);
  color:#fff;
  border-left-color: var(--coral);
}
.sidebar-foot{
  padding:1rem 1.3rem 1.3rem;
  border-top:1px solid rgba(255,255,255,.08);
}
.user-chip{ display:flex; align-items:center; gap:.6rem; }
.user-chip .avatar{
  width:34px;height:34px;border-radius:50%;
  background: var(--teal); color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-weight:700; font-size:.85rem; font-family:var(--font-display);
}
.user-chip .info .uname{ font-size:.85rem; font-weight:600; color:#fff; line-height:1.1;}
.user-chip .info .urole{ font-size:.72rem; color:#9297C4; text-transform:capitalize;}

.main{
  margin-left:250px;
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.topbar{
  position:sticky; top:0; z-index:900;
  background: rgba(247,246,251,.85);
  backdrop-filter: blur(8px);
  border-bottom:1px solid var(--line);
  padding:.85rem 1.5rem;
  display:flex; align-items:center; gap:1rem;
}
.topbar .page-title{ font-family:var(--font-display); font-weight:700; font-size:1.15rem; margin:0;}
.burger{
  display:none;
  width:38px;height:38px;border-radius:10px;
  border:1px solid var(--line); background:#fff;
  align-items:center;justify-content:center;
  cursor:pointer;
}

.content{ padding:1.5rem; flex:1; }

.sidebar-backdrop{
  display:none;
  position:fixed; inset:0; background:rgba(20,22,40,.45); z-index:999;
}

/* ---------------------------------------------------------
   COMPONENTES
--------------------------------------------------------- */
.card-x{
  background: var(--paper-card);
  border:1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-x .card-x-head{
  padding:1.1rem 1.3rem;
  border-bottom:1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between; gap:.75rem; flex-wrap:wrap;
}
.card-x .card-x-body{ padding:1.3rem; }
.card-x .card-x-title{ font-family:var(--font-display); font-weight:700; font-size:1rem; margin:0; }

/* KPI stat cards */
.stat-card{
  background: var(--paper-card);
  border:1px solid var(--line);
  border-radius: var(--radius-md);
  padding:1.2rem 1.3rem;
  box-shadow: var(--shadow-sm);
  position:relative;
  overflow:hidden;
}
.stat-card::after{
  content:"";
  position:absolute; right:-30px; top:-30px;
  width:100px;height:100px;border-radius:50%;
  background: var(--accent, var(--coral));
  opacity:.08;
}
.stat-card .stat-label{ font-size:.78rem; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; font-weight:600;}
.stat-card .stat-value{ font-family:var(--font-display); font-size:1.65rem; font-weight:800; margin:.15rem 0;}
.stat-card .stat-icon{
  width:42px;height:42px;border-radius:12px;
  background: var(--accent, var(--coral)); color:#fff;
  display:flex;align-items:center;justify-content:center;
  margin-bottom:.6rem;
}
.stat-card .stat-icon svg{ width:22px;height:22px;}
.stat-card .stat-delta{ font-size:.78rem; font-weight:600; }
.stat-card .stat-delta.up{ color: var(--green); }
.stat-card .stat-delta.down{ color: var(--red); }

/* Botones */
.btn-x{
  display:inline-flex; align-items:center; justify-content:center; gap:.45rem;
  font-family: var(--font-body); font-weight:600; font-size:.88rem;
  padding:.55rem 1.05rem; border-radius: var(--radius-sm);
  border:1px solid transparent; cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  line-height:1.2;
}
.btn-x:active{ transform: translateY(1px); }
.btn-x svg{ width:16px;height:16px; }
.btn-primary{ background: var(--coral); color:#fff; box-shadow: 0 4px 12px rgba(0,82,12,.28);}
.btn-primary:hover{ background: var(--coral-dark); color:#fff; }
.btn-outline{ background:#fff; border-color: var(--line); color: var(--text);}
.btn-outline:hover{ border-color: var(--ink); color:var(--ink);}
.btn-teal{ background: var(--teal); color:#fff; }
.btn-teal:hover{ background:#238e97; color:#fff; }
.btn-ghost{ background:transparent; color:var(--text-muted); border-color:transparent; }
.btn-ghost:hover{ background: var(--paper); color:var(--text);}
.btn-danger{ background:#fff; color:var(--red); border-color: #F6C6C8;}
.btn-danger:hover{ background:var(--red); color:#fff; border-color:var(--red);}
.btn-sm{ padding:.35rem .7rem; font-size:.8rem;}
.btn-block{ width:100%; }
.btn-icon{ width:36px; height:36px; padding:0; border-radius:10px; }

/* Formularios */
.form-label-x{ font-size:.82rem; font-weight:600; color:var(--text); margin-bottom:.35rem; display:block;}
.form-control-x, select.form-control-x, textarea.form-control-x{
  width:100%;
  padding:.58rem .8rem;
  border:1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size:.9rem;
  background:#fff;
  color:var(--text);
}
.form-control-x:focus{ outline:none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(44,177,188,.15); }
.input-group-x{ position:relative; }
.input-group-x .prefix{ position:absolute; left:.75rem; top:50%; transform:translateY(-50%); color:var(--text-muted); font-size:.85rem;}
.input-group-x .form-control-x.has-prefix{ padding-left:1.7rem; }

/* Tablas */
.table-x{ width:100%; border-collapse:separate; border-spacing:0; font-size:.88rem; }
.table-x thead th{
  text-align:left; font-size:.72rem; text-transform:uppercase; letter-spacing:.05em;
  color: var(--text-muted); font-weight:700;
  padding:.7rem .9rem; border-bottom:1px solid var(--line);
  white-space:nowrap;
}
.table-x tbody td{ padding:.75rem .9rem; border-bottom:1px solid var(--line); vertical-align:middle;}
.table-x tbody tr:last-child td{ border-bottom:none; }
.table-x tbody tr:hover{ background: #FBFAFE; }
.table-responsive-x{ overflow-x:auto; border-radius: var(--radius-md); }

/* Badges */
.badge-x{
  display:inline-flex; align-items:center; gap:.3rem;
  padding:.22rem .6rem; border-radius:999px;
  font-size:.72rem; font-weight:700;
}
.badge-green{ background:#E4F7EF; color:#1F8F63;}
.badge-red{ background:#FCE9EA; color:#C23237;}
.badge-amber{ background:#FDF1DD; color:#B4750E;}
.badge-gray{ background:#EEEDF5; color:#6B7094;}
.badge-teal{ background:#E1F5F6; color:#1D8891;}

/* --- Tarjeta de producto "plancha de sticker" (firma visual) --- */
.sticker-card{
  background:#fff;
  border-radius: var(--radius-lg);
  border: 2px dashed #D9D5EC;
  padding: .9rem;
  position:relative;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.sticker-card:hover{
  transform: translateY(-3px) rotate(-.4deg);
  box-shadow: var(--shadow-md);
  border-color: var(--coral);
}
.sticker-card .thumb{
  width:100%; aspect-ratio:1/1; border-radius: 14px;
  background: var(--paper); overflow:hidden;
  display:flex; align-items:center; justify-content:center;
  margin-bottom:.7rem;
}
.sticker-card .thumb img{ width:100%; height:100%; object-fit:cover; }
.sticker-card .name{ font-weight:700; font-size:.88rem; line-height:1.25; margin:0 0 .2rem; }
.sticker-card .price{ font-family:var(--font-mono); font-weight:600; color:var(--coral-dark); font-size:1rem;}
.sticker-card .stock-pill{
  position:absolute; top:.7rem; right:.7rem;
  background: var(--ink); color:#fff; font-family:var(--font-mono);
  font-size:.68rem; font-weight:600; padding:.15rem .5rem; border-radius:999px;
}
.sticker-card .stock-pill.low{ background: var(--red); }

/* Carrito POS */
.pos-cart{
  display:flex; flex-direction:column; height:100%;
}
.pos-cart-items{ flex:1; overflow-y:auto; }
.cart-line{
  display:flex; align-items:center; gap:.6rem;
  padding:.6rem 0; border-bottom:1px dashed var(--line);
}
.cart-line .qty-ctrl{ display:flex; align-items:center; gap:.3rem; }
.cart-line .qty-ctrl button{
  width:24px;height:24px;border-radius:7px; border:1px solid var(--line); background:#fff; cursor:pointer;
  display:flex;align-items:center;justify-content:center;
}
.cart-total-row{ display:flex; justify-content:space-between; font-family:var(--font-mono); font-size:.9rem; padding:.25rem 0;}
.cart-total-row.grand{ font-size:1.2rem; font-weight:700; font-family:var(--font-display); color:var(--ink);}

/* Modal simple */
.modal-x-backdrop{
  position:fixed; inset:0; background:rgba(20,22,40,.5); z-index:1400;
  display:none; align-items:center; justify-content:center; padding:1rem;
}
.modal-x-backdrop.show{ display:flex; }
.modal-x{
  background:#fff; border-radius: var(--radius-md); width:100%; max-width:560px;
  max-height:90vh; overflow-y:auto; box-shadow: var(--shadow-lg);
}
.modal-x-head{ padding:1.1rem 1.3rem; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between;}
.modal-x-body{ padding:1.3rem; }
.modal-x-foot{ padding:1rem 1.3rem; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:.6rem;}

/* Toast */
#toast-x{
  position:fixed; bottom:1.2rem; right:1.2rem; z-index:2000;
  display:flex; flex-direction:column; gap:.6rem;
}
.toast-item{
  background: var(--ink); color:#fff; padding:.7rem 1rem; border-radius: var(--radius-sm);
  font-size:.85rem; box-shadow: var(--shadow-md); display:flex; align-items:center; gap:.5rem;
  animation: toast-in .18s ease;
}
.toast-item.err{ background: var(--red); }
.toast-item.ok{ background: var(--green); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(8px);} to{opacity:1; transform:translateY(0);} }

.empty-state{
  text-align:center; padding:3rem 1rem; color: var(--text-muted);
}
.empty-state svg{ width:52px; height:52px; opacity:.35; margin-bottom:.8rem; }

/* Login page */
.login-shell{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 15% 20%, rgba(0,82,12,.13), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(44,177,188,.13), transparent 40%),
    var(--ink);
  padding:1.5rem;
}
.login-card{
  width:100%; max-width:400px; background:#fff; border-radius: var(--radius-lg);
  padding:2.2rem 2rem; box-shadow: var(--shadow-lg);
}
.login-card .mark{
  width:52px;height:52px;border-radius:16px; background:var(--coral);
  display:flex;align-items:center;justify-content:center; color:#fff;
  font-family:var(--font-display); font-weight:800; font-size:1.4rem;
  margin:0 auto 1rem; transform:rotate(-6deg);
  box-shadow: 0 6px 16px rgba(0,82,12,.4);
}
.login-card h1{ text-align:center; font-size:1.35rem; margin:0 0 .2rem; }
.login-card .sub{ text-align:center; color:var(--text-muted); font-size:.85rem; margin-bottom:1.6rem;}
.login-error{ background:#FCE9EA; color:#C23237; border-radius: var(--radius-sm); padding:.6rem .8rem; font-size:.85rem; margin-bottom:1rem;}

/* Utilidades */
.text-muted-x{ color: var(--text-muted); }
.sr-only{ position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.d-flex{ display:flex; } .align-center{ align-items:center; } .justify-between{ justify-content:space-between;}
.gap-1{ gap:.4rem;} .gap-2{ gap:.8rem;} .gap-3{ gap:1.2rem;}
.mb-1{margin-bottom:.5rem;} .mb-2{margin-bottom:1rem;} .mb-3{margin-bottom:1.5rem;}
.grid{ display:grid; gap:1.2rem; }
.grid-4{ grid-template-columns: repeat(4, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
.grid-2{ grid-template-columns: repeat(2, 1fr); }

/* ---------------------------------------------------------
   RESPONSIVE
--------------------------------------------------------- */
@media (max-width: 992px){
  .grid-4{ grid-template-columns: repeat(2, 1fr); }
  .grid-3{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px){
  .sidebar{ transform: translateX(-100%); }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-backdrop.show{ display:block; }
  .main{ margin-left:0; }
  .burger{ display:flex; }
  .grid-2{ grid-template-columns: 1fr; }
}

@media (max-width: 560px){
  .grid-4, .grid-3{ grid-template-columns: 1fr 1fr; }
  .content{ padding:1rem; }
  .topbar{ padding:.7rem 1rem; }
  .card-x-body{ padding:1rem; }
}
