/*
 * App shell PWA / Capacitor.
 * Il sito resta invariato nel browser tradizionale; queste regole si attivano
 * soltanto nei contesti standalone e native rilevati da app-shell.js.
 */
:root {
    --rcd-app-navy: rgb(10, 42, 77);
    --rcd-app-cyan: rgb(93, 202, 220);
    --rcd-app-surface: #ffffff;
    --rcd-app-background: #f3f6f9;
    --rcd-app-text: #17324d;
    --rcd-app-muted: #52606d;
    --rcd-app-border: #d8e1e8;
    --rcd-app-bar-height: 62px;
    --rcd-app-nav-height: 70px;
}

.rcd-app-topbar,
.rcd-app-bottom-nav,
.rcd-network-banner,
.rcd-install-prompt {
    display: none;
}

.rcd-install-prompt {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1080;
    max-width: 430px;
    padding: 1rem;
    border: 1px solid var(--rcd-app-border);
    border-radius: .75rem;
    background: #fff;
    color: var(--rcd-app-text);
    box-shadow: 0 16px 40px rgba(10, 42, 77, .18);
}

.rcd-install-prompt > div:first-child {
    display: grid;
    gap: .15rem;
}

.rcd-install-prompt span {
    color: var(--rcd-app-muted);
}

.rcd-install-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: .85rem;
}

body.rcd-install-available .rcd-install-prompt:not([hidden]) {
    display: block;
}

.rcd-network-banner {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1200;
    padding: .55rem 1rem;
    background: #fff3cd;
    color: #5c4300;
    border-bottom: 1px solid #ffda6a;
    text-align: center;
    font-weight: 600;
}

body.rcd-network-offline .rcd-network-banner:not([hidden]) {
    display: block;
}

html[data-app-context="native"],
html[data-app-context="standalone"] {
    background: var(--rcd-app-background);
    overscroll-behavior-y: contain;
}

html[data-app-context="native"] body,
html[data-app-context="standalone"] body {
    min-height: 100dvh;
    padding-top: calc(var(--rcd-app-bar-height) + env(safe-area-inset-top, 0px));
    padding-bottom: calc(var(--rcd-app-nav-height) + env(safe-area-inset-bottom, 0px));
    background: var(--rcd-app-background);
    color: var(--rcd-app-text);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html[data-app-context="native"] body.rcd-network-offline,
html[data-app-context="standalone"] body.rcd-network-offline {
    padding-top: calc(var(--rcd-app-bar-height) + 42px + env(safe-area-inset-top, 0px));
}

html[data-app-context="native"] .acn-topbar,
html[data-app-context="native"] .acn-header,
html[data-app-context="native"] .acn-footer,
html[data-app-context="standalone"] .acn-topbar,
html[data-app-context="standalone"] .acn-header,
html[data-app-context="standalone"] .acn-footer {
    display: none !important;
}

html[data-app-context="native"] .rcd-app-topbar,
html[data-app-context="standalone"] .rcd-app-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1100;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    min-height: calc(var(--rcd-app-bar-height) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) .65rem 0;
    background: var(--rcd-app-navy);
    color: #fff;
    border-bottom: 3px solid var(--rcd-app-cyan);
    box-shadow: 0 2px 10px rgba(10, 42, 77, .22);
}

.rcd-app-back,
.rcd-app-account {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
}

.rcd-app-back:hover,
.rcd-app-back:focus-visible,
.rcd-app-account:hover,
.rcd-app-account:focus-visible {
    background: rgba(93, 202, 220, .2);
    color: #fff;
}

.rcd-app-back:focus-visible,
.rcd-app-account:focus-visible,
.rcd-app-bottom-nav a:focus-visible {
    outline: 3px solid var(--rcd-app-cyan);
    outline-offset: 1px;
}

.rcd-app-back svg,
.rcd-app-account svg {
    width: 24px;
    height: 24px;
}

.rcd-app-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
}

.rcd-app-brand:hover,
.rcd-app-brand:focus {
    color: #fff;
    text-decoration: none;
}

.rcd-app-brand img {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    object-fit: cover;
    background: #fff;
}

.rcd-app-brand span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 700;
}

html[data-app-context="native"] .rcd-app-bottom-nav,
html[data-app-context="standalone"] .rcd-app-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1100;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: calc(var(--rcd-app-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: .35rem .35rem env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--rcd-app-border);
    box-shadow: 0 -8px 24px rgba(10, 42, 77, .09);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.rcd-app-bottom-nav a {
    position: relative;
    display: grid;
    grid-template-rows: 26px auto;
    place-items: center;
    align-content: center;
    min-width: 0;
    min-height: 58px;
    gap: .15rem;
    border-radius: .65rem;
    color: #52606d;
    text-decoration: none;
    font-size: .74rem;
    font-weight: 600;
}

.rcd-app-bottom-nav a svg {
    width: 24px;
    height: 24px;
}

.rcd-app-bottom-nav a.active,
.rcd-app-bottom-nav a[aria-current="page"] {
    background: rgba(93, 202, 220, .16);
    color: var(--rcd-app-navy);
}

.rcd-app-bottom-nav a.active::before,
.rcd-app-bottom-nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 2px;
    width: 30px;
    height: 3px;
    border-radius: 999px;
    background: var(--rcd-app-cyan);
}

