/* ============================================================
   Ranyave — panel de gestion (sistema de diseno)
   ============================================================ */
:root {
    --rv-primary: #2563eb;
    --rv-primary-contrast: #ffffff;
    --rv-radius: 14px;
    --rv-radius-sm: 9px;
    --rv-sidebar-w: 244px;
    --rv-topbar-h: 58px;
    --rv-ease: cubic-bezier(.4, 0, .2, 1);

    --rv-bg: #f4f6fb;
    --rv-surface: #ffffff;
    --rv-surface-2: #f8fafc;
    --rv-border: #e6e9f2;
    --rv-text: #0f172a;
    --rv-muted: #64748b;
    --rv-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .10);
    --rv-shadow: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
    --rv-shadow-lg: 0 18px 40px rgba(15, 23, 42, .16);

    --bs-primary: var(--rv-primary);
    --bs-link-color: var(--rv-primary);
}

@media (prefers-color-scheme: dark) {
    :root {
        --rv-bg: #0b1120;
        --rv-surface: #131c31;
        --rv-surface-2: #0f1728;
        --rv-border: #26324b;
        --rv-text: #e8edf7;
        --rv-muted: #94a3b8;
        --rv-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --rv-shadow: 0 6px 18px rgba(0, 0, 0, .45);
        --rv-shadow-lg: 0 22px 48px rgba(0, 0, 0, .6);
    }
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
    margin: 0;
    background: var(--rv-bg);
    color: var(--rv-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
a { color: var(--rv-primary); }

/* ---------- Bootstrap tie-ins ---------- */
.btn { border-radius: var(--rv-radius-sm); font-weight: 600; transition: transform .12s var(--rv-ease); }
.btn:active { transform: scale(.97); }
.btn-primary {
    --bs-btn-bg: var(--rv-primary); --bs-btn-border-color: var(--rv-primary);
    --bs-btn-color: var(--rv-primary-contrast);
    --bs-btn-hover-bg: color-mix(in srgb, var(--rv-primary) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--rv-primary) 86%, #000);
    --bs-btn-hover-color: var(--rv-primary-contrast);
    --bs-btn-active-bg: color-mix(in srgb, var(--rv-primary) 78%, #000);
    --bs-btn-disabled-bg: var(--rv-primary); --bs-btn-disabled-border-color: var(--rv-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--rv-primary);
    --bs-btn-border-color: color-mix(in srgb, var(--rv-primary) 55%, transparent);
    --bs-btn-hover-bg: var(--rv-primary); --bs-btn-hover-border-color: var(--rv-primary);
    --bs-btn-hover-color: var(--rv-primary-contrast);
}
.text-bg-primary { background: var(--rv-primary) !important; color: var(--rv-primary-contrast) !important; }
.form-control, .form-select {
    border-radius: var(--rv-radius-sm); border-color: var(--rv-border);
    background: var(--rv-surface); color: var(--rv-text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--rv-primary);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--rv-primary) 22%, transparent);
    background: var(--rv-surface); color: var(--rv-text);
}
.table { color: var(--rv-text); --bs-table-bg: transparent; }
.table > :not(caption) > * > * { border-color: var(--rv-border); }
.modal-content, .dropdown-menu { background: var(--rv-surface); color: var(--rv-text); border-color: var(--rv-border); }

/* ---------- Shell ---------- */
.rv-shell { display: flex; min-height: 100vh; }
.rv-sidebar {
    width: var(--rv-sidebar-w); flex: 0 0 var(--rv-sidebar-w);
    background: var(--rv-surface); border-right: 1px solid var(--rv-border);
    position: fixed; inset: 0 auto 0 0; z-index: 1040;
    display: flex; flex-direction: column;
    transition: transform .28s var(--rv-ease);
}
.rv-sidebar__brand {
    height: var(--rv-topbar-h); display: flex; align-items: center; gap: .55rem;
    padding: 0 1rem; border-bottom: 1px solid var(--rv-border);
    font-weight: 800; letter-spacing: -.02em; color: var(--rv-text); text-decoration: none;
}
.rv-logo {
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: var(--rv-primary); color: var(--rv-primary-contrast); font-weight: 800; font-size: .95rem;
    flex: 0 0 30px;
}
.rv-logo--lg { width: 52px; height: 52px; border-radius: 15px; font-size: 1.5rem; flex-basis: 52px; }
.rv-sidebar__nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; }
.rv-sidebar__foot { padding: .6rem; border-top: 1px solid var(--rv-border); }
.rv-navgroup__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--rv-muted); padding: 1rem .7rem .3rem; font-weight: 700; }
.rv-navlink {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; margin: .12rem 0;
    border-radius: var(--rv-radius-sm); color: var(--rv-muted); text-decoration: none;
    font-weight: 600; font-size: .92rem; transition: background-color .16s, color .16s;
}
.rv-navlink:hover { background: var(--rv-surface-2); color: var(--rv-text); }
.rv-navlink.is-active { background: color-mix(in srgb, var(--rv-primary) 13%, transparent); color: var(--rv-primary); }
.rv-ico { width: 18px; height: 18px; flex: 0 0 18px; }

