/* =========================================================
   Copy & KasNet POS — estilos principales
   ========================================================= */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --kasnet: #ea580c;
    --kasnet-dark: #c2410c;
    --sidebar-bg: #111827;
    --sidebar-bg-2: #1f2937;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #6b7280;
    --sidebar-width: 260px;
    --sidebar-collapsed: 74px;
    --topbar-h: 60px;
    --body-bg: #f3f4f8;
    --card-radius: 14px;
    --bs-primary: var(--primary);
    --bs-primary-rgb: 79, 70, 229;
}

body {
    background: var(--body-bg);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .925rem;
    color: #1f2937;
}

.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-active-bg: var(--primary-dark); }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary); --bs-btn-active-bg: var(--primary); }
.btn-kasnet { background: var(--kasnet); border-color: var(--kasnet); color: #fff; }
.btn-kasnet:hover, .btn-kasnet:focus { background: var(--kasnet-dark); border-color: var(--kasnet-dark); color: #fff; }
.text-primary { color: var(--primary) !important; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: width .2s ease, transform .2s ease;
}
.app-main {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-width: 0;
    transition: margin-left .2s ease;
}
.app-content { padding: 1.25rem; flex: 1; }

.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem; height: var(--topbar-h); border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 1.2rem; }
.brand-icon.lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; background: rgba(255,255,255,.18); }
.brand-text { line-height: 1.1; white-space: nowrap; }
.brand-text strong { color: #fff; font-size: 1.05rem; }
.brand-text strong span { color: var(--kasnet); }
.brand-text small { display: block; color: var(--sidebar-muted); font-size: .72rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem 0; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #374151; border-radius: 5px; }
.nav-list, .submenu { list-style: none; margin: 0; padding: 0; }
.nav-section { padding: 1rem 1.25rem .35rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); white-space: nowrap; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .75rem;
    margin: 2px .65rem; padding: .6rem .75rem;
    color: var(--sidebar-text); border-radius: 10px; white-space: nowrap;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link > .bi:first-child { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.45); }
.sidebar-nav .nav-link.active-parent { color: #fff; }
.sidebar-nav .caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.sidebar-nav .nav-link:not(.collapsed) .caret { transform: rotate(180deg); }
.submenu .nav-link { padding: .45rem .75rem .45rem 2.9rem; font-size: .87rem; }
.submenu .nav-link.active { background: rgba(79,70,229,.25); box-shadow: none; color: #fff; }
.submenu .nav-link::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; margin-left: -1.1rem; }

/* Sidebar colapsado (escritorio) */
.sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed); }
.sidebar-collapsed .app-main { margin-left: var(--sidebar-collapsed); }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-section,
.sidebar-collapsed .nav-link span,
.sidebar-collapsed .caret,
.sidebar-collapsed .submenu { display: none !important; }
.sidebar-collapsed .sidebar-nav .nav-link { justify-content: center; }
.sidebar-collapsed .app-sidebar:hover { width: var(--sidebar-width); }
.sidebar-collapsed .app-sidebar:hover .brand-text,
.sidebar-collapsed .app-sidebar:hover .nav-section,
.sidebar-collapsed .app-sidebar:hover .nav-link span,
.sidebar-collapsed .app-sidebar:hover .caret { display: initial !important; }
.sidebar-collapsed .app-sidebar:hover .submenu.show { display: block !important; }
.sidebar-collapsed .app-sidebar:hover .sidebar-nav .nav-link { justify-content: flex-start; }

