/* Shell.css - VERSIONE 4 - 4 novembre 2026 (la cornice riempie la finestra fino in fondo; il footer sta in fondo alla pagina o dopo i dati) */
/* =====================================================================================================
   Shell.css - application shell, menu and motion of DeviceTrack.

   Follows the layout and the feel of the MDM control panel prototype (mdm_control_panel_prototype.html),
   in DeviceTrack's own colours. Loaded by Site.Master AFTER Site.css, so it overrides it; it replaces
   the block of rules that used to sit inline in Site.Master.

   What is here:   1. tokens  2. shell  3. top bar  4. menu  5. main area  6. motion  7. toasts + busy bar
   Every colour, size and speed worth tuning is a variable in section 1.

   To go back to the old "the whole page scrolls" behaviour, change in section 2:
       .unified-app { height: 100vh; }   ->   .unified-app { min-height: 100vh; }
   ===================================================================================================== */


/* ---------- 1. tokens ---------------------------------------------------------------------------- */
:root {
    /* DeviceTrack palette - the only place the brand colour is decided for the shell */
    --dt-sidebar-bg: #a6452f;
    --dt-sidebar-bg-dark: #7f3423;
    --dt-sidebar-ink: #f7e8e2;
    --dt-sidebar-ink-muted: #d9a692;
    --dt-nav-hover-bg: rgba(255, 255, 255, .10);
    --dt-nav-active-bg: #c15c3f;

    /* neutrals, as in the prototype */
    --dt-ink: #1b222c;
    --dt-ink-2: #48535f;
    --dt-muted: #7b8794;
    --dt-line: #e2e8ef;
    --dt-line-2: #eef2f6;

    /* toast dots */
    --dt-ok: #4fd6a0;
    --dt-err: #ff8a8a;
    --dt-info: #6fb0ee;

    /* geometry */
    --dt-nav-width: 248px;
    --dt-topbar-height: 60px;
    --dt-radius: 12px;
    --dt-radius-s: 8px;
    --dt-shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 16px rgba(16, 32, 56, .06);

    /* motion */
    --dt-ease: cubic-bezier(.2, .7, .3, 1);
    --dt-fast: .12s;
    --dt-med: .18s;

    /* was defined in the old inline block; kept in case something still reads it */
    --unified-input-border-radius: 3px;
}


/* ---------- 2. shell ----------------------------------------------------------------------------- */
html, body { height: 100%; }
body { -webkit-font-smoothing: antialiased; }

/* Fixed to the window: the top bar and the menu stay put and only the main area scrolls
   (minmax(0, ...) is what lets the grid cells shrink below their content, so they can scroll). */
