/*
 * Portal B visual alignment v2.
 *
 * Визуальное направление адаптировано из design/portal-shell Павла,
 * но production Portal остаётся обычным ASP.NET Core Razor Pages.
 * Этот файл подключается после site.css и переопределяет только presentation.
 */

:root {
    --portal-v2-blue: #0864d9;
    --portal-v2-blue-dark: #052f6c;
    --portal-v2-blue-deep: #032454;
    --portal-v2-text: #0b1018;
    --portal-v2-muted: #667085;
    --portal-v2-border: #e1e6ed;
    --portal-v2-surface: #ffffff;
    --portal-v2-bg: #f7f9fc;
    --portal-v2-success: #168947;
    --portal-v2-danger: #b42318;
    --portal-v2-radius: 7px;
    --portal-v2-sidebar-width: 228px;
    --portal-v2-header-height: 76px;
}

body {
    background: var(--portal-v2-bg);
    color: var(--portal-v2-text);
}

.portal-shell {
    min-height: 100vh;
    display: block;
    background: var(--portal-v2-bg);
}

/* =========================================================
   TOP BAR
   ========================================================= */

.portal-topbar {
    position: relative;
    z-index: 20;
    min-height: var(--portal-v2-header-height);
    display: grid;
    grid-template-columns: var(--portal-v2-sidebar-width) minmax(220px, 1fr) auto;
    align-items: center;
    border-bottom: 1px solid #e5e9ef;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.025);
}

.portal-brand {
    min-height: var(--portal-v2-header-height);
    display: flex;
    align-items: center;
    padding: 10px 22px;
    border-right: 1px solid #edf0f4;
    color: inherit;
    text-decoration: none;
}

.portal-brand img {
    display: block;
    width: auto;
    max-width: 162px;
    max-height: 50px;
    object-fit: contain;
}

.portal-breadcrumbs {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 30px;
    color: #6b7280;
    font-size: 13px;
}

.portal-breadcrumbs strong {
    overflow: hidden;
    color: #111827;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-breadcrumbs__divider {
    color: #a3aab5;
    font-size: 18px;
    line-height: 1;
}

.portal-topbar__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 22px 12px 10px;
}

.portal-account-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 3px 6px 3px 3px;
    color: #101828;
    text-decoration: none;
}

.portal-account-link:hover .portal-user__name {
    color: var(--portal-v2-blue);
}

.portal-user__avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--portal-v2-blue);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.portal-user__name {
    max-width: 240px;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .15s ease;
}

.portal-logout-form {
    margin: 0;
}

.portal-logout-button {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #dce1e8;
    border-radius: 5px;
    background: #ffffff;
    color: #475467;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.portal-logout-button:hover {
    border-color: #bfc8d5;
    color: #111827;
}

.portal-topbar__status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--portal-v2-muted);
    font-size: 13px;
}

/* =========================================================
   BODY / SIDEBAR
   ========================================================= */

.portal-body {
    min-height: calc(100vh - var(--portal-v2-header-height));
    display: grid;
    grid-template-columns: var(--portal-v2-sidebar-width) minmax(0, 1fr);
}

.portal-sidebar {
    position: sticky;
    top: 0;
    min-height: calc(100vh - var(--portal-v2-header-height));
    height: calc(100vh - var(--portal-v2-header-height));
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 22px 14px 16px;
    overflow-y: auto;
    background:
        linear-gradient(
            180deg,
            #073d85 0%,
            var(--portal-v2-blue-dark) 48%,
            var(--portal-v2-blue-deep) 100%
        );
    color: #ffffff;
}

.portal-nav {
    display: grid;
    gap: 4px;
}

.portal-nav__link {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 5px;
    color: rgba(255, 255, 255, 0.76);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease;
}

