@import url('/assets/css/fonts.css');
@import url('/assets/css/theme.css');
@import url('/assets/css/components.css');

* { box-sizing: border-box; }

body.cms-login-page {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--ui-text, #fff);
    background: var(--ui-bg, #0a0a0a);
    font-family: var(--font-ui);
}

.login-shell {
    width: min(520px, 100%);
    padding: clamp(28px, 6vw, 52px);
    border-radius: 30px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    box-shadow: 0 24px 80px rgba(0,0,0,.46);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.login-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    margin-bottom: 26px;
    background: linear-gradient(135deg, rgba(108,99,255,.95), rgba(0,212,255,.75));
    box-shadow: 0 0 35px rgba(108,99,255,.3);
    font-weight: 700;
}

.login-shell .eyebrow { margin: 0 0 8px; color: #7de8ff; letter-spacing: .14em; font-size: 12px; }
.login-shell h1 { margin: 0; font-size: clamp(32px, 8vw, 54px); line-height: 1.05; letter-spacing: -.05em; }
.login-copy { margin: 16px 0 30px; color: rgba(255,255,255,.68); font-size: 14px; line-height: 1.65; }
.login-form { display: grid; gap: 18px; }
.login-form label { display: grid; gap: 9px; font-size: 13px; color: rgba(255,255,255,.72); }
.login-form input {
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border-radius: 16px;
    color: #fff;
    background: rgba(0,0,0,.3);
    border: 1px solid rgba(255,255,255,.12);
    outline: none;
}
.login-form input:focus { border-color: rgba(0,212,255,.65); box-shadow: 0 0 0 4px rgba(0,212,255,.08); }
.login-form button { min-height: 58px; border: 0; border-radius: 16px; color: #fff; cursor: pointer; background: linear-gradient(135deg, #6c63ff, #00b8df); font-weight: 600; }
.login-form button:disabled { opacity: .6; cursor: wait; }
.login-notice { margin: 0 0 18px; padding: 14px 16px; border-radius: 14px; color: #9ff4ca; background: rgba(65,211,142,.1); border: 1px solid rgba(65,211,142,.18); font-size: 13px; }
.login-notice.error { color: #ffaaa7; background: rgba(255,90,86,.1); border-color: rgba(255,90,86,.2); }
.login-meta { margin-top: 24px; color: rgba(255,255,255,.42); font-size: 11px; line-height: 1.6; }

.cms-session-controls { display: inline-flex; align-items: center; gap: 10px; }
.cms-session-user { color: rgba(255,255,255,.66); font-size: 11px; }
.cms-logout { min-height: 38px; padding: 0 13px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; }
.cms-logout:hover { background: rgba(255,255,255,.11); }

/* 45G: critical protected CMS geometry. These rules intentionally load before
   module JS so the first rendered frame matches the authenticated final layout. */
body[data-cms-protected] .dashboard-shell,
body[data-cms-protected] .shell,
body[data-cms-protected] .doctor-shell,
body[data-cms-protected] .user-shell,
body[data-cms-protected] .operations-shell,
body[data-cms-protected] .library-shell,
body[data-cms-protected] .security-shell,
body[data-cms-protected] .diagnostics-shell {
    width: min(1440px, calc(100% - 32px)) !important;
    margin-inline: auto !important;
    padding-top: 30px !important;
}

body[data-cms-protected] .dashboard-topbar,
body[data-cms-protected] .topbar,
body[data-cms-protected] .doctor-topbar,
body[data-cms-protected] .user-topbar,
body[data-cms-protected] .operations-topbar,
body[data-cms-protected] .library-topbar,
body[data-cms-protected] .security-topbar,
body[data-cms-protected] .diagnostics-topbar {
    padding: 0 !important;
    margin-top: 0 !important;
}

body[data-cms-protected] .dashboard-topbar > div:first-child,
body[data-cms-protected] .topbar > div:first-child,
body[data-cms-protected] .doctor-topbar > div:first-child,
body[data-cms-protected] .user-topbar > div:first-child,
body[data-cms-protected] .operations-topbar > div:first-child,
body[data-cms-protected] .library-topbar > div:first-child,
body[data-cms-protected] .security-topbar > div:first-child,
body[data-cms-protected] .diagnostics-topbar > div:first-child {
    width: 100% !important;
    min-width: 0 !important;
}

body[data-cms-protected] .topbar,
body[data-cms-protected] .doctor-topbar {
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body[data-cms-protected] .topbar::before,
body[data-cms-protected] .doctor-topbar::before {
    display: none !important;
}

body[data-cms-protected] .module-nav {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
    padding: 8px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 20px !important;
    background: rgba(8, 18, 42, 0.34) !important;
    box-sizing: border-box !important;
}

body[data-cms-protected] .module-nav a {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 140px !important;
    min-height: 42px !important;
    padding: 8px 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 14px !important;
    background: rgba(13, 29, 61, 0.28) !important;
    color: rgba(255, 255, 255, 0.72) !important;
    font-family: var(--font-ui) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    text-align: center !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

body[data-cms-protected] .module-nav a.active {
    border-color: rgba(255, 108, 151, 0.72) !important;
    background: linear-gradient(135deg, rgba(104, 81, 245, 0.24), rgba(34, 182, 230, 0.12)) !important;
    color: #ffffff !important;
    box-shadow: inset 0 0 0 1px rgba(255, 108, 151, 0.12) !important;
}

body[data-cms-protected] .eyebrow {
    font-family: var(--font-ui) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
}

body[data-cms-protected] h1 {
    font-size: clamp(1.5rem, 3.6vw, 2.15rem) !important;
    line-height: 1.08 !important;
    letter-spacing: 0.01em !important;
    text-transform: uppercase !important;
}

@media (max-width: 700px) {
    body[data-cms-protected] .dashboard-shell,
    body[data-cms-protected] .shell,
    body[data-cms-protected] .doctor-shell,
    body[data-cms-protected] .user-shell,
    body[data-cms-protected] .operations-shell,
    body[data-cms-protected] .library-shell,
    body[data-cms-protected] .security-shell,
    body[data-cms-protected] .diagnostics-shell {
        width: min(100% - 18px, 1440px) !important;
        padding-top: 18px !important;
    }

    body[data-cms-protected] .module-nav {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        min-height: 240px !important;
        padding: 8px !important;
        border-radius: 18px !important;
    }

    body[data-cms-protected] .module-nav a {
        width: 100% !important;
        min-height: 40px !important;
        padding: 7px 8px !important;
        font-size: 12px !important;
        border-radius: 13px !important;
    }

    body[data-cms-protected] .module-nav a[href="/patient/"] {
        grid-column: 1 / -1 !important;
    }

    body[data-cms-protected] h1 {
        font-size: clamp(1.45rem, 6.2vw, 1.85rem) !important;
    }
}

/* 139: one deterministic protected CMS header across every module. */
body[data-cms-protected] .governance-shell {
    width: min(1440px, calc(100% - 32px)) !important;
    margin-inline: auto !important;
    padding-top: 30px !important;
}

body[data-cms-protected] .dashboard-topbar,
body[data-cms-protected] .topbar,
body[data-cms-protected] .doctor-topbar,
body[data-cms-protected] .user-topbar,
body[data-cms-protected] .operations-topbar,
body[data-cms-protected] .library-topbar,
body[data-cms-protected] .security-topbar,
body[data-cms-protected] .diagnostics-topbar,
body[data-cms-protected] .governance-topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 404px !important;
    column-gap: 24px !important;
    align-items: start !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 0 28px !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

body[data-cms-protected] .dashboard-topbar::before,
body[data-cms-protected] .topbar::before,
body[data-cms-protected] .doctor-topbar::before,
body[data-cms-protected] .user-topbar::before,
body[data-cms-protected] .operations-topbar::before,
body[data-cms-protected] .library-topbar::before,
body[data-cms-protected] .security-topbar::before,
body[data-cms-protected] .diagnostics-topbar::before,
body[data-cms-protected] .governance-topbar::before {
    display: none !important;
}

body[data-cms-protected] .governance-topbar > div:first-child {
    width: 100% !important;
    min-width: 0 !important;
}

body[data-cms-protected] .module-nav {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    margin: 0 0 24px !important;
    min-height: 0 !important;
}

body[data-cms-protected] .module-nav a {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
    padding-inline: 9px !important;
    font-size: 11px !important;
}

/* 141: keep the page title descriptive but use a compact visible nav label. */
body[data-cms-protected] .module-nav a[href="/admin/templates/"] {
    font-size: 0 !important;
}
body[data-cms-protected] .module-nav a[href="/admin/templates/"]::after {
    content: "Шаблоны";
    font-size: 11px !important;
    line-height: 1.2 !important;
}

body[data-cms-protected] .module-nav a[hidden] {
    display: none !important;
}

body[data-cms-protected] .cms-session-controls {
    display: grid !important;
    grid-template-columns: 104px 90px 190px !important;
    gap: 10px !important;
    align-items: center !important;
    justify-content: end !important;
    width: 404px !important;
    min-width: 404px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
}

body[data-cms-protected] .cms-session-user {
    grid-column: 1 !important;
    justify-self: end !important;
    white-space: nowrap !important;
}

body[data-cms-protected] .cms-logout {
    grid-column: 2 !important;
    justify-self: stretch !important;
    width: 90px !important;
    min-width: 90px !important;
    max-width: 90px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 12px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
}

body[data-cms-protected] .cms-session-controls > :nth-child(3) {
    grid-column: 3 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    justify-self: stretch !important;
    width: 190px !important;
    max-width: 190px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 14px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

@media (max-width: 1180px) {
    body[data-cms-protected] .dashboard-topbar,
    body[data-cms-protected] .topbar,
    body[data-cms-protected] .doctor-topbar,
    body[data-cms-protected] .user-topbar,
    body[data-cms-protected] .operations-topbar,
    body[data-cms-protected] .library-topbar,
    body[data-cms-protected] .security-topbar,
    body[data-cms-protected] .diagnostics-topbar,
    body[data-cms-protected] .governance-topbar {
        grid-template-columns: 1fr !important;
        row-gap: 14px !important;
    }

    body[data-cms-protected] .module-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    body[data-cms-protected] .cms-session-controls {
        justify-content: start !important;
    }
}

@media (max-width: 700px) {
    body[data-cms-protected] .governance-shell {
        width: min(100% - 18px, 1440px) !important;
        padding-top: 18px !important;
    }

    body[data-cms-protected] .module-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        min-height: 0 !important;
    }

    body[data-cms-protected] .cms-session-controls {
        grid-template-columns: minmax(0, 1fr) auto !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    body[data-cms-protected] .cms-session-user {
        grid-column: 1 !important;
        justify-self: start !important;
    }

    body[data-cms-protected] .cms-logout {
        grid-column: 2 !important;
    }

    body[data-cms-protected] .cms-session-controls > :nth-child(3) {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: none !important;
        white-space: normal !important;
    }
}