.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.app-topbar {
    position: sticky; top: 0; z-index: 1030;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.25rem;
    background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border-bottom: 1px solid #e5e7eb;
}
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar-clock { font-variant-numeric: tabular-nums; color: #6b7280; font-size: .85rem; padding: 0 .5rem; }
.btn-icon { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; font-size: 1.35rem; color: #374151; border: 0; background: transparent; }
.btn-icon:hover { background: #f3f4f6; }

/* Campana de notificaciones */
.notif-badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #f59e0b; color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid #fff; box-sizing: content-box; }
.notif-badge.peligro { background: #dc2626; }
.notif-menu { width: 360px; max-width: calc(100vw - 1.5rem); border: 0; border-radius: 14px; box-shadow: 0 12px 32px rgba(16,24,40,.18); overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; font-weight: 600; border-bottom: 1px solid #eef0f4; }
#notifLista { max-height: 420px; overflow-y: auto; }
.notif-grupo { padding: .5rem 1rem .25rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: #9ca3af; background: #f9fafb; }
.notif-item { display: flex; align-items: center; gap: .7rem; padding: .65rem 1rem; color: #1f2937; text-decoration: none; border-bottom: 1px solid #f3f4f6; font-size: .85rem; line-height: 1.3; }
a.notif-item:hover { background: #f5f5ff; color: #1f2937; }
.notif-icon { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; display: grid; place-items: center; font-size: .95rem; }
.notif-texto { flex: 1; }
.notif-vacio { padding: 1.5rem; text-align: center; color: #059669; }
.notif-vacio i { display: block; font-size: 1.8rem; margin-bottom: .25rem; }

/* ---------- Cards / stats ---------- */
.card { border: 0; border-radius: var(--card-radius); box-shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f4; font-weight: 600; padding: .85rem 1.1rem; border-radius: var(--card-radius) var(--card-radius) 0 0 !important; }
.card-footer { background: #fff; border-top: 1px solid #eef0f4; border-radius: 0 0 var(--card-radius) var(--card-radius) !important; }
.table > :not(caption) > * > * { padding: .6rem .85rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; background: #f9fafb; font-weight: 600; white-space: nowrap; }

.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.2rem; border-radius: var(--card-radius); background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,.06); height: 100%; }
.stat-icon { width: 54px; height: 54px; flex: 0 0 54px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; }
.stat-label { font-size: .8rem; color: #6b7280; }
.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.stat-sub { font-size: .75rem; color: #9ca3af; }
.stat-primary .stat-icon { background: #eef2ff; color: var(--primary); }
.stat-kasnet .stat-icon { background: #fff7ed; color: var(--kasnet); }
.stat-success .stat-icon { background: #ecfdf5; color: #059669; }
.stat-info .stat-icon { background: #ecfeff; color: #0891b2; }
.stat-danger .stat-icon { background: #fef2f2; color: #dc2626; }
.stat-danger .stat-value { color: #dc2626; }

.mini-stat { background: #fff; border-radius: 12px; padding: .85rem 1rem; box-shadow: 0 1px 3px rgba(16,24,40,.06); height: 100%; }
.mini-stat span { display: block; font-size: .75rem; color: #6b7280; }
.mini-stat strong { font-size: 1.2rem; }
.mini-stat small { display: block; font-size: .72rem; color: #9ca3af; }
.mini-stat.highlight { background: var(--primary); color: #fff; }
.mini-stat.highlight span, .mini-stat.highlight small { color: rgba(255,255,255,.75); }
.mini-stat.danger { background: #fef2f2; }
.mini-stat.danger strong { color: #dc2626; }

.summary-list li { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px dashed #e5e7eb; }
.summary-list li.total { border-bottom: 0; font-size: 1.1rem; color: var(--primary); }

.badge-estado { font-weight: 500; }
.table-actions { white-space: nowrap; text-align: right; }
.table-actions .btn { padding: .2rem .45rem; }

/* ---------- Login ---------- */
.auth-body { background: radial-gradient(circle at 10% 10%, #6366f1 0, transparent 40%), radial-gradient(circle at 90% 90%, #f97316 0, transparent 40%), #1e1b4b; min-height: 100vh; }
.login-wrapper { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 900px; display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.login-side { background: linear-gradient(135deg, var(--primary), #7c3aed 60%, var(--kasnet)); color: #fff; padding: 2.5rem; display: flex; align-items: center; }
.login-side h2 { margin: 1rem 0 .5rem; font-weight: 700; }
.login-side p { opacity: .85; }
.login-features { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.login-features li { padding: .35rem 0; }
.login-features i { margin-right: .5rem; }
.login-form { padding: 2.5rem; }
@media (max-width: 767.98px) { .login-card { grid-template-columns: 1fr; } .login-side { display: none; } }

.error-page { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; color: #fff; padding: 1rem; }
.error-page .text-muted { color: #c7d2fe !important; }
.error-code { font-size: 6rem; font-weight: 800; line-height: 1; }
.error-trace { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: 10px; max-width: 900px; max-height: 300px; overflow: auto; font-size: .75rem; }

/* ---------- POS ---------- */
.pos-layout { display: grid; grid-template-columns: 1fr 400px; gap: 1rem; height: calc(100vh - var(--topbar-h) - 2.5rem); min-height: 520px; }
.pos-catalog, .pos-cart { display: flex; flex-direction: column; min-height: 0; }
/* Bootstrap da flex:1 a .card-body; en el POS solo deben crecer la grilla y la lista del carrito */
.pos-catalog > .card-body, .pos-cart > .card-body { flex: 0 0 auto; }
.pos-categorias { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .25rem; }
.pos-categorias .btn { white-space: nowrap; border-radius: 20px; }
.pos-grid { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; align-content: start; }
.pos-product { border: 1px solid #e5e7eb; border-radius: 12px; padding: .75rem; background: #fff; cursor: pointer; text-align: left; transition: all .12s; display: flex; flex-direction: column; gap: .25rem; min-height: 110px; }
.pos-product:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(79,70,229,.15); transform: translateY(-1px); }
.pos-product .name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.pos-product .code { font-size: .7rem; color: #9ca3af; }
.pos-product .price { margin-top: auto; font-weight: 700; color: var(--primary); font-size: 1.05rem; }
.pos-product .tag .badge { font-size: .7rem; font-weight: 600; }
.pos-product .unit { font-size: .7rem; font-weight: 400; color: #9ca3af; }
.pos-mas { grid-column: 1 / -1; text-align: center; padding: .5rem; }
.pos-product.servicio { border-left: 4px solid var(--kasnet); }
.pos-product.sin-stock { opacity: .5; }
.pos-items { flex: 1; overflow-y: auto; padding: 0 1rem; }
.pos-item { display: grid; grid-template-columns: 1fr auto; gap: .25rem .5rem; padding: .55rem 0; border-bottom: 1px dashed #e5e7eb; }
.pos-item .desc { font-weight: 600; font-size: .85rem; }
.pos-item .line-total { font-weight: 700; text-align: right; }
.pos-item .controls { display: flex; align-items: center; gap: .3rem; grid-column: 1 / -1; }
.pos-item .controls input { width: 70px; text-align: center; }
.pos-item .controls .precio { width: 85px; }
.pos-empty { text-align: center; color: #9ca3af; padding: 2.5rem 0; }
.pos-totals { border-top: 1px solid #e5e7eb; padding: .75rem 1rem 1rem; background: #fafafa; border-radius: 0 0 var(--card-radius) var(--card-radius); }
.pos-total { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-top: .25rem; }
.pos-metodos { display: flex; flex-wrap: wrap; gap: .3rem; }
.pos-billetes { display: flex; flex-wrap: wrap; gap: .3rem; }
.pos-billetes .btn { flex: 1; border: 1px solid #e5e7eb; }
@media (max-width: 991.98px) { .pos-layout { grid-template-columns: 1fr; height: auto; } .pos-grid { max-height: 50vh; } .pos-items { max-height: 40vh; } }

/* ---------- KasNet ---------- */
.kasnet-header { background: linear-gradient(90deg, var(--kasnet), #f59e0b) !important; color: #fff; display: flex; align-items: center; }
.kasnet-tipos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .4rem; }
.kasnet-tipo { border: 1px solid #e5e7eb; border-radius: 10px; padding: .5rem .6rem; display: flex; align-items: center; gap: .5rem; font-size: .8rem; text-align: left; background: #fff; line-height: 1.15; }
.kasnet-tipo i { font-size: 1.2rem; }
.btn-check:checked + .kasnet-tipo { border-color: var(--kasnet); background: #fff7ed; box-shadow: 0 0 0 2px rgba(234,88,12,.25); color: #9a3412; font-weight: 600; }

.mov-motivos { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.mov-motivos .btn { font-size: .8rem; padding: .45rem .25rem; }
@media (max-width: 575.98px) { .mov-motivos { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Roles y permisos ---------- */
.rol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.rol-card { background: #fff; border-radius: var(--card-radius); box-shadow: 0 1px 3px rgba(16,24,40,.06); padding: 1.1rem; display: flex; flex-direction: column; gap: .75rem; border: 1px solid transparent; transition: border-color .15s; }
.rol-card:hover { border-color: #e0e7ff; }
.rol-head { display: flex; align-items: center; gap: .75rem; }
.rol-icon { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; }
.rol-nombre { font-weight: 700; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.rol-meta { font-size: .78rem; color: #6b7280; }
.rol-desc { font-size: .85rem; color: #6b7280; flex: 1; }
.rol-acciones { display: flex; gap: .5rem; }
.min-w-0 { min-width: 0; }
.rol-c-purple { background: #ede9fe; color: #7c3aed; }
.rol-c-teal   { background: #ccfbf1; color: #0d9488; }
.rol-c-peach  { background: #ffedd5; color: #ea580c; }
.rol-c-yellow { background: #fef9c3; color: #ca8a04; }
.rol-c-blue   { background: #dbeafe; color: #2563eb; }
.rol-c-red    { background: #fee2e2; color: #dc2626; }
.rol-c-slate  { background: #e2e8f0; color: #475569; }
.rol-colores { display: flex; gap: .5rem; flex-wrap: wrap; }
.rol-color-op { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; cursor: pointer; font-size: 1.1rem; border: 2px solid transparent; }
.btn-check:checked + .rol-color-op { border-color: currentColor; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

.perm-bar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.perm-head, .perm-fila { display: grid; grid-template-columns: 1fr 70px 70px 70px; align-items: center; gap: .5rem; }
.perm-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; font-weight: 600; padding: .4rem .75rem; border-bottom: 1px solid #e5e7eb; }
.perm-head span:not(:first-child), .perm-fila > :not(:first-child) { text-align: center; justify-self: center; }
.perm-grupo { margin-top: .75rem; }
.perm-grupo-titulo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--primary); padding: 0 .75rem .25rem; }
.perm-fila { padding: .45rem .75rem; border-radius: 8px; }
.perm-fila:nth-child(odd) { background: #f9fafb; }
.perm-nombre { font-size: .88rem; font-weight: 500; }
.perm-nombre small { display: block; font-size: .72rem; color: #9ca3af; font-weight: 400; }
.perm-chk { cursor: pointer; margin: 0; }
.perm-chk .form-check-input { width: 1.2em; height: 1.2em; margin: 0; cursor: pointer; }
.perm-na { color: #d1d5db; }

.card-empty { max-width: 560px; margin: 2rem auto; }

/* ---------- Responsive sidebar ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    .app-main { margin-left: 0 !important; }
    .sidebar-open .app-sidebar { transform: none; }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
    .sidebar-collapsed .brand-text, .sidebar-collapsed .nav-section,
    .sidebar-collapsed .nav-link span, .sidebar-collapsed .caret { display: initial !important; }
    .app-content { padding: 1rem; }
}