.portal-nav__link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.portal-nav__link--active {
    border-color: rgba(76, 144, 255, 0.38);
    background:
        linear-gradient(
            90deg,
            rgba(30, 111, 230, 0.72),
            rgba(29, 101, 205, 0.48)
        );
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.portal-nav__icon {
    width: 24px;
    flex: 0 0 24px;
    color: #a8ccff;
    font-size: 18px;
    line-height: 1;
    text-align: center;
}

.portal-sidebar__bottom {
    margin-top: auto;
}

.portal-workspace {
    min-width: 0;
    background: var(--portal-v2-bg);
}

.portal-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* =========================================================
   HERO / HOME
   ========================================================= */

.software-hero {
    min-height: 430px;
    display: grid;
    grid-template-columns: minmax(500px, .95fr) minmax(420px, 1.05fr);
    overflow: hidden;
    border-bottom: 1px solid #e6e9ee;
    background: linear-gradient(110deg, #ffffff 0%, #ffffff 48%, #f7faff 100%);
}

.software-hero__main {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 54px 42px 48px;
}

.software-hero__eyebrow {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #111827;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .025em;
}

.software-hero__eyebrow span:first-child {
    color: var(--portal-v2-blue);
}

.software-hero__eyebrow i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #aab2bd;
}

.software-hero h1 {
    max-width: 760px;
    margin: 20px 0 17px;
    color: var(--portal-v2-text);
    font-size: clamp(34px, 3vw, 48px);
    font-weight: 750;
    line-height: 1.08;
    letter-spacing: -.045em;
}

.software-hero h1 span {
    display: block;
    margin-top: 2px;
    color: var(--portal-v2-blue);
}

.software-hero__description {
    max-width: 690px;
    margin: 0;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.62;
}

.software-hero__buttons {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-top: 25px;
}

.hero-button {
    min-width: 185px;
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 19px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition:
        transform .15s ease,
        box-shadow .15s ease,
        border-color .15s ease;
}

.hero-button:hover {
    transform: translateY(-1px);
}

.hero-button--primary {
    border: 1px solid var(--portal-v2-blue);
    background: var(--portal-v2-blue);
    color: #ffffff;
    box-shadow: 0 5px 14px rgba(8, 100, 217, .18);
}

.hero-button--primary:hover {
    box-shadow: 0 7px 18px rgba(8, 100, 217, .23);
}

.hero-button--secondary {
    border: 1px solid #b9c0c9;
    background: #ffffff;
    color: #111827;
}

.hero-button--secondary:hover {
    border-color: #7f8996;
}

.hero-button strong {
    font-size: 19px;
    font-weight: 400;
}

.software-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 25px;
    color: var(--portal-v2-muted);
    font-size: 11px;
}

.software-hero__meta > div {
    display: flex;
    align-items: center;
    gap: 7px;
}

.hero-meta__dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
}

.hero-meta__dot--green {
    background: #29b967;
    box-shadow: 0 0 0 3px rgba(41, 185, 103, .12);
}

.hero-meta__dot--blue {
    border: 2px solid var(--portal-v2-blue);
    background: #ffffff;
}

.hero-meta__icon {
    color: var(--portal-v2-muted);
    font-size: 13px;
}

.software-hero__visual {
    position: relative;
    min-width: 0;
    min-height: 430px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 52%, #f2f7ff 100%);
}

.hero-image-background {
    position: absolute;
    width: 620px;
    height: 620px;
    right: -170px;
    bottom: -320px;
    border: 1px solid rgba(8, 100, 217, .10);
    border-radius: 50%;
}

.hero-image-background::before {
    content: "";
    position: absolute;
    width: 480px;
    height: 480px;
    left: 65px;
    top: 65px;
    border: 1px solid rgba(8, 100, 217, .08);
    border-radius: 50%;
}

.hero-software-image {
    position: relative;
    z-index: 2;
    width: min(94%, 780px);
    height: auto;
    display: block;
    object-fit: contain;
    transform: translateY(7px);
    filter: drop-shadow(0 20px 30px rgba(25, 45, 70, .10));
}

.portal-overview,
.applications--portal {
    padding: 32px 38px 46px;
    background: #f8fafc;
}

.applications--portal {
    min-height: calc(100vh - var(--portal-v2-header-height));
}

.applications__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 20px;
}

