/* Studio — an opt-in page-shell family for visually richer operational pages.
   It changes chrome and presentation only: markup, actions, access gates and the
   UI contract are identical to the standard page/page-table family. */

.page.container.studio-shell {
    width: 100%;
    max-width: 1500px;
    height: 100vh;
    grid-template-areas:
        "banner header"
        "menu main"
        "menu footer";
    grid-template-columns: 224px minmax(0, 1fr);
    grid-template-rows: 64px minmax(0, 1fr) auto;
    gap: 0;
    background: var(--page-background);
    box-shadow: var(--shadow-soft);
}

.studio-shell.page.container > div { border-radius: 0; }

.studio-shell > .banner {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0 22px;
    border: 0;
    background: var(--nav-gradient);
    color: var(--nav-font-color);
    box-shadow: none;
    font-size: 21px;
    letter-spacing: -0.02em;
}

.studio-shell > .banner .control.popup .target { color: var(--nav-font-color); }
.studio-shell > .banner .control.popup .target:hover {
    background: var(--nav-hover-background);
}
.studio-shell > .banner .banner-subtext {
    display: block;
    overflow: hidden;
    margin-left: 8px;
    padding: 2px 0 0 8px;
    border-left: 1px solid color-mix(in srgb, var(--nav-font-color) 30%, transparent);
    color: color-mix(in srgb, var(--nav-font-color) 78%, transparent);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.studio-shell > .header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    border: 0;
    border-bottom: var(--main-border);
    background: var(--surface-raised);
    box-shadow: var(--shadow-soft);
    z-index: 20;
}
.studio-shell > .header .search { margin-left: auto; }
.studio-shell > .header .user.control { margin-left: auto; }
.studio-shell > .header .search + .user.control { margin-left: 0; }
.studio-shell > .header .search input {
    width: min(360px, 30vw);
    transition: border-color var(--motion-normal) ease,
                box-shadow var(--motion-normal) ease,
                width var(--motion-normal) ease;
}
.studio-shell > .header .search input:focus { width: min(440px, 38vw); }

.studio-shell > .sidebar-menu {
    padding: 20px 14px;
    border: 0;
    background: var(--nav-gradient);
    color: var(--nav-font-color);
    box-shadow: none;
}
.studio-shell > .sidebar-menu a { color: var(--nav-font-color); }
.studio-shell > .sidebar-menu ul.nav-menu li {
    position: relative;
    margin: 3px 0;
    padding: 9px 12px;
    border-radius: calc(var(--page-grid-border-radius) + 2px);
    transition: background-color var(--motion-fast) var(--motion-ease-out),
                color var(--motion-fast) var(--motion-ease-out),
                transform var(--motion-fast) var(--motion-ease-spring);
}
.studio-shell > .sidebar-menu ul.nav-menu li:hover {
    background: var(--nav-hover-background);
    text-decoration: none;
    transform: translateX(2px);
}
.studio-shell > .sidebar-menu ul.nav-menu li.current {
    background: var(--nav-active-background);
    color: var(--nav-active-font-color);
    box-shadow: inset 3px 0 0 var(--nav-indicator), var(--shadow-soft);
}
.studio-shell > .sidebar-menu ul.nav-menu li.current > a { color: inherit; }
.studio-shell > .sidebar-menu ul.nav-menu ul.nav-children {
    margin-top: 6px;
    padding-left: 8px;
    color: color-mix(in srgb, var(--nav-font-color) 78%, transparent);
}

.studio-shell > .main {
    background-color: var(--page-background);
    background-image: var(--surface-page-accent);
    background-repeat: no-repeat;
}
.studio-shell > .main .area {
    box-sizing: border-box;
    padding: 24px;
    scrollbar-gutter: stable;
}
.studio-shell > .main .fillup,
.studio-shell > .main .fixed {
    margin: 0;
    padding: 22px 24px;
    border: var(--main-border);
    border-radius: calc(var(--page-grid-border-radius) + 3px);
    background: var(--surface-raised);
    box-shadow: var(--shadow-soft);
}
.studio-shell > .footer {
    padding: 8px 24px 10px;
    border: 0;
    background: var(--page-background);
    color: var(--banner-subtext);
    box-shadow: none;
    font-size: 12px;
    text-align: right;
}

.studio-shell .page-header {
    justify-content: space-between;
    padding-bottom: 14px;
    border-bottom: var(--main-border);
}
.studio-shell .page-header :is(h1, h2, h3) { letter-spacing: -0.025em; }

.studio-shell .button:not(.section),
.studio-shell .button.section button,
.studio-shell .target {
    min-height: 34px;
    box-sizing: border-box;
    box-shadow: var(--button-shadow);
    font-weight: 600;
    transition: background-color var(--motion-fast) var(--motion-ease-out),
                border-color var(--motion-fast) var(--motion-ease-out),
                box-shadow var(--motion-fast) var(--motion-ease-out),
                transform var(--motion-fast) var(--motion-ease-spring);
}
.studio-shell .button:not(.section),
.studio-shell .button.section button { background-image: var(--gradient-accent); }
.studio-shell .button:not(.section):hover,
.studio-shell .button.section button:hover,
.studio-shell .target:hover { transform: translateY(-1px); }
.studio-shell .button:not(.section):hover,
.studio-shell .button.section button:hover { background-image: var(--gradient-accent-hover); }
.studio-shell :is(button, .button, .target):active { transform: translateY(0); }

