/* Dialog layer map
   - Side panel: base lateral form/dialog
   - Stacked panel: error/detail panel shown above the side panel
   - Confirm dialog: highest layer for destructive/unsaved-changes confirmation
*/
:root {
    --barcino-side-panel-width: 50vw;
    --barcino-dialog-z-stacked-mask: 1599;
    --barcino-dialog-z-stacked-wrapper: 1600;
    --barcino-dialog-z-stacked-panel: 1601;
    --barcino-dialog-z-confirm-mask: 1699;
    --barcino-dialog-z-confirm-wrapper: 1700;
    --barcino-dialog-z-confirm-panel: 1701;
}

.barcino-side-panel-wrapper {
    width: var(--barcino-side-panel-width) !important;
    max-width: var(--barcino-side-panel-width) !important;
}

.barcino-side-panel-wrapper.barcino-side-panel-full {
    width: 100vw !important;
    max-width: 100vw !important;
}

.barcino-side-panel {
    width: var(--barcino-side-panel-width) !important;
    max-width: var(--barcino-side-panel-width) !important;
    height: 100vh !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* DARK THEME — side panel lives outside .rz-material-dark in the DOM;
   must use html:has() so theme variables and background cascade into it */
html:has(.rz-material-dark) .barcino-side-panel {
    background-color: var(--bc-navy) !important;
    color: var(--bc-cream) !important;
    /* Re-declare theme vars so they cascade to all content inside the panel */
    --bc-text-soft:    rgba(243, 238, 229, 0.65);
    --bc-border-color: rgba(243, 238, 229, 0.1);
    --rz-text-color:   var(--bc-cream);
    --rz-base-background-color: var(--bc-navy);
}

html:has(.rz-material-dark) .barcino-side-panel-content {
    background-color: var(--bc-navy);
}

/* Side panel cards: use navy-soft so they lift above the navy background */
html:has(.rz-material-dark) .barcino-side-panel-content .rz-card {
    background-color: var(--bc-navy-soft) !important;
    border-color: rgba(243, 238, 229, 0.08) !important;
}

/* DARK THEME — inputs and labels inside the side panel */
html:has(.rz-material-dark) .barcino-side-panel-content .rz-textbox,
html:has(.rz-material-dark) .barcino-side-panel-content .rz-dropdown-label {
    background-color: var(--bc-navy-soft) !important;
    border-color: rgba(243, 238, 229, 0.14) !important;
    color: var(--bc-cream) !important;
}

html:has(.rz-material-dark) .barcino-side-panel-content .barcino-field-label {
    color: var(--bc-cream) !important;
}

.barcino-side-panel.barcino-side-panel-full {
    width: 100vw !important;
    max-width: 100vw !important;
}

/* All barcino side panels render bc-dialog-header — hide Radzen's titlebar */
.barcino-side-panel .rz-dialog-side-titlebar {
    display: none;
}

.barcino-side-panel-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.barcino-side-dialog-shell {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.barcino-side-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.barcino-side-form-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--bc-border-color, rgba(10, 14, 31, 0.08));
}

/* ════════════════════════════════════════════════════════
   DIALOG FORM HEADER — bc-dialog-header
   Placed as first child of barcino-side-form (inside
   barcino-side-panel-content which has padding: 1.5rem).
   Negative margin extends it edge-to-edge.
   ════════════════════════════════════════════════════════ */
.bc-dialog-header {
    margin: -1.5rem -1.5rem 0;
    padding: 1.75rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--bc-border-color, rgba(10, 14, 31, 0.08));
    flex-shrink: 0;
}

.bc-dialog-header-eyebrow {
    font-family: "Inter", sans-serif;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--bc-grana);
    margin-bottom: 0.5rem;
}

.bc-dialog-header-title {
    font-family: "Fraunces", Georgia, serif;
    font-size: 2rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0 0 0.5rem;
    color: var(--rz-text-color);
}

.bc-dialog-header-sub {
    font-size: 0.875rem;
    color: var(--bc-text-soft, rgba(10, 14, 31, 0.65));
    margin: 0;
    line-height: 1.5;
    max-width: 34rem;
}

.barcino-stacked-panel-wrapper {
    position: fixed !important;
    inset: 0 0 0 auto !important;
    width: var(--barcino-side-panel-width) !important;
    max-width: var(--barcino-side-panel-width) !important;
    height: 100vh !important;
    margin: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: stretch !important;
    pointer-events: none;
    z-index: var(--barcino-dialog-z-stacked-wrapper) !important;
}

.barcino-stacked-panel-wrapper .rz-dialog {
    margin: 0 !important;
}

.barcino-stacked-panel-wrapper + .rz-dialog-mask {
    z-index: var(--barcino-dialog-z-stacked-mask) !important;
}