.rv-main { flex: 1; min-width: 0; margin-left: var(--rv-sidebar-w); display: flex; flex-direction: column; }
.rv-topbar {
    height: var(--rv-topbar-h); position: sticky; top: 0; z-index: 1030;
    background: color-mix(in srgb, var(--rv-surface) 90%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--rv-border);
    display: flex; align-items: center; gap: .75rem; padding: 0 1.1rem;
}
.rv-topbar__title { font-weight: 700; font-size: 1.02rem; }
.rv-iconbtn {
    border: 1px solid var(--rv-border); background: var(--rv-surface); color: var(--rv-muted);
    height: 38px; min-width: 38px; border-radius: 10px; display: inline-grid; place-items: center;
    cursor: pointer; transition: .15s var(--rv-ease);
}
.rv-iconbtn:hover { color: var(--rv-text); border-color: color-mix(in srgb, var(--rv-primary) 40%, var(--rv-border)); }
.rv-menu {
    position: absolute; right: 0; margin-top: .4rem; min-width: 190px; z-index: 1050;
    background: var(--rv-surface); border: 1px solid var(--rv-border); border-radius: var(--rv-radius-sm);
    box-shadow: var(--rv-shadow-lg); padding: .5rem;
}
.rv-content { padding: 1.3rem 1.5rem 3rem; max-width: 1240px; width: 100%; }
.rv-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 1035; }

@media (max-width: 991.98px) {
    .rv-sidebar { transform: translateX(-100%); }
    .rv-shell.is-open .rv-sidebar { transform: translateX(0); box-shadow: var(--rv-shadow-lg); }
    .rv-main { margin-left: 0; }
    .rv-content { padding: 1rem 1rem 3rem; }
}

