/*
 * Glass UI (docs/design_glass_ui.md).
 * Every rule is scoped under body.glass-ui, which the layouts add only when
 * glass_ui() is true, so the old blue theme is untouched when it's off.
 * Screens are moved over one at a time; so far: login, OTP and the app_full shell.
 */

/* ---------- auth screens (login, OTP): L1–L3 ---------- */

body.glass-ui.glass-auth {
    min-height: 100vh;
    background-color: #01395e;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.glass-ui .glass-auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.glass-ui .glass-card {
    width: 100%;
    max-width: 340px;
    padding: 1.75rem 1.5rem 1.5rem;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 20, 45, 0.45);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
}

/* no backdrop-filter support: a solid navy card instead of see-through */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass-ui .glass-card {
        background: rgba(1, 57, 94, 0.92);
    }
}

.glass-ui .glass-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    text-align: center;
}

.glass-ui .glass-brand img {
    max-width: 140px;
    height: auto;
}

.glass-ui .glass-brand-name {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.glass-ui .glass-card .login-box-msg {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
}

.glass-ui .glass-card .kas-label {
    color: #fff;
    font-size: 0.875rem;
}

.glass-ui .glass-card input[type="text"],
.glass-ui .glass-card input[type="password"] {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.5rem;
}

.glass-ui .glass-card input[type="text"]:focus,
.glass-ui .glass-card input[type="password"]:focus {
    background: #fff;
    border-color: #93c5fd;
    outline: none;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.45);
}

.glass-ui .glass-card .error-msg {
    background: transparent;
    color: #fecaca;
    font-size: 0.8rem;
}

.glass-ui .glass-btn {
    width: 100%;
    padding: 0.55rem 1rem;
    color: #fff;
    font-weight: 600;
    background: #01395e;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.5rem;
}

.glass-ui .glass-btn:hover,
.glass-ui .glass-btn:focus {
    background: #024b7a;
}

.glass-ui .glass-msg {
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
}

.glass-ui .glass-msg-success {
    color: #dcfce7;
    background: rgba(22, 163, 74, 0.35);
    border: 1px solid rgba(134, 239, 172, 0.5);
}

.glass-ui .glass-msg-error {
    color: #fee2e2;
    background: rgba(220, 38, 38, 0.35);
    border: 1px solid rgba(252, 165, 165, 0.5);
}

/* ---------- app_full shell: D1–D5 (shell-* hooks in layouts/app_full) ---------- */

/* D1: brand navy gradient behind the whole page */
body.glass-ui:not(.glass-auth) {
    background-color: #01395e;
    background-image: linear-gradient(135deg, #01395e 0%, #0b4f8a 45%, #1e40af 100%);
    background-attachment: fixed;
}

/* top bar */
.glass-ui .shell-topbar {
    position: relative;
    z-index: 40;
    background: rgba(1, 30, 60, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 2px 16px rgba(0, 10, 30, 0.35);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* profile dropdown under the top bar */
.glass-ui .shell-dropdown {
    background: rgba(1, 30, 60, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 0.5rem;
    overflow: hidden;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* D5: breadcrumb strip, thin glass */
.glass-ui .shell-crumbs {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    background: rgba(255, 255, 255, 0.10);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.glass-ui .shell-crumbs a,
.glass-ui .shell-crumbs .active-bread-crumb {
    color: #fff;
}

/* D4: sidebar menu, dark navy glass.
   Height follows the menu (not the screen), so the background reaches the
   last item of a long open menu; the bottom padding keeps it clear of the
   fixed footer. */
.glass-ui .shell-sidebar {
    align-self: flex-start;
    height: auto;
    min-height: 100%;
    padding-bottom: 3rem;
    background: rgba(1, 25, 50, 0.55);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* open: as wide as the longest item (at least the old 235px), one line per item */
.glass-ui .shell-sidebar.sidebar-open {
    width: max-content;
    min-width: 235px;
}

.glass-ui .shell-sidebar.sidebar-open li,
.glass-ui .shell-sidebar.sidebar-open a,
.glass-ui .shell-sidebar.sidebar-open button {
    white-space: nowrap;
}

.glass-ui .shell-sidebar li {
    border-radius: 0.375rem;
}

.glass-ui .shell-sidebar a,
.glass-ui .shell-sidebar button {
    color: #fff;
    background: transparent;
    border: 0;
}

.glass-ui .shell-sidebar a.nav-link {
    display: block;
    padding: 0.2rem 0.4rem;
    border-radius: 0.375rem;
}

.glass-ui .shell-sidebar a.nav-link:hover,
.glass-ui .shell-sidebar li:hover > a.nav-link {
    background: rgba(255, 255, 255, 0.12);
}

/* the open menu group */
.glass-ui .shell-sidebar li:has(> ul.menu-open) {
    background: rgba(255, 255, 255, 0.10);
    box-shadow: inset 3px 0 0 #93c5fd;
}

/* D1: light frosted sheet behind the page, so screens not moved over yet
   stay readable; only when the page has content (the home page is empty, D2) */
.glass-ui .shell-content:has(> *) {
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin-left: 1rem;
    margin-right: 1rem;
    color: #111827;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 20, 45, 0.30);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* footer */
.glass-ui .shell-footer {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(1, 30, 60, 0.55);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.glass-ui .shell-footer a {
    color: #fff;
}

/* no backdrop-filter support: solid navy shell instead of see-through */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass-ui .shell-topbar,
    .glass-ui .shell-sidebar,
    .glass-ui .shell-footer,
    .glass-ui .shell-dropdown {
        background: rgba(1, 45, 80, 0.95);
    }
    .glass-ui .shell-content:has(> *) {
        background: #fff;
    }
}

/* ---------- top-bar switch (app_full), shown only with GLASS_UI on ---------- */

.glass-ui-toggle {
    opacity: 0.75;
}

.glass-ui-toggle:hover,
.glass-ui .glass-ui-toggle {
    opacity: 1;
}

/* ---------- content screens moved over (first: Yards, docs/design_yards.md Y10) ----------
   A page that is moved over marks its root with .glass-page. Its sheet goes
   clear so the navy gradient shows, and its cards (.glass-panel) are frosted.
   Grids and tables inside stay solid white (G2). */

.glass-ui .shell-content:has(.glass-page) {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.glass-ui .glass-page .glass-panel {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 20, 45, 0.28);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.glass-ui .glass-page .glass-panel input[type=text],
.glass-ui .glass-page .glass-panel select,
.glass-ui .glass-page .glass-panel textarea,
.glass-ui .glass-page .glass-panel .select2-container .select2-selection {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(1, 57, 94, 0.25);
}

.glass-ui .glass-page .glass-chip {
    color: #fff;
    background: rgba(1, 45, 80, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

/* text sitting straight on the gradient (outside the cards) */
.glass-ui .glass-page > form > .yard-actions,
.glass-ui .glass-page > .glass-on-gradient {
    color: #fff;
}

/* grids stay solid and readable */
.glass-ui .glass-page table {
    background: #fff;
}

.glass-ui .glass-page .yard-grid-box,
.glass-ui .glass-page .dataTables_wrapper {
    background: #fff;
    border-radius: 0.5rem;
    padding: 4px;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass-ui .glass-page .glass-panel {
        background: #fff;
    }
    .glass-ui .glass-page .glass-chip {
        background: rgba(1, 45, 80, 0.95);
    }
}