.barcino-stacked-panel {
    width: var(--barcino-side-panel-width) !important;
    max-width: var(--barcino-side-panel-width) !important;
    height: 100vh !important;
    border-radius: 0 !important;
    border-left: 1px solid rgba(23, 53, 45, 0.12);
    box-shadow: -24px 0 48px rgba(23, 53, 45, 0.18);
    background: var(--rz-dialog-background-color, #fff);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    z-index: var(--barcino-dialog-z-stacked-panel) !important;
    transform: translateX(0);
    animation: barcino-stacked-panel-enter 180ms ease-out;
}

.barcino-stacked-panel .rz-dialog-titlebar {
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(23, 53, 45, 0.12);
    padding: 1rem 1.5rem;
}

.barcino-stacked-panel-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

/* DARK THEME — stacked panel (error/detail overlay) lives outside .rz-material-dark;
   mirrors the same cascade pattern as .barcino-side-panel dark mode. */
html:has(.rz-material-dark) .barcino-stacked-panel {
    background-color: var(--bc-navy) !important;
    border-left-color: rgba(243, 238, 229, 0.1) !important;
    box-shadow: -24px 0 48px rgba(0, 0, 0, 0.5) !important;
    color: var(--bc-cream);
    --bc-text-soft:    rgba(243, 238, 229, 0.65);
    --bc-border-color: rgba(243, 238, 229, 0.1);
    --rz-text-color:   var(--bc-cream);
    --rz-base-background-color: var(--bc-navy);
}

html:has(.rz-material-dark) .barcino-stacked-panel-content {
    background-color: var(--bc-navy);
}

.barcino-confirm-on-top-wrapper {
    z-index: var(--barcino-dialog-z-confirm-wrapper) !important;
}

.barcino-confirm-on-top-wrapper + .rz-dialog-mask {
    z-index: var(--barcino-dialog-z-confirm-mask) !important;
}

.barcino-confirm-on-top {
    z-index: var(--barcino-dialog-z-confirm-panel) !important;
}

@keyframes barcino-stacked-panel-enter {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

/* ════════════════════════════════════════════════════════
   BARCINO DIALOG DESIGN
   Standard confirm / open dialogs rendered at <body> level,
   outside .rz-material[/dark] scope. Light rules are global;
   dark overrides use html:has(.rz-material-dark).
   Side panels already have their own styles — not targeted here.
   ════════════════════════════════════════════════════════ */

/* — Overlay mask — */
.rz-dialog-mask {
    background-color: rgba(10, 14, 31, 0.45) !important;
}

html:has(.rz-material-dark) .rz-dialog-mask {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

/* — Dialog container — */
.rz-dialog {
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(10, 14, 31, 0.12), 0 2px 8px rgba(10, 14, 31, 0.06) !important;
    background-color: #ffffff;
    min-width: 400px;
}

html:has(.rz-material-dark) .rz-dialog {
    background-color: var(--bc-navy) !important;
    border: 1px solid rgba(243, 238, 229, 0.1) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
    color: var(--bc-cream);
    --rz-text-color: var(--bc-cream);
    --rz-base-background-color: var(--bc-navy);
}

/* — Titlebar — */
.rz-dialog-titlebar {
    background-color: #ffffff !important;
    border-bottom: 1px solid rgba(10, 14, 31, 0.08) !important;
    padding: 1.25rem 1.5rem !important;
}

html:has(.rz-material-dark) .rz-dialog-titlebar {
    background-color: var(--bc-navy) !important;
    border-bottom-color: rgba(243, 238, 229, 0.1) !important;
}

/* — Title text — */
.rz-dialog-title {
    font-family: "Fraunces", Georgia, serif !important;
    font-weight: 500 !important;
    font-size: 1.25rem !important;
    letter-spacing: -0.01em !important;
    color: var(--bc-ink) !important;
    line-height: 1.3 !important;
}

html:has(.rz-material-dark) .rz-dialog-title {
    color: var(--bc-cream) !important;
}

/* — Close button — */
.rz-dialog-titlebar-close {
    color: rgba(10, 14, 31, 0.4) !important;
    transition: color 0.15s;
}

.rz-dialog-titlebar-close:hover {
    color: var(--bc-ink) !important;
}

html:has(.rz-material-dark) .rz-dialog-titlebar-close {
    color: rgba(243, 238, 229, 0.45) !important;
}

html:has(.rz-material-dark) .rz-dialog-titlebar-close:hover {
    color: var(--bc-cream) !important;
}

/* — Content area — */
.rz-dialog-content {
    padding: 1.5rem !important;
    color: var(--bc-ink);
    font-size: 0.9375rem;
    line-height: 1.55;
}

html:has(.rz-material-dark) .rz-dialog-content {
    color: var(--bc-cream) !important;
}

/* — Footer (confirm dialog buttons) — */
.rz-dialog-footer {
    padding: 1rem 1.5rem !important;
    border-top: 1px solid rgba(10, 14, 31, 0.08) !important;
    background-color: #ffffff !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 0.75rem !important;
}

html:has(.rz-material-dark) .rz-dialog-footer {
    background-color: var(--bc-navy) !important;
    border-top-color: rgba(243, 238, 229, 0.1) !important;
}

/* Stacked panel resets: full-height slide-in must not inherit the dialog
   border-radius or shadow added above (later cascade order). */
.barcino-stacked-panel {
    border-radius: 0 !important;
    box-shadow: -24px 0 48px rgba(23, 53, 45, 0.18) !important;
}

/* ════════════════════════════════════════════════════════
   CART PANEL (cesta-panel)
   Overrides panel-content padding/overflow so the cart
   controls its own sticky-header / sticky-footer layout.
   Uses CSS :has() — supported in all modern browsers.
   ════════════════════════════════════════════════════════ */
html:has(.cesta-panel) .barcino-side-panel-content {
    padding: 0 !important;
    overflow: hidden !important;
}

@media (max-width: 900px) {
    .barcino-side-panel-wrapper {
        inset: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
    }

    .barcino-side-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }

    .barcino-stacked-panel-wrapper {
        inset: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        margin: 0 !important;
    }

    .barcino-stacked-panel {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
}
