/*
 * Page boot skeleton (issue #4910).
 *
 * Linked in the head of every dashboard shell page, after style.css (and after
 * design-tokens.css, so every token resolves from the first paint, light and
 * dark: theme.js has already set data-theme). Paints the page on --bg instead
 * of the legacy slate of style.css's global body rule (which stays for the
 * login, landing and error pages) and draws the shell skeleton until the shell
 * is injected (stage 1) and the content skeleton until the page renders
 * (stage 2, same markup, js/util/boot-shell.js).
 *
 * Tokens only. This file is NOT a shell stylesheet: main_base.html never links
 * it (#3534), it stays in the head for the whole session.
 */

body.si-dashboard-page {
    background: var(--bg);
    color: var(--ink);
}

/* ── Stage 1: shell outline, same sizes as dashboard-shell.css ──────────── */
.si-boot {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    background: var(--bg);
}

html[data-si-sidebar="collapsed"] .si-boot {
    grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}

/* The shell shows its own #wrapper (display none until a controller shows it);
 * the skeleton follows it in the DOM and steps aside at that moment. */
#wrapper:not([style*="display: none"]):not([style*="display:none"]) ~ .si-boot {
    display: none;
}

.si-boot-sb {
    background: var(--sidebar-bg);
    padding: 0 10px;
    height: 100vh;
    overflow: hidden;
}

.si-boot-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 10px 14px;
}

.si-boot-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--blue);
    flex-shrink: 0;
}

.si-boot-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 34px;
    padding: 0 12px;
}

.si-boot-icon {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    background: var(--sidebar-ink);
    opacity: 0.2;
    flex-shrink: 0;
}

.si-boot-text {
    display: block;
    height: 8px;
    width: 110px;
    border-radius: 4px;
    background: var(--sidebar-ink);
    opacity: 0.2;
}

.si-boot-item:nth-child(odd) .si-boot-text { width: 96px; }
.si-boot-item:nth-child(3n) .si-boot-text { width: 124px; }

.si-boot-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.si-boot-top {
    height: 54px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.si-boot-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.si-boot-search {
    width: 380px;
    max-width: 50%;
    height: 32px;
    border-radius: 10px;
    background: var(--surface-3);
}

.si-boot-page {
    flex: 1;
    padding: var(--s-6) 28px var(--s-10);
    background: var(--bg);
}

@media (min-width: 1600px) { .si-boot-page { zoom: 1.10; } }
@media (min-width: 2000px) { .si-boot-page { zoom: 1.18; } }
@media (min-width: 2500px) { .si-boot-page { zoom: 1.25; } }

/* Rail: the stored collapsed choice (desktop) and every width up to 900px. */
@media (min-width: 641px) {
    html[data-si-sidebar="collapsed"] .si-boot-text { display: none; }
    html[data-si-sidebar="collapsed"] .si-boot-brand,
    html[data-si-sidebar="collapsed"] .si-boot-item { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
}

@media (max-width: 900px) {
    .si-boot,
    html[data-si-sidebar="collapsed"] .si-boot { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
    .si-boot-text { display: none; }
    .si-boot-brand,
    .si-boot-item { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
    .si-boot-page { padding: var(--s-5); }
}

/* No sidebar on phones (the shell's sidebar is an off-canvas drawer there). */
@media (max-width: 640px) {
    .si-boot,
    html[data-si-sidebar="collapsed"] .si-boot { grid-template-columns: 1fr; }
    .si-boot-sb { display: none; }
}

/* ── Content skeleton (stage 1 and stage 2) ─────────────────────────────── */
.si-boot-content { position: relative; }

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

.si-boot-block {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: si-boot-shimmer 1.2s linear infinite;
}

.si-boot-line { height: 9px; width: 85%; margin-top: 10px; }
.si-boot-line.is-short { width: 60%; margin-top: 8px; }
.si-boot-line.is-head { height: 12px; width: 40%; margin-top: 0; }
.si-boot-line.is-label { height: 9px; width: 120px; margin-top: 0; }
.si-boot-line.is-title { height: 18px; width: 220px; max-width: 70%; margin-top: 8px; border-radius: 8px; }

.si-boot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    margin-top: 14px;
    overflow: hidden;
}

@keyframes si-boot-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .si-boot-block { animation: none; }
}