.studio-shell .window {
    margin-top: 6px;
    border-radius: calc(var(--page-grid-border-radius) + 3px);
    box-shadow: var(--shadow-float);
}

.studio-shell :is(.box, .kpi, .dash-card, .crud-card, .dash-detail-card) {
    background: var(--surface-card);
    border-color: color-mix(in srgb, var(--main-font-color) 14%, transparent);
    border-radius: calc(var(--page-grid-border-radius) + 3px);
    box-shadow: var(--shadow-soft);
}

/* Presentation-grade record forms. Titled panels make the information
   architecture visible in a screenshot; the accent/tone is entirely derived
   from theme tokens, so a branded theme changes the mood without new markup. */
.studio-shell .record-header {
    margin-bottom: 22px;
    padding: 4px 2px 18px;
}
.studio-shell .record-header-copy h3 {
    font-size: clamp(22px, 2.4vw, 30px);
    line-height: 1.08;
}
.studio-shell .record-header-copy .record-ident {
    display: block;
    margin-top: 5px;
    color: var(--banner-subtext);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
}
.studio-shell .record-lede { font-size: 13px; }
.studio-shell .status-pill { box-shadow: var(--shadow-soft); }

.studio-shell .form-panel {
    position: relative;
    margin-bottom: 18px;
    padding: 0;
    border-color: color-mix(in srgb, var(--main-font-color) 12%, transparent);
    transition: border-color var(--motion-normal) var(--motion-ease-out),
                box-shadow var(--motion-normal) var(--motion-ease-out),
                transform var(--motion-normal) var(--motion-ease-out);
}
.studio-shell .form-panel::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent-background);
    content: "";
}
.studio-shell .form-panel--security::before { background: var(--status-warning-background); }
.studio-shell .form-panel--record::before { background: var(--banner-subtext); }
.studio-shell .form-panel:focus-within {
    border-color: var(--card-border-hover);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}
.studio-shell .form-panel-header {
    margin: 0;
    padding: 17px 20px 14px 24px;
    background: linear-gradient(135deg, var(--surface-subtle), var(--surface-card));
}
.studio-shell .form-panel-header h4 {
    font-size: 16px;
    letter-spacing: -0.01em;
}
.studio-shell .form-panel-body { padding: 19px 20px 20px 24px; }
.studio-shell .form-panel-body .field :is(input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], select, textarea) {
    max-width: none;
}
.studio-shell .form-panel-body .field { margin-bottom: 15px; }
.studio-shell .form-panel-body .field:last-child { margin-bottom: 0; }
.studio-shell .form-panel-body .field > label,
.studio-shell .choice-field > legend {
    color: var(--main-title-font-color);
    font-size: 12px;
    letter-spacing: .025em;
    text-transform: uppercase;
}
.studio-shell .form-panel-body :is(input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], select, textarea) {
    min-height: 40px;
    border: var(--input-border);
    border-radius: calc(var(--page-grid-border-radius) - 1px);
    transition: border-color var(--motion-fast) var(--motion-ease-out),
                box-shadow var(--motion-fast) var(--motion-ease-out),
                background-color var(--motion-fast) var(--motion-ease-out);
}
.studio-shell .form-panel-body :is(input, select, textarea):focus {
    outline: none;
    border-color: var(--focus-ring-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring-color) 18%, transparent);
}
.studio-shell .form-panel .field.display .value {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 2px 9px;
    border-radius: calc(var(--page-grid-border-radius) - 2px);
    background: var(--surface-subtle);
    font-weight: 600;
}

.studio-shell .choice-grid { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.studio-shell .choice-card {
    overflow: hidden;
    border-color: color-mix(in srgb, var(--main-font-color) 15%, transparent);
    background: var(--surface-card);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--main-font-color) 5%, transparent);
    transition: border-color var(--motion-fast) var(--motion-ease-out),
                background var(--motion-fast) var(--motion-ease-out),
                box-shadow var(--motion-fast) var(--motion-ease-out),
                transform var(--motion-fast) var(--motion-ease-spring);
}
.studio-shell .choice-card:hover {
    border-color: var(--card-border-hover);
    box-shadow: var(--shadow-soft);
    transform: translateY(-1px);
}
.studio-shell .choice-card:has(input:checked) {
    border-color: var(--accent-background);
    background: linear-gradient(145deg, var(--accent-soft-background), var(--surface-card));
    box-shadow: inset 3px 0 0 var(--accent-background), var(--shadow-soft);
}
.studio-shell .choice-card:has(input:checked) strong { color: var(--link-font-color); }

