/* PERIOP Platform global typography */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@400;600;700&display=swap');

:root {
    --font-ui: "Unbounded", Arial, sans-serif;
}

html,
body,
button,
input,
select,
textarea,
optgroup {
    font-family: var(--font-ui);
}

/* 7.3D final UI contract: Unbounded is the only visible application font. */
html body,
html body *,
html body *::before,
html body *::after {
    font-family: var(--font-ui) !important;
}

/* Global CMS navigation contract: equal geometry and real inner spacing on every page. */
html body[data-cms-protected] nav.module-nav {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: none !important;
    padding: 8px !important;
    overflow: visible !important;
    box-sizing: border-box !important;
}

html body[data-cms-protected] nav.module-nav > a,
html body[data-cms-protected] nav.module-nav > a[href="/patient/"] {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 56px !important;
    min-height: 56px !important;
    padding: 8px 16px !important;
    line-height: 1.25 !important;
    text-align: center !important;
    text-decoration: none !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-wrap: balance;
    box-sizing: border-box !important;
}

/* One CMS button language: rounded glass controls with semantic primary/danger colors. */
html body[data-cms-protected] .button,
html body[data-cms-protected] .cms-logout,
html body[data-cms-protected] .icon-button {
    font-family: var(--font-ui) !important;
    border-radius: 14px !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
}

html body[data-cms-protected] .button,
html body[data-cms-protected] .cms-logout {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 42px !important;
    padding: 0 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
}

html body[data-cms-protected] .button:not(.primary):not(.danger),
html body[data-cms-protected] .cms-logout {
    background: rgba(255, 255, 255, 0.07) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

html body[data-cms-protected] .button.primary {
    border-color: rgba(108, 99, 255, 0.68) !important;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.96), rgba(0, 212, 255, 0.76)) !important;
    box-shadow: 0 12px 30px rgba(108, 99, 255, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.34) !important;
}

html body[data-cms-protected] .button.danger {
    border-color: rgba(255, 119, 115, 0.42) !important;
    background: rgba(255, 119, 115, 0.12) !important;
    color: #ffd1cf !important;
}

html body[data-cms-protected] .icon-button {
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: rgba(255, 255, 255, 0.07) !important;
    color: #fff !important;
}

/* Existing doctor shortcut keeps its route but uses the agreed Russian visible label. */
html body[data-cms-protected] a.button[href="/admin/doctors/onboarding/"] {
    font-size: 0 !important;
    text-decoration: none !important;
}

html body[data-cms-protected] a.button[href="/admin/doctors/onboarding/"]::after {
    content: "Подключение врача";
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.15 !important;
    text-decoration: none !important;
}

/* The only approved English product/role terms are handled elsewhere; module copy stays Russian. */
html body[data-cms-protected] #doctorEmpty .eyebrow {
    font-size: 0 !important;
}

html body[data-cms-protected] #doctorEmpty .eyebrow::after {
    content: "МОДУЛЬ ВРАЧА";
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    letter-spacing: 0.08em !important;
}

/* Unified CMS modal contract: compact cards, restrained headings, one action geometry. */
html body[data-cms-protected] dialog {
    border-radius: 20px !important;
    box-sizing: border-box !important;
}

html body[data-cms-protected] dialog:not(.organization-dialog):not(.preview-dialog):not(.content-editor-dialog) {
    padding: 16px 18px 18px !important;
}

html body[data-cms-protected] dialog.organization-dialog {
    padding: 0 !important;
}

html body[data-cms-protected] dialog.organization-dialog .dialog-card {
    gap: 12px !important;
    padding: 18px !important;
}

html body[data-cms-protected] dialog .dialog-head {
    gap: 12px !important;
    align-items: flex-start !important;
}