/* ---------- Bloques ---------- */
.rv-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.rv-page-header h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.rv-page-header .rv-sub { color: var(--rv-muted); font-size: .9rem; margin-top: .15rem; }
.rv-card { background: var(--rv-surface); border: 1px solid var(--rv-border); border-radius: var(--rv-radius); box-shadow: var(--rv-shadow-sm); }
.rv-card + .rv-card { margin-top: 1.1rem; }
.rv-card__head { padding: .85rem 1.15rem; border-bottom: 1px solid var(--rv-border); font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.rv-card__body { padding: 1.1rem 1.15rem; }
.rv-muted { color: var(--rv-muted); }
.rv-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.rv-stats { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.3rem; }
.rv-stat { background: var(--rv-surface); border: 1px solid var(--rv-border); border-radius: var(--rv-radius); padding: 1rem 1.1rem; box-shadow: var(--rv-shadow-sm); }
.rv-stat__label { color: var(--rv-muted); font-size: .8rem; font-weight: 600; }
.rv-stat__value { font-size: 1.8rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin-top: .15rem; }
.rv-stat__value.is-warn { color: #d97706; }
.rv-stat__hint { font-size: .78rem; color: var(--rv-muted); margin-top: .1rem; }

.rv-table-wrap { overflow-x: auto; border-radius: var(--rv-radius); border: 1px solid var(--rv-border); }
table.rv-table { width: 100%; margin: 0; border-collapse: collapse; }
.rv-table th { background: var(--rv-surface-2); font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rv-muted); font-weight: 700; white-space: nowrap; padding: .6rem .75rem; text-align: left; }
.rv-table td { padding: .55rem .75rem; border-top: 1px solid var(--rv-border); vertical-align: middle; }
.rv-table tbody tr:hover { background: var(--rv-surface-2); }
.rv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rv-inline { border: 1px solid transparent; background: transparent; border-radius: 7px; padding: .25rem .4rem; width: 100%; color: inherit; font: inherit; }
.rv-inline:hover { border-color: var(--rv-border); }
.rv-inline:focus { outline: none; border-color: var(--rv-primary); background: var(--rv-surface); }
.rv-row-saved { animation: rv-flash 1s var(--rv-ease); }
@keyframes rv-flash { 0% { background: color-mix(in srgb, #16a34a 28%, transparent); } 100% { background: transparent; } }

.rv-pill { display: inline-block; padding: .18rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.rv-pill--ok { background: color-mix(in srgb, #16a34a 16%, transparent); color: #15803d; }
.rv-pill--low { background: color-mix(in srgb, #d97706 18%, transparent); color: #b45309; }
.rv-pill--out { background: color-mix(in srgb, #dc2626 15%, transparent); color: #b91c1c; }
.rv-pill--muted { background: var(--rv-surface-2); color: var(--rv-muted); }

.rv-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.rv-toolbar .form-control, .rv-toolbar .form-select { max-width: 280px; }

/* ---------- Toasts ---------- */
.rv-toasts { position: fixed; top: calc(var(--rv-topbar-h) + 12px); right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: .6rem; width: min(360px, calc(100vw - 32px)); }
.rv-toast { background: var(--rv-surface); border: 1px solid var(--rv-border); border-left: 4px solid var(--rv-primary); border-radius: var(--rv-radius-sm); box-shadow: var(--rv-shadow-lg); padding: .8rem .95rem; font-size: .9rem; font-weight: 500; cursor: pointer; }
.rv-toast.is-success { border-left-color: #16a34a; }
.rv-toast.is-danger { border-left-color: #dc2626; }
.rv-toast.is-warning { border-left-color: #d97706; }

/* ---------- Login ---------- */
.rv-login-body { background:
    radial-gradient(1000px 500px at 12% 8%, color-mix(in srgb, var(--rv-primary) 20%, transparent), transparent 60%),
    radial-gradient(900px 450px at 90% 92%, color-mix(in srgb, var(--rv-primary) 15%, transparent), transparent 55%),
    var(--rv-bg); }
.rv-login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.rv-login__card { width: min(400px, 100%); }

/* ============================================================
   PLANO (bodega / POS) — editor visual
   ============================================================ */
.rv-plano-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.rv-zonatabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.rv-zonatab { border: 1px solid var(--rv-border); background: var(--rv-surface); color: var(--rv-muted); border-radius: 999px; padding: .3rem .85rem; font-size: .84rem; font-weight: 600; cursor: pointer; }
.rv-zonatab.is-active { background: var(--rv-primary); color: var(--rv-primary-contrast); border-color: var(--rv-primary); }

.rv-plano {
    position: relative; overflow: auto; border: 1px solid var(--rv-border); border-radius: var(--rv-radius);
    background: var(--rv-surface); height: min(70vh, 640px); touch-action: none;
}
.rv-plano__lienzo {
    position: relative; width: 2000px; height: 1400px; transform-origin: 0 0;
    background-image:
        linear-gradient(color-mix(in srgb, var(--rv-border) 60%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--rv-border) 60%, transparent) 1px, transparent 1px);
    background-size: 40px 40px;
}
.rv-estante {
    position: absolute; background: var(--rv-surface-2); border: 2px solid color-mix(in srgb, var(--rv-primary) 45%, var(--rv-border));
    border-radius: 10px; box-shadow: var(--rv-shadow-sm); display: flex; flex-direction: column; overflow: hidden;
    user-select: none;
}
.rv-estante.is-selected { border-color: var(--rv-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rv-primary) 25%, transparent); }
.rv-estante__head {
    padding: .3rem .45rem; font-weight: 800; font-size: .82rem; cursor: grab;
    background: color-mix(in srgb, var(--rv-primary) 12%, transparent); color: var(--rv-text);
    display: flex; align-items: center; gap: .3rem; touch-action: none;
}
.rv-estante__head:active { cursor: grabbing; }
.rv-estante__name {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: transparent; border: none; font: inherit; color: inherit; padding: 0;
}
input.rv-estante__name { outline: 1px solid var(--rv-primary); border-radius: 4px; }
.rv-estante__body { flex: 1; display: flex; min-height: 0; }
.rv-columna {
    flex: 1; border-left: 1px dashed var(--rv-border); padding: .25rem; display: flex; flex-direction: column; gap: .2rem;
    cursor: pointer; min-width: 0; font-size: .72rem;
}
.rv-columna:first-child { border-left: none; }
.rv-columna:hover { background: color-mix(in srgb, var(--rv-primary) 8%, transparent); }
.rv-columna__name { font-weight: 700; color: var(--rv-muted); text-align: center; }
.rv-columna__badge { text-align: center; font-weight: 800; color: var(--rv-primary); }
.rv-columna__badge small { display: block; font-weight: 500; color: var(--rv-muted); }
.rv-estante__resize {
    position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; cursor: nwse-resize;
    border-right: 3px solid var(--rv-muted); border-bottom: 3px solid var(--rv-muted); border-radius: 0 0 6px 0; opacity: .6;
}

/* panel lateral (drawer) para gestionar una columna / seccion */
.rv-drawer-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.4); z-index: 1060; }
.rv-drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 1061;
    background: var(--rv-surface); border-left: 1px solid var(--rv-border); box-shadow: var(--rv-shadow-lg);
    display: flex; flex-direction: column;
}
.rv-drawer__head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--rv-border); display: flex; align-items: center; justify-content: space-between; }
.rv-drawer__body { flex: 1; overflow-y: auto; padding: 1.15rem; }

.rv-seccion { position: absolute; background: color-mix(in srgb, var(--rv-primary) 8%, var(--rv-surface-2)); border: 2px solid color-mix(in srgb, var(--rv-primary) 45%, var(--rv-border)); border-radius: 10px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: .85rem; user-select: none; cursor: grab; }
.rv-seccion.is-selected { border-color: var(--rv-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rv-primary) 25%, transparent); }

/* Producto thumb en catalogo */
.rv-thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--rv-surface-2); border: 1px solid var(--rv-border); }

@media (prefers-reduced-motion: no-preference) {
    .rv-content > * { animation: rv-fade .3s var(--rv-ease) both; }
    @keyframes rv-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
