/* ============================================================
   Bodega Pipe — sistema de diseño
   ============================================================ */

:root {
    --bp-primary: #2563eb;                 /* sobrescrito por restaurante en layout.php */
    --bp-primary-contrast: #ffffff;

    --bp-radius: 14px;
    --bp-radius-sm: 9px;
    --bp-radius-lg: 20px;

    --bp-shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .10);
    --bp-shadow: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
    --bp-shadow-lg: 0 18px 40px rgba(15, 23, 42, .16);

    --bp-sidebar-w: 264px;
    --bp-topbar-h: 60px;

    --bp-ease: cubic-bezier(.4, 0, .2, 1);

    --bs-primary: var(--bp-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-link-color: var(--bp-primary);
    --bs-link-hover-color: color-mix(in srgb, var(--bp-primary) 78%, #000);
}

:root {
    --bp-bg: #f4f6fb;
    --bp-surface: #ffffff;
    --bp-surface-2: #f8fafc;
    --bp-border: #e6e9f2;
    --bp-text: #0f172a;
    --bp-text-muted: #64748b;
}

[data-bs-theme="dark"] {
    --bp-bg: #0b1120;
    --bp-surface: #131c31;
    --bp-surface-2: #0f1728;
    --bp-border: #26324b;
    --bp-text: #e8edf7;
    --bp-text-muted: #94a3b8;
    --bp-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --bp-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    --bp-shadow-lg: 0 22px 48px rgba(0, 0, 0, .6);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme="light"]) {
        --bp-bg: #0b1120;
        --bp-surface: #131c31;
        --bp-surface-2: #0f1728;
        --bp-border: #26324b;
        --bp-text: #e8edf7;
        --bp-text-muted: #94a3b8;
    }
}

* { box-sizing: border-box; }

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

[x-cloak] { display: none !important; }

a { color: var(--bp-primary); }

/* ---------- Botones / badges enganchados al color del negocio ---------- */
.btn-primary {
    --bs-btn-bg: var(--bp-primary);
    --bs-btn-border-color: var(--bp-primary);
    --bs-btn-color: var(--bp-primary-contrast);
    --bs-btn-hover-bg: color-mix(in srgb, var(--bp-primary) 86%, #000);
    --bs-btn-hover-border-color: color-mix(in srgb, var(--bp-primary) 86%, #000);
    --bs-btn-active-bg: color-mix(in srgb, var(--bp-primary) 78%, #000);
    --bs-btn-disabled-bg: var(--bp-primary);
    --bs-btn-disabled-border-color: var(--bp-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--bp-primary);
    --bs-btn-border-color: color-mix(in srgb, var(--bp-primary) 55%, transparent);
    --bs-btn-hover-bg: var(--bp-primary);
    --bs-btn-hover-border-color: var(--bp-primary);
    --bs-btn-hover-color: var(--bp-primary-contrast);
}
.text-bg-primary { background: var(--bp-primary) !important; color: var(--bp-primary-contrast) !important; }
.text-primary { color: var(--bp-primary) !important; }

.btn { border-radius: var(--bp-radius-sm); font-weight: 600; transition: transform .12s var(--bp-ease), box-shadow .2s var(--bp-ease), background-color .2s; }
.btn:active { transform: scale(.97); }
.form-control, .form-select { border-radius: var(--bp-radius-sm); border-color: var(--bp-border); background: var(--bp-surface); color: var(--bp-text); }
.form-control:focus, .form-select:focus {
    border-color: var(--bp-primary);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bp-primary) 25%, transparent);
}

/* ---------- Shell: sidebar + topbar ---------- */
.bp-shell { display: flex; min-height: 100vh; }

.bp-sidebar {
    width: var(--bp-sidebar-w);
    flex: 0 0 var(--bp-sidebar-w);
    background: var(--bp-surface);
    border-right: 1px solid var(--bp-border);
    position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: transform .28s var(--bp-ease);
}
.bp-sidebar__brand {
    height: var(--bp-topbar-h);
    display: flex; align-items: center; gap: .6rem;
    padding: 0 1rem; border-bottom: 1px solid var(--bp-border);
    font-weight: 800; letter-spacing: -.02em; color: var(--bp-text);
}
.bp-sidebar__brand img { width: 30px; height: 30px; object-fit: contain; border-radius: 7px; }
.bp-sidebar__brand .bp-logo-fallback {
    width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: var(--bp-primary); color: var(--bp-primary-contrast); font-size: .9rem;
}
.bp-sidebar__scroll { overflow-y: auto; flex: 1; padding: .75rem .6rem 1.5rem; }
.bp-switcher { padding: .6rem; }
.bp-navgroup { margin-top: 1rem; }
.bp-navgroup__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--bp-text-muted); padding: .3rem .7rem; font-weight: 700; }
.bp-navlink {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .7rem; margin: .1rem 0;
    border-radius: var(--bp-radius-sm);
    color: var(--bp-text-muted); text-decoration: none; font-weight: 600; font-size: .92rem;
    position: relative; transition: background-color .18s, color .18s;
}
.bp-navlink:hover { background: var(--bp-surface-2); color: var(--bp-text); }
.bp-navlink.is-active { background: color-mix(in srgb, var(--bp-primary) 12%, transparent); color: var(--bp-primary); }
.bp-navlink.is-active::before {
    content: ""; position: absolute; left: -.6rem; top: 20%; bottom: 20%;
    width: 3px; border-radius: 3px; background: var(--bp-primary);
    animation: bp-grow .25s var(--bp-ease);
}
.bp-navlink .bp-ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }

.bp-main-wrap { flex: 1; min-width: 0; margin-left: var(--bp-sidebar-w); display: flex; flex-direction: column; }

.bp-topbar {
    height: var(--bp-topbar-h);
    position: sticky; top: 0; z-index: 1030;
    background: color-mix(in srgb, var(--bp-surface) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--bp-border);
    display: flex; align-items: center; gap: .75rem;
    padding: 0 1.1rem;
}
.bp-topbar__title { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.bp-iconbtn {
    border: 1px solid var(--bp-border); background: var(--bp-surface);
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
    color: var(--bp-text-muted); cursor: pointer; transition: .15s var(--bp-ease);
}
.bp-iconbtn:hover { color: var(--bp-text); border-color: color-mix(in srgb, var(--bp-primary) 40%, var(--bp-border)); transform: translateY(-1px); }

.bp-content { padding: 1.4rem 1.6rem 3rem; max-width: 1180px; width: 100%; }

@media (max-width: 991.98px) {
    .bp-sidebar { transform: translateX(-100%); }
    .bp-shell.is-open .bp-sidebar { transform: translateX(0); box-shadow: var(--bp-shadow-lg); }
    .bp-main-wrap { margin-left: 0; }
    .bp-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 1035; }
}

/* ---------- Cards, page header, tablas ---------- */
.bp-card {
    background: var(--bp-surface); border: 1px solid var(--bp-border);
    border-radius: var(--bp-radius); box-shadow: var(--bp-shadow-sm);
}
.bp-card + .bp-card { margin-top: 1.1rem; }
.bp-card__body { padding: 1.15rem 1.25rem; }
.bp-card__head {
    padding: .9rem 1.25rem; border-bottom: 1px solid var(--bp-border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    font-weight: 700;
}
.card { background: var(--bp-surface); border-color: var(--bp-border); border-radius: var(--bp-radius); color: var(--bp-text); }
.card-header, .card-footer { background: var(--bp-surface-2); border-color: var(--bp-border); }

.bp-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.bp-page-header h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.bp-page-header .bp-sub { color: var(--bp-text-muted); font-size: .9rem; }

.table { color: var(--bp-text); --bs-table-bg: transparent; }
.table > :not(caption) > * > * { border-color: var(--bp-border); }
.bp-table-wrap { overflow-x: auto; border-radius: var(--bp-radius); }
.bp-table thead th {
    position: sticky; top: 0; background: var(--bp-surface-2);
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--bp-text-muted); font-weight: 700; white-space: nowrap;
}
.bp-table tbody tr { transition: background-color .15s; }
.bp-table tbody tr:hover { background: var(--bp-surface-2); }
.bp-table .cell-edit { cursor: text; border-radius: 7px; transition: box-shadow .15s, background .15s; }
.bp-table .cell-edit:hover { background: color-mix(in srgb, var(--bp-primary) 8%, transparent); }
.bp-row-saved { animation: bp-flash-ok 1s var(--bp-ease); }