.unified-app {
    display: grid;
    grid-template-columns: var(--dt-nav-width) minmax(0, 1fr);
    grid-template-rows: var(--dt-topbar-height) minmax(0, 1fr);
    grid-template-areas: "brand top" "nav main";
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.unified-brand {
    grid-area: brand;
    background: var(--dt-sidebar-bg-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    padding: 0 18px;
    min-width: 0;
    overflow: hidden;
}
.unified-brand a { display: flex; align-items: center; gap: 10px; max-width: 100%; color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .2px; text-decoration: none; white-space: nowrap; }
.unified-brand img { max-height: 30px; }

/* The Menu control writes two "Skip Navigation Links" anchors - one before the menu, one after it - as DIRECT children of the app. They have no grid area, so the grid
   gave them a third row of its own: a strip of about 16px under the menu and the main area (the main area, and the menu with it, ended 16px above the bottom of the window,
   and the page background showed there). They are out of the flow now, the usual way of hiding something visually without hiding it from screen readers. */
.unified-app > a {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* What a page writes after the site name - its title, with the chevron icon: a second line under the name, set in a little.
   (It used to be squeezed beside the name, in whatever width was left, and wrapped onto two lines.) */
.unified-brand > :not(a) {
    box-sizing: border-box;
    max-width: 100%;
    padding-left: 14px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.25;
    color: rgba(255, 255, 255, .82);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unified-brand > .mdi::before { font-size: 16px; margin-right: 2px; vertical-align: middle; }


/* ---------- 3. top bar --------------------------------------------------------------------------- */
.unified-topbar {
    grid-area: top;
    background: #fff;
    border-bottom: 1px solid var(--dt-line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    min-width: 0;
}
.unified-topbar .spacer { flex: 1; }

.unified-topbar .app-switcher,
.unified-topbar .loginDisplay { border-radius: 10px; }
.app-switcher a { transition: background-color var(--dt-fast) ease, color var(--dt-fast) ease; }

/* The user menu ("Welcome admin"). Site.css opened it by growing the box itself on hover (height: auto); the bar centres its
   items, so the box grew UP as well as down and "Welcome admin" ended up cut off at the top of the window.
   Now the box keeps its size and the entries hang under it as a panel, always opening downwards.
   z-index: above the map and the tables, below the popups (those are far higher). */
.unified-topbar .loginDisplay { position: relative; z-index: 2000; overflow: visible; height: 32px; }
.unified-topbar .loginDisplay:hover,
.unified-topbar .loginDisplay:focus,
.unified-topbar .loginDisplay:focus-within { height: 32px; }

.unified-topbar .loginDisplay > ul {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 100%;
    margin: 8px 0 0;
    padding: 4px 0;
    background: #fff;
    border: 1px solid var(--dt-line);
    border-radius: 10px;
    box-shadow: var(--dt-shadow);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;           /* closed: invisible, and the empty space under the box does not catch the mouse */
    transform: translateY(-4px);   /* (not visibility:hidden: the entries stay reachable with the Tab key) */
    transition: opacity var(--dt-fast) ease, transform var(--dt-fast) ease;
}
/* the gap between the box and the panel still counts as "over the menu", so it does not close while the pointer crosses it */
.unified-topbar .loginDisplay > ul::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.unified-topbar .loginDisplay:hover > ul,
.unified-topbar .loginDisplay:focus > ul,
.unified-topbar .loginDisplay:focus-within > ul {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}
.unified-topbar .loginDisplay > ul li a { margin: 0 4px; border-radius: 7px; }
.unified-topbar .loginDisplay > ul li a:hover { background-color: var(--dt-line-2); }


/* ---------- 4. menu ------------------------------------------------------------------------------
   Written to hold whatever the Menu control renders (<ul><li><a>...</a><ul>...</ul></li></ul>), without
   relying on class names: an entry that has a list under it is a GROUP LABEL (small capitals, as in the
   prototype); everything else is a menu item. The icon is the "mdi" span the item template writes.     */
.unified-nav {
    grid-area: nav;
    background: linear-gradient(to right, var(--dt-sidebar-bg-dark) 0%, var(--dt-sidebar-bg) 100%);
    color: var(--dt-sidebar-ink);
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
.unified-nav, .unified-nav ul { list-style: none; margin: 0; padding: 0; }
.unified-nav li { list-style: none; margin: 0 2.5px 2.5px 2.5px; padding: 0; }
ul.level1.static { width: 99% !important; margin-top: 20px; }

.unified-nav li > a,
.unified-nav li > span:not(.mdi) {
    display: flex;
    align-items: center;
    gap: 11px;
    height: 42px;
    padding: 0 12px;
    border-radius: 9px;
    color: var(--dt-sidebar-ink);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dt-fast) ease, color var(--dt-fast) ease;
}
.unified-nav li > span:not(.mdi) { cursor: default; }
.unified-nav li > a:hover { background: var(--dt-nav-hover-bg); color: #fff; }

/* the page you are on */
.unified-nav li > a.active,
.unified-nav li > a.selected { background: var(--dt-nav-active-bg); color: #fff; font-weight: 600; }

.unified-nav .mdi { flex: 0 0 auto; width: 18px; margin: 0; font-size: 17px; text-align: center; opacity: .85; transition: opacity var(--dt-fast) ease; }
.unified-nav a:hover .mdi,
.unified-nav a.active .mdi,
.unified-nav a.selected .mdi { opacity: 1; }

/* group label: an entry with other entries under it. Recognised two ways, so it works whichever shape the Menu control
   writes: by :has() for a nested list, and by the dt-group class that the small script right after the menu adds.
   It is only a heading: not clickable (the script also takes its link away, so the keyboard cannot reach it either) and
   it does not react to the mouse - no colour change, no pointer. */
.unified-nav li:has(> ul) > a,
.unified-nav li:has(> ul) > span:not(.mdi),
.unified-nav .dt-group {
    height: auto;
    margin: 16px 0 6px;
    padding: 0 12px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    color: var(--dt-sidebar-ink-muted);
    background: none;
    cursor: default;
    pointer-events: none;
    user-select: none;
}
.unified-nav li:has(> ul) > a:hover,
.unified-nav li:has(> ul) > span:not(.mdi):hover,
.unified-nav .dt-group:hover { background: none; color: var(--dt-sidebar-ink-muted); }
/* a label carries no icon - only ITS OWN icon: the items under it keep theirs */
.unified-nav li:has(> ul) > a .mdi,
.unified-nav li:has(> ul) > span:not(.mdi) .mdi,
.unified-nav .dt-group .mdi { display: none; }
.unified-nav li:first-child:has(> ul) > a,
.unified-nav li:first-child:has(> ul) > span:not(.mdi),
.unified-nav li:first-child > .dt-group { margin-top: 4px; }

/* an entry with no page behind it (the Menu control writes it as a postback link) is a plain label: nothing to click */
.unified-nav a[href^="javascript:"] { pointer-events: none; cursor: default; }

/* items under a group label sit at the same level, as in the prototype - no indent */
.unified-nav ul ul { margin: 0; padding: 0; }


/* ---------- 5. main area ------------------------------------------------------------------------- */
.unified-main {
    grid-area: main;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 22px 26px;
    scrollbar-width: thin;
    scrollbar-color: #cdd6df transparent;
    /* A column: the content, then the footer. The content takes whatever is left (below), so the footer is at the bottom of the window when there is little to show. */
    display: flex;
    flex-direction: column;
}

/* What the page writes (Site.Master wraps it in this). It grows to fill the area, which pushes the footer to the bottom; when there is more content than room, the area
   scrolls and the footer follows the content. flex-shrink 0: the content is never squeezed to fit - the area scrolls instead. */
.unified-content {
    flex: 1 0 auto;
    min-width: 0;
}

/* The footer used to be pinned to the bottom of the window (position: absolute in Site.css). The main
   area scrolls now, so it goes after the content - and, being after a content that grows to fill the area, at the bottom of the window when the content is short. */
.unified-main .footer {
    flex: 0 0 auto;
    position: static;
    height: auto;
    line-height: 1.6;
    margin: 28px -26px -22px;
    padding: 10px 26px;
    background: transparent;
    border-top: 1px solid var(--dt-line);
    color: var(--dt-muted);
    display: flow-root;
}

@media (max-width: 760px) {
    .unified-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--dt-topbar-height) auto minmax(0, 1fr); grid-template-areas: "brand" "top" "main"; }
    .unified-nav { display: none; }
    .unified-main { padding: 16px; }
    .unified-main .footer { margin: 24px -16px -16px; padding: 10px 16px; }
}


/* ---------- 6. motion ---------------------------------------------------------------------------- */

/* hover and focus: smooth, never "all" (so layout never animates) */
a, button, .button, input, select, textarea {
    transition: background-color var(--dt-fast) ease, border-color var(--dt-fast) ease, color var(--dt-fast) ease,
                box-shadow var(--dt-fast) ease, opacity var(--dt-fast) ease;
}
table tr { transition: background-color var(--dt-fast) ease; }

input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="search"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--link-color);
    box-shadow: 0 0 0 3px rgba(166, 69, 47, .15);
}

@keyframes dt-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes dt-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes dt-pop-in   { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes dt-slide-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes dt-busy     { from { left: -40%; } to { left: 100%; } }

/* A popup is re-created by every partial update (a checkbox, a dropdown...), so it must not "pop" each time:
   the script in Site.Master adds .dt-opening only when the popup appears where there was none. */
.modal-background.dt-opening { animation: dt-fade-in var(--dt-med) ease both; }
.modal-popup.dt-opening { animation: dt-pop-in var(--dt-med) var(--dt-ease) both; }

/* Moving from page to page: a short cross-fade of the whole page. The menu and the top bar are identical on both pages, so
   they look still and only what changes appears to fade (the main area, the highlighted menu entry).
   A browser feature (Chrome, Edge): where it is not available, pages simply load as before.
   No element is given a view-transition-name on purpose: that turns it into a containing block for its position: fixed
   descendants, which would pull the popups (fixed, inside the main area) out of the window. */
@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
}
::view-transition-old(root) { animation: dt-fade-out .12s ease both; }
::view-transition-new(root) { animation: dt-fade-in .2s var(--dt-ease) both; }

/* people who ask their system for less motion get none */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ---------- 7. toasts and busy bar ---------------------------------------------------------------- */
#dt-toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2000000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.dt-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 380px;
    padding: 13px 16px;
    border-radius: 11px;
    background: #2b2220;
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.4;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
    cursor: pointer;
    animation: dt-slide-in var(--dt-med) var(--dt-ease) both;
    transition: opacity .25s ease, transform .25s ease;
}
.dt-toast.out { opacity: 0; transform: translateY(8px); }
.dt-toast .dt-ti { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--dt-info); }
.dt-toast.ok .dt-ti { background: var(--dt-ok); }
.dt-toast.err .dt-ti { background: var(--dt-err); }

#dt-busy {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2147483000;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s ease;
}
#dt-busy::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: var(--dt-nav-active-bg);
    border-radius: 3px;
    animation: dt-busy 1s ease-in-out infinite;
}
#dt-busy.on { opacity: 1; }