html body[data-cms-protected] dialog .dialog-head > div {
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

html body[data-cms-protected] dialog .dialog-head h2,
html body[data-cms-protected] dialog > h2 {
    margin: 0 !important;
    font-size: clamp(22px, 2.2vw, 30px) !important;
    line-height: 1.08 !important;
    letter-spacing: .01em !important;
    text-transform: uppercase !important;
    white-space: normal !important;
}

html body[data-cms-protected] dialog .dialog-head .eyebrow {
    margin: 0 0 5px !important;
    font-size: 10.5px !important;
    line-height: 1.2 !important;
    letter-spacing: .08em !important;
}

html body[data-cms-protected] dialog .dialog-head .subtitle,
html body[data-cms-protected] dialog > .subtitle,
html body[data-cms-protected] dialog .dialog-card > .subtitle {
    margin: 5px 0 0 !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
}

html body[data-cms-protected] dialog form,
html body[data-cms-protected] dialog .dialog-form,
html body[data-cms-protected] dialog .create-form,
html body[data-cms-protected] dialog .template-form,
html body[data-cms-protected] dialog .doctor-protocol-form {
    gap: 10px !important;
}

html body[data-cms-protected] dialog label {
    gap: 5px !important;
}

html body[data-cms-protected] dialog label > span,
html body[data-cms-protected] dialog .protocol-source-group > span {
    font-size: 12px !important;
    line-height: 1.25 !important;
}

html body[data-cms-protected] dialog input:not([type="checkbox"]):not([type="radio"]),
html body[data-cms-protected] dialog select,
html body[data-cms-protected] dialog textarea {
    min-height: 40px !important;
    padding: 9px 12px !important;
    border-radius: 12px !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
    box-sizing: border-box !important;
}

html body[data-cms-protected] dialog textarea {
    min-height: 84px !important;
}

html body[data-cms-protected] dialog .button {
    min-height: 40px !important;
    padding: 0 13px !important;
    font-size: 12px !important;
}

html body[data-cms-protected] dialog .icon-button {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
}

html body[data-cms-protected] dialog .dialog-actions,
html body[data-cms-protected] dialog .template-dialog-actions,
html body[data-cms-protected] dialog .doctor-protocol-dialog-actions {
    gap: 8px !important;
    margin-top: 10px !important;
}

html body[data-cms-protected] dialog .template-note,
html body[data-cms-protected] dialog .protocol-source-group,
html body[data-cms-protected] dialog .preview-section,
html body[data-cms-protected] dialog .version,
html body[data-cms-protected] dialog .field-card,
html body[data-cms-protected] dialog .editor-stage {
    padding: 12px 14px !important;
    border-radius: 14px !important;
}

html body[data-cms-protected] dialog .template-note,
html body[data-cms-protected] dialog .doctor-protocol-hint {
    font-size: 12px !important;
    line-height: 1.4 !important;
}

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

@media (max-width: 700px) {
    html body[data-cms-protected] nav.module-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }

    html body[data-cms-protected] nav.module-nav > a,
    html body[data-cms-protected] nav.module-nav > a[href="/patient/"] {
        height: auto !important;
        min-height: 48px !important;
        padding: 9px 12px !important;
    }

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

    html body[data-cms-protected] .button,
    html body[data-cms-protected] .cms-logout {
        min-height: 42px !important;
        white-space: normal !important;
    }

    html body[data-cms-protected] dialog .dialog-head h2,
    html body[data-cms-protected] dialog > h2 {
        font-size: clamp(20px, 6vw, 25px) !important;
        line-height: 1.08 !important;
    }

    html body[data-cms-protected] dialog:not(.organization-dialog):not(.preview-dialog):not(.content-editor-dialog) {
        padding: 14px !important;
    }

    html body[data-cms-protected] dialog.organization-dialog .dialog-card {
        padding: 14px !important;
    }

    /* Reuse the proven #161 iOS Safari dialog contract: pin long dialogs to the dynamic viewport. */
    html body[data-cms-protected] dialog#createOrganizationDialog[open],
    html body[data-cms-protected] dialog#createDoctorDialog[open],
    html body[data-cms-protected] dialog#createTemplateDialog[open] {
        position: fixed !important;
        top: max(6px, env(safe-area-inset-top)) !important;
        right: 6px !important;
        bottom: max(6px, env(safe-area-inset-bottom)) !important;
        left: 6px !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }
}

/* Final modal heading density: intentionally smaller on every device. */
html body[data-cms-protected] dialog .dialog-head h2,
html body[data-cms-protected] dialog > h2 {
    font-size: clamp(18px, 1.6vw, 24px) !important;
}

@media (max-width: 700px) {
    html body[data-cms-protected] dialog .dialog-head h2,
    html body[data-cms-protected] dialog > h2 {
        font-size: clamp(17px, 4.8vw, 20px) !important;
    }
}
