/* ==========================================================================
   FLUXO DESIGN SYSTEM — BASE.CSS
   Reset strutturale, tipografia Apple (-apple-system / SF Pro / Inter),
   antialiased rendering, griglia applicativa 100dvh e sfondo ambientale.
   ========================================================================== */

/* === RESET & BOX MODEL === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    view-transition-name: root;
}

/* Blocca ogni transizione/animazione fino al completamento del primo paint (zero flash al reload) */
html.is-preload *,
html.is-preload *::before,
html.is-preload *::after {
    transition: none !important;
    animation-duration: 0s !important;
}

html,
body {
    height: 100%;
    overflow: hidden;
    background-color: var(--fx-bg-app);
    color: var(--fx-text-primary);
    font-family: var(--fx-font-body);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* === TIPOGRAFIA APPLE & TABULAR NUMBERS === */
h1,
h2,
h3,
h4,
.fx-heading {
    font-family: var(--fx-font-heading);
    font-weight: 600;
    letter-spacing: -0.028em;
    color: var(--fx-text-primary);
}

.fx-num,
.fx-money,
table td,
table th {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "cv05" 1;
}

.fx-mono {
    font-family: var(--fx-font-mono);
    font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

a {
    color: var(--fx-accent-primary);
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--fx-accent-ring);
    outline-offset: 2px;
}

/* === SHELL APPLICATIVA (GRID VIEWPORT LOCKED) === */
.fx-app-shell {
    display: grid;
    grid-template-columns: var(--fx-sidebar-width) minmax(0, 1fr);
    grid-template-rows: 100dvh;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--fx-bg-app);
    background-image:
        radial-gradient(65% 55% at 88% 0%, var(--fx-ambient-glow-1) 0%, transparent 100%),
        radial-gradient(50% 45% at 15% 100%, var(--fx-ambient-glow-2) 0%, transparent 100%);
    transition: grid-template-columns 320ms var(--fx-ease-out-quint);
}

.fx-app-shell.is-sidebar-collapsed,
html[data-sidebar-collapsed="true"] .fx-app-shell {
    grid-template-columns: var(--fx-sidebar-collapsed-width) minmax(0, 1fr);
}

@media (max-width: 1024px) {
    .fx-app-shell,
    .fx-app-shell.is-sidebar-collapsed,
    html[data-sidebar-collapsed="true"] .fx-app-shell {
        grid-template-columns: minmax(0, 1fr);
    }
}

.fx-workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100dvh;
    overflow: hidden;
    background-color: transparent;
}

.fx-main-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fx-main-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--fx-space-6) var(--fx-space-8) var(--fx-space-10);
    scroll-behavior: smooth;
}

@media (max-width: 768px) {
    .fx-main-scroll {
        padding: var(--fx-space-4) var(--fx-space-4) var(--fx-space-8);
    }
}

.fx-view-container {
    width: 100%;
    max-width: var(--fx-content-max-width);
    margin: 0 auto;
}

/* === SCROLLBAR SOTTILI APPLE === */
.fx-main-scroll::-webkit-scrollbar,
.fx-scroll-thin::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

.fx-main-scroll::-webkit-scrollbar-track,
.fx-scroll-thin::-webkit-scrollbar-track {
    background: transparent;
}

.fx-main-scroll::-webkit-scrollbar-thumb,
.fx-scroll-thin::-webkit-scrollbar-thumb {
    background-color: var(--fx-border-strong);
    border-radius: var(--fx-radius-full);
    border: 2px solid transparent;
    background-clip: content-box;
}

/* === UTILITY ACCESSIBILITÀ === */
[hidden] {
    display: none !important;
}

.fx-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