.section-eyebrow {
    display: block;
    color: var(--portal-v2-blue);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .09em;
}

.applications__header h1,
.applications__header h2 {
    margin: 5px 0 0;
    color: var(--portal-v2-text);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.applications__header p {
    max-width: 460px;
    margin: 0 0 2px;
    color: #7a8491;
    font-size: 12px;
    line-height: 1.5;
    text-align: right;
}

.portal-overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.portal-overview-card {
    min-height: 205px;
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--portal-v2-border);
    border-radius: var(--portal-v2-radius);
    background: #ffffff;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(16, 24, 40, .035);
    transition:
        transform .16s ease,
        border-color .16s ease,
        box-shadow .16s ease;
}

.portal-overview-card:not(.portal-overview-card--static):hover {
    transform: translateY(-2px);
    border-color: #c9d6e8;
    box-shadow: 0 9px 24px rgba(16, 24, 40, .07);
}

.portal-overview-card__icon,
.application-icon {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border: 1px solid #dce9ff;
    border-radius: 7px;
    background: #edf4ff;
    color: var(--portal-v2-blue);
    font-size: 24px;
}

.portal-overview-card strong {
    margin-top: 18px;
    color: #111827;
    font-size: 17px;
}

.portal-overview-card > span:not(.portal-overview-card__icon) {
    margin-top: 9px;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.55;
}

.portal-overview-card em {
    margin-top: auto;
    padding-top: 18px;
    color: var(--portal-v2-blue);
    font-size: 12px;
    font-style: normal;
    font-weight: 700;
}

.portal-overview-card--static em {
    color: var(--portal-v2-success);
}

/* =========================================================
   TOOL CARDS
   ========================================================= */

.applications-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.applications-grid--dynamic {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.application-card {
    min-width: 0;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    padding: 21px;
    border: 1px solid var(--portal-v2-border);
    border-radius: var(--portal-v2-radius);
    background: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 24, 40, .035);
    transition:
        transform .16s ease,
        border-color .16s ease,
        box-shadow .16s ease;
}

.application-card:hover {
    transform: translateY(-2px);
    border-color: #c9d6e8;
    box-shadow: 0 9px 24px rgba(16, 24, 40, .07);
}

.application-status {
    align-self: flex-start;
    min-height: 21px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border-radius: 4px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .035em;
}

.application-status--available {
    background: #e9f8ee;
    color: var(--portal-v2-success);
}

.application-icon {
    margin-top: 22px;
}

.application-card h2,
.application-card h3 {
    margin: 18px 0 9px;
    color: #111827;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.27;
    letter-spacing: -.015em;
}

.application-card p {
    margin: 0;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.58;
}

.application-card__footer {
    margin-top: auto;
    padding-top: 18px;
}

.application-action {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 18px;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease;
}

.application-action strong {
    font-size: 19px;
    font-weight: 400;
}

.application-action--primary {
    border: 1px solid var(--portal-v2-blue);
    background: var(--portal-v2-blue);
    color: #ffffff;
}

.application-action--primary:hover {
    border-color: #0758c0;
    background: #0758c0;
}

.portal-state-card {
    max-width: 760px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--portal-v2-border);
    border-radius: var(--portal-v2-radius);
    background: #ffffff;
}

.portal-state-card__icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: #edf4ff;
    color: var(--portal-v2-blue);
    font-weight: 800;
}

.portal-state-card strong {
    display: block;
    margin-bottom: 7px;
}

.portal-state-card p {
    margin: 0;
    color: var(--portal-v2-muted);
    line-height: 1.55;
}

/* =========================================================
   FORMS / ISSUE #27
   ========================================================= */

.auth-panel,
.admin-editor-card,
.profile-card,
.admin-table-card,
.admin-summary__item {
    border-radius: var(--portal-v2-radius);
}

.auth-panel {
    width: min(560px, calc(100% - 40px));
    margin: 42px auto;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(16, 24, 40, .055);
}

.auth-panel__heading h1,
.page-heading h1 {
    letter-spacing: -.025em;
}