.studio-shell .crud-form > .edit-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    padding: 13px 16px;
    border: var(--main-border);
    border-radius: calc(var(--page-grid-border-radius) + 2px);
    background: var(--surface-raised);
    box-shadow: var(--shadow-soft);
}
.studio-shell .button--secondary { background-image: none; }
.studio-shell .button--danger {
    margin-left: auto;
    border-color: var(--status-failed-background);
    background: var(--status-failed-background);
    background-image: none;
    color: var(--status-failed-font-color);
}
.studio-shell :is(.kpi, .dash-card, .crud-card) {
    position: relative;
    overflow: hidden;
    transition: background var(--motion-normal) var(--motion-ease-out),
                border-color var(--motion-normal) var(--motion-ease-out),
                box-shadow var(--motion-normal) var(--motion-ease-out),
                transform var(--motion-normal) var(--motion-ease-spring);
}
.studio-shell :is(.kpi, .dash-card, .crud-card)::after {
    position: absolute;
    inset: 0;
    background: var(--card-highlight);
    content: "";
    pointer-events: none;
    transform: translateX(-115%);
    transition: transform var(--motion-slow) var(--motion-ease-out);
}
.studio-shell :is(a.kpi, .dash-card, .crud-card):hover {
    background: var(--surface-card-hover);
    border-color: var(--card-border-hover);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}
.studio-shell :is(a.kpi, .dash-card, .crud-card):hover::after { transform: translateX(115%); }
.studio-shell .kpi {
    position: relative;
    overflow: hidden;
}
.studio-shell .kpi::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent-background);
    content: "";
}
.studio-shell .kpi-num { letter-spacing: -0.04em; }

/* A short, ordered reveal makes a dashboard's information hierarchy legible as
   it arrives. The shared reduced-motion rule collapses this animation. */
@keyframes studio-reveal {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.studio-shell .dashboard > .dash-field {
    animation: studio-reveal var(--motion-slow) var(--motion-ease-out) both;
}
.studio-shell .dashboard > .dash-field:nth-child(2) { animation-delay: 35ms; }
.studio-shell .dashboard > .dash-field:nth-child(3) { animation-delay: 70ms; }
.studio-shell .dashboard > .dash-field:nth-child(4) { animation-delay: 105ms; }
.studio-shell .dashboard > .dash-field:nth-child(n+5) { animation-delay: 140ms; }

.studio-shell :is(.banner.success, .banner.error, .banner.warn, .banner.info) {
    padding: 11px 14px;
    border-radius: var(--page-grid-border-radius);
}
.studio-shell :is(.empty-state, .spreadsheet tr.crud-empty td, .crud-cards > .crud-empty) {
    padding: 32px 18px;
    background: var(--surface-subtle);
    font-style: normal;
}

.studio-shell .table {
    overflow: hidden;
    border: var(--main-border);
    border-radius: calc(var(--page-grid-border-radius) + 3px);
    box-shadow: var(--shadow-soft);
}
.studio-shell .table > .header,
.studio-shell .table > .footer {
    padding: 12px 14px;
    background: var(--surface-raised);
}
.studio-shell .spreadsheet thead th {
    height: 42px;
    border-width: 0 0 1px;
    font-size: 12px;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}
.studio-shell .spreadsheet tbody td {
    height: 40px;
    border-width: 0 0 1px;
}

@media (max-width: 900px) {
    .page.container.studio-shell {
        min-height: 100vh;
        height: auto;
        overflow: visible;
        grid-template-areas:
            "banner"
            "header"
            "menu"
            "main"
            "footer";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    }
    .studio-shell > .banner { min-height: 56px; }
    .studio-shell > .header { flex-wrap: wrap; padding: 8px 16px; }
    .studio-shell > .sidebar-menu { padding: 7px 12px; overflow-x: auto; }
    .studio-shell > .sidebar-menu ul.nav-menu {
        display: flex;
        align-items: center;
        gap: 4px;
        width: max-content;
    }
    .studio-shell > .sidebar-menu ul.nav-menu > li { margin: 0; white-space: nowrap; }
    .studio-shell > .sidebar-menu ul.nav-menu li:hover { transform: none; }
    .studio-shell > .sidebar-menu ul.nav-menu ul.nav-children { display: none; }
    .studio-shell > .main { min-height: 55vh; overflow: visible; }
    .studio-shell > .main .area { overflow: visible; padding: 16px; }
    .studio-shell > .footer { padding-right: 16px; }
}

@media (max-width: 640px) {
    .studio-shell > .header .search { flex-basis: 100%; min-width: 0; width: 100%; order: 2; }
    .studio-shell > .header .search input,
    .studio-shell > .header .search input:focus { box-sizing: border-box; max-width: 100%; width: 100%; }
    .studio-shell > .main .area { padding: 10px; }
    .studio-shell > .main .fillup,
    .studio-shell > .main .fixed { padding: 16px; }
    .studio-shell .button.section { justify-content: flex-start; }
    .studio-shell .table > .header { display: flex; flex-wrap: wrap; }
    .studio-shell .record-header-meta { width: 100%; }
    .studio-shell .choice-grid { grid-template-columns: 1fr; }
}