html[data-app-context="native"] main,
html[data-app-context="standalone"] main {
    width: 100%;
    max-width: none;
}

html[data-app-context="native"] .rcd-app-shell,
html[data-app-context="standalone"] .rcd-app-shell,
html[data-app-context="native"] main.container,
html[data-app-context="standalone"] main.container {
    margin-top: 0 !important;
    padding: 1rem max(1rem, env(safe-area-inset-left, 0px)) 1.5rem max(1rem, env(safe-area-inset-right, 0px));
}

html[data-app-context="native"] .rcd-user-layout,
html[data-app-context="standalone"] .rcd-user-layout {
    display: block;
}

html[data-app-context="native"] .rcd-user-nav,
html[data-app-context="standalone"] .rcd-user-nav {
    display: none !important;
}

html[data-app-context="native"] .rcd-page-header,
html[data-app-context="standalone"] .rcd-page-header {
    display: block;
    margin: 0 0 1rem;
    padding: .35rem 0 .5rem;
}

html[data-app-context="native"] .rcd-page-header h1,
html[data-app-context="standalone"] .rcd-page-header h1 {
    margin-bottom: .35rem;
    font-size: clamp(1.75rem, 7vw, 2.35rem);
    line-height: 1.08;
}

html[data-app-context="native"] .rcd-page-header p,
html[data-app-context="standalone"] .rcd-page-header p {
    margin-bottom: .75rem;
    color: var(--rcd-app-muted);
    line-height: 1.5;
}

html[data-app-context="native"] .rcd-panel,
html[data-app-context="standalone"] .rcd-panel,
html[data-app-context="native"] .card,
html[data-app-context="standalone"] .card {
    border: 1px solid var(--rcd-app-border);
    border-radius: 1rem;
    background: var(--rcd-app-surface);
    box-shadow: 0 8px 24px rgba(10, 42, 77, .07);
}

html[data-app-context="native"] .rcd-panel,
html[data-app-context="standalone"] .rcd-panel {
    padding: 1.1rem;
}

html[data-app-context="native"] .btn,
html[data-app-context="standalone"] .btn,
html[data-app-context="native"] .form-control,
html[data-app-context="standalone"] .form-control,
html[data-app-context="native"] .form-select,
html[data-app-context="standalone"] .form-select {
    min-height: 48px;
}

html[data-app-context="native"] .btn,
html[data-app-context="standalone"] .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html[data-app-context="native"] .acn-page-hero,
html[data-app-context="standalone"] .acn-page-hero {
    padding: 1.25rem 0 1.5rem;
}

html[data-app-context="native"] .acn-page-hero h1,
html[data-app-context="standalone"] .acn-page-hero h1 {
    font-size: clamp(2rem, 8vw, 2.75rem);
}

html[data-app-context="native"] .acn-tricolore-strip,
html[data-app-context="standalone"] .acn-tricolore-strip {
    position: fixed;
    top: calc(var(--rcd-app-bar-height) + env(safe-area-inset-top, 0px));
    right: 0;
    left: 0;
    z-index: 1090;
    height: 3px;
}

html[data-app-context="native"] .unified-registry-page,
html[data-app-context="standalone"] .unified-registry-page {
    padding-top: 1rem;
}

html[data-app-context="native"] .rcd-registry-tabs,
html[data-app-context="standalone"] .rcd-registry-tabs {
    margin-right: -1rem;
    padding-right: 1rem;
    scroll-snap-type: x proximity;
}

html[data-app-context="native"] .rcd-registry-tab,
html[data-app-context="standalone"] .rcd-registry-tab {
    min-height: 48px;
    scroll-snap-align: start;
}

html[data-app-context="native"] body.rcd-keyboard-open .rcd-app-bottom-nav,
html[data-app-context="standalone"] body.rcd-keyboard-open .rcd-app-bottom-nav {
    display: none;
}

html[data-app-context="native"] body.rcd-keyboard-open,
html[data-app-context="standalone"] body.rcd-keyboard-open {
    padding-bottom: 1rem;
}

@media (min-width: 768px) {
    html[data-app-context="standalone"] body,
    html[data-app-context="native"] body {
        --rcd-app-nav-height: 76px;
    }

    html[data-app-context="standalone"] main,
    html[data-app-context="native"] main {
        max-width: 980px;
        margin-right: auto;
        margin-left: auto;
    }

    .rcd-install-prompt {
        right: 1.5rem;
        bottom: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html[data-app-context="native"] *,
    html[data-app-context="standalone"] * {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    .rcd-app-topbar,
    .rcd-app-bottom-nav,
    .rcd-network-banner,
    .rcd-install-prompt {
        display: none !important;
    }

    html[data-app-context="native"] body,
    html[data-app-context="standalone"] body {
        padding: 0 !important;
        background: #fff !important;
    }
}