.auth-panel__heading h1 {
    font-size: 30px;
}

.form-field input {
    min-height: 46px;
    border-radius: 5px;
}

.portal-button {
    border-radius: 5px;
}

.portal-button--primary {
    background: var(--portal-v2-blue);
}

.portal-button--primary:hover {
    background: #0758c0;
}

.password-requirements {
    margin: 0 0 22px;
    padding: 16px 18px;
    border: 1px solid #d9e6f8;
    border-radius: 6px;
    background: #f5f9ff;
    color: #344054;
}

.password-requirements strong {
    display: block;
    margin-bottom: 9px;
    color: #1d4f91;
    font-size: 13px;
}

.password-requirements ul {
    display: grid;
    gap: 5px;
    margin: 0;
    padding-left: 19px;
    font-size: 12px;
    line-height: 1.45;
}

.auth-validation:not(:empty) {
    margin-bottom: 2px;
    padding: 12px 14px;
    border: 1px solid #f1b9b4;
    border-radius: 6px;
    background: #fff5f4;
    color: var(--portal-v2-danger);
    font-size: 13px;
    line-height: 1.45;
}

.auth-validation ul {
    margin: 0;
    padding-left: 18px;
}

.field-validation:not(:empty) {
    font-weight: 500;
}

.auth-forced-note {
    margin-bottom: 18px;
    border-radius: 6px;
}

.admin-alert,
.profile-status {
    border-radius: 6px;
}

.admin-alert--success,
.profile-status--success {
    border-color: #a8dec0;
    background: #edf9f2;
    color: #116b39;
}

.admin-editor-card {
    box-shadow: 0 6px 22px rgba(16, 24, 40, .04);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {
    .software-hero {
        grid-template-columns: minmax(420px, 1fr) minmax(360px, .85fr);
    }

    .portal-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    :root {
        --portal-v2-sidebar-width: 84px;
    }

    .portal-brand {
        justify-content: center;
        padding: 10px 8px;
    }

    .portal-brand img {
        max-width: 62px;
    }

    .portal-nav__link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    .portal-nav__link span:last-child {
        display: none;
    }

    .portal-breadcrumbs {
        padding-left: 18px;
        padding-right: 18px;
    }

    .portal-user__name {
        max-width: 160px;
    }

    .software-hero {
        grid-template-columns: 1fr;
    }

    .software-hero__visual {
        min-height: 330px;
    }

    .portal-overview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .portal-topbar {
        min-height: 64px;
        grid-template-columns: 118px minmax(0, 1fr);
    }

    .portal-brand {
        min-height: 64px;
    }

    .portal-brand img {
        max-width: 100px;
    }

    .portal-breadcrumbs {
        display: none;
    }

    .portal-topbar__actions {
        padding-right: 10px;
    }

    .portal-user__name {
        display: none;
    }

    .portal-body {
        display: block;
        min-height: calc(100vh - 64px);
    }

    .portal-sidebar {
        position: static;
        width: 100%;
        min-height: auto;
        height: auto;
        padding: 8px 10px;
    }

    .portal-nav {
        display: flex;
        overflow-x: auto;
    }

    .portal-nav__link {
        min-width: 48px;
        flex: 0 0 auto;
    }

    .software-hero__main {
        padding: 36px 20px 28px;
    }

    .software-hero h1 {
        font-size: 34px;
    }

    .software-hero__buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-button {
        width: 100%;
    }

    .software-hero__meta {
        display: grid;
    }

    .software-hero__visual {
        min-height: 270px;
    }

    .hero-software-image {
        width: 105%;
        max-width: none;
    }

    .portal-overview,
    .applications--portal {
        padding: 26px 20px 38px;
    }

    .applications__header {
        display: block;
    }

    .applications__header p {
        margin-top: 10px;
        text-align: left;
    }

    .applications-grid,
    .applications-grid--dynamic {
        grid-template-columns: 1fr;
    }

    .auth-panel {
        width: calc(100% - 24px);
        margin: 24px auto;
        padding: 22px;
    }
}