/* ---------- Stat tiles ---------- */
.bp-stats { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1.3rem; }
.bp-stat {
    background: var(--bp-surface); border: 1px solid var(--bp-border);
    border-radius: var(--bp-radius); padding: 1rem 1.1rem; box-shadow: var(--bp-shadow-sm);
    position: relative; overflow: hidden;
}
.bp-stat::after {
    content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px;
    border-radius: 50%; background: color-mix(in srgb, var(--bp-primary) 12%, transparent);
}
.bp-stat__label { color: var(--bp-text-muted); font-size: .8rem; font-weight: 600; }
.bp-stat__value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-top: .2rem; }
.bp-stat__hint { font-size: .78rem; color: var(--bp-text-muted); }

/* ---------- Chips / filtros ---------- */
.bp-toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.bp-chip {
    border: 1px solid var(--bp-border); background: var(--bp-surface);
    border-radius: 999px; padding: .3rem .8rem; font-size: .82rem; font-weight: 600;
    color: var(--bp-text-muted); cursor: pointer; transition: .15s;
}
.bp-chip.is-active { background: var(--bp-primary); color: var(--bp-primary-contrast); border-color: var(--bp-primary); }
.bp-chip-hoy:not(.is-active) { border-color: var(--bp-primary); color: var(--bp-primary); }

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

/* ---------- Skeleton ---------- */
.bp-skeleton { background: linear-gradient(90deg, var(--bp-surface-2) 25%, var(--bp-border) 37%, var(--bp-surface-2) 63%); background-size: 400% 100%; border-radius: 6px; }

/* ---------- Login ---------- */
.bp-login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; position: relative; overflow: hidden; }
.bp-login__bg {
    position: absolute; inset: 0; z-index: 0;
    background: radial-gradient(1200px 600px at 15% 10%, color-mix(in srgb, var(--bp-primary) 24%, transparent), transparent 60%),
               radial-gradient(1000px 500px at 90% 90%, color-mix(in srgb, var(--bp-primary) 18%, transparent), transparent 55%),
               var(--bp-bg);
}
.bp-login__card { position: relative; z-index: 1; width: min(400px, 100%); }

/* ============================================================
   Animaciones
   ============================================================ */
@keyframes bp-fade-in-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bp-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes bp-flash-ok {
    0% { background: color-mix(in srgb, #16a34a 30%, transparent); }
    100% { background: transparent; }
}
@keyframes bp-skeleton { to { background-position: -135% 0; } }
@keyframes bp-toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes bp-drift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(0, -18px, 0) scale(1.04); }
}

@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }

    .bp-content > * { animation: bp-fade-in-up .32s var(--bp-ease) both; }
    .bp-anim-list > * { animation: bp-fade-in-up .3s var(--bp-ease) both; }
    .bp-anim-list > *:nth-child(1) { animation-delay: .02s; }
    .bp-anim-list > *:nth-child(2) { animation-delay: .05s; }
    .bp-anim-list > *:nth-child(3) { animation-delay: .08s; }
    .bp-anim-list > *:nth-child(4) { animation-delay: .11s; }
    .bp-anim-list > *:nth-child(5) { animation-delay: .14s; }
    .bp-anim-list > *:nth-child(6) { animation-delay: .17s; }
    .bp-anim-list > *:nth-child(7) { animation-delay: .20s; }
    .bp-anim-list > *:nth-child(8) { animation-delay: .23s; }
    .bp-anim-list > *:nth-child(n+9) { animation-delay: .26s; }

    .bp-card, .bp-stat { transition: transform .2s var(--bp-ease), box-shadow .2s var(--bp-ease); }
    .bp-stat:hover { transform: translateY(-3px); box-shadow: var(--bp-shadow); }

    .bp-toast { animation: bp-toast-in .28s var(--bp-ease) both; }
    .bp-skeleton { animation: bp-skeleton 1.3s ease-in-out infinite; }
    .bp-login__bg::before, .bp-login__bg::after {
        content: ""; position: absolute; border-radius: 50%; filter: blur(30px);
        background: color-mix(in srgb, var(--bp-primary) 35%, transparent);
    }
    .bp-login__bg::before { width: 320px; height: 320px; left: 8%; top: 12%; animation: bp-drift 14s ease-in-out infinite; }
    .bp-login__bg::after { width: 260px; height: 260px; right: 10%; bottom: 10%; animation: bp-drift 18s ease-in-out infinite reverse; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* util */
.bp-muted { color: var(--bp-text-muted); }
.bp-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.bp-line-row td { padding-top: .3rem; padding-bottom: .3rem; }
