/* ============================================================
   02. START: HEADER
   Header + contacts + desktop dropdown + mobile burger
   ============================================================ */


/* ============================================================
   HEADER BASE
   ============================================================ */

.site-header {
    position: relative;
    z-index: 1000;

    background: var(--white);
    border-bottom: 1px solid var(--border);
}

.top-header {
    padding: 12px 0;

    background: var(--light-bg);
    border-bottom: 1px solid var(--border);
}


/* ---------- LOGO ---------- */

.brand-link {
    display: inline-flex;
    align-items: center;
}

.brand-logo {
    display: block;

    width: 200px;
    max-width: 100%;
    height: 160px;
}


/* ============================================================
   HEADER APPS
   ============================================================ */

.header-apps {
    display: flex;
    
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    gap: 7px;
}

.header-app-link {
    display: block;

    line-height: 0;
    text-decoration: none;

    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.header-app-link:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.header-app-badge {
    display: block;

    width: 120px;
    max-width: 100%;
    height: auto;
}


/* ============================================================
   HEADER CONTACTS
   ============================================================ */

.header-contacts {
    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 26px;
}


/* ---------- BRANCHES ---------- */

.header-branches {
    display: flex;
    align-items: stretch;

    gap: 16px;
}

.header-branch {
    min-width: 290px;
    padding: 9px 16px;

    border-left: 2px solid rgba(31, 63, 108, 0.15);

    box-sizing: border-box;
}


/* ---------- ADDRESS ---------- */

.header-branch__address {
    margin-bottom: 7px;

    font-size: 16px;
    line-height: 1.3;
    font-weight: 700;

    color: var(--text);
}


/* ---------- CONTACT LINE ---------- */

.header-contact-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;

    column-gap: 6px;
    row-gap: 3px;

    margin-top: 4px;
}


/* ---------- CONTACT LABEL ---------- */

.header-contact-line__label {
    flex: 0 0 auto;

    font-size: 15px;
    line-height: 1.4;
    font-weight: 500;

    color: var(--text);

    white-space: nowrap;
}


/* ---------- CONTACT PHONE ---------- */

.header-contact-line__phone {
    display: inline-block;
    flex: 0 0 auto;

    font-size: 17px;
    line-height: 1.4;
    font-weight: 700;

    color: var(--primary);

    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;

    text-decoration: none;

    transition: color var(--transition-fast);
}

.header-contact-line__phone:hover {
    color: var(--accent2);
    text-decoration: none;
}


/* ---------- SECONDARY CONTACTS ---------- */

.header-contact-line--secondary {
    margin-top: 4px;
}

.header-contact-line--secondary .header-contact-line__label {
    font-size: 13px;
    line-height: 1.4;
    font-weight: 400;

    color: var(--muted);
}

.header-contact-line--secondary .header-contact-line__phone {
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;

    color: #52677f;

    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
}

.header-contact-line--secondary .header-contact-line__phone:hover {
    color: var(--primary);
}


/* ============================================================
   HEADER ACTIONS
   ============================================================ */

.header-actions {
    display: flex;
    align-items: center;

    gap: 14px;
}


/* ---------- MESSENGER ---------- */

.messenger {
    display: flex;
    align-items: center;
    justify-content: center;
}

.messenger a {
    display: flex;
    align-items: center;
    justify-content: center;
}

.messenger img {
    display: block;

    width: 30px;
    height: 30px;

    border-radius: 50%;
}


/* ---------- CALLBACK BUTTON ---------- */

.btn-callback {
    padding: 8px 16px;

    border: none;
    border-radius: var(--radius-small);

    background: var(--accent);
    color: var(--white);

    cursor: pointer;

    font-size: 0.9rem;
    line-height: 1.3;
    font-weight: 600;

    white-space: nowrap;

    transition:
        background var(--transition-normal),
        transform var(--transition-fast);
}

.btn-callback:hover {
    background: var(--accent2);

    transform: translateY(-2px);
}


/* ============================================================
   TABLET HEADER <= 1200px
   ============================================================ */

@media (max-width: 1200px) {

    .header-contacts {
        gap: 14px;
    }

    .header-branches {
        gap: 8px;
    }

    .header-branch {
        min-width: 245px;

        padding-left: 11px;
        padding-right: 11px;
    }

    .header-branch__address {
        font-size: 15px;
    }

    .header-contact-line__label {
        font-size: 14px;
    }

    .header-contact-line__phone {
        font-size: 16px;
    }

    .header-contact-line--secondary .header-contact-line__label {
        font-size: 12px;
    }

    .header-contact-line--secondary .header-contact-line__phone {
        font-size: 13px;
    }

    .header-app-badge {
        width: 100px;
    }

}


/* ============================================================
   MOBILE HEADER <= 991px
   ============================================================ */

@media (max-width: 991px) {

    .top-header .container {
        flex-wrap: wrap;
    }

    .brand {
        flex: 0 0 100%;
        width: 100%;
    }

    .brand-link {
        justify-content: center;
        width: 100%;
    }

    .header-apps {
        order: 2;

        flex-direction: row;
        justify-content: center;

        width: 100%;

        gap: 8px;
    }

    .header-app-badge {
        width: 105px;
    }

    .header-contacts {
        order: 3;

        width: 100%;

        flex-direction: column;
        align-items: stretch;

        gap: 14px;
    }

    .header-branches {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));

        width: 100%;

        gap: 10px;
    }

    .header-branch {
        width: 100%;
        min-width: 0;

        padding: 12px 14px;

        background: #fff;

        border-left: 2px solid rgba(31, 63, 108, 0.15);
        border-radius: 8px;

        box-sizing: border-box;
    }

    .header-branch__address {
        margin-bottom: 9px;

        font-size: 16px;
        line-height: 1.35;
        font-weight: 700;

        color: var(--text);

        overflow-wrap: normal;
        word-break: normal;
    }

    .header-contact-line {
        display: flex;
        align-items: baseline;
        flex-wrap: wrap;

        column-gap: 6px;
        row-gap: 3px;

        width: 100%;

        margin-top: 5px;
    }

    .header-contact-line__label {
        flex: 0 0 auto;

        font-size: 16px;
        line-height: 1.4;
        font-weight: 500;

        white-space: nowrap;
    }

    .header-contact-line__phone {
        display: inline-block;
        flex: 0 0 auto;

        font-size: 18px;
        line-height: 1.4;
        font-weight: 700;

        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    .header-contact-line--secondary {
        margin-top: 7px;
    }

    .header-contact-line--secondary .header-contact-line__label {
        font-size: 14px;
        line-height: 1.4;
        font-weight: 400;
    }

    .header-contact-line--secondary .header-contact-line__phone {
        font-size: 15px;
        line-height: 1.4;
        font-weight: 500;

        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    .header-actions {
        justify-content: center;
        width: 100%;
    }

}


/* ============================================================
   HEADER BOTTOM
   ============================================================ */

.bottom-header {
    position: relative;

    padding: 10px 0;

    background: var(--white);
}

.header-inner {
    position: relative;

    width: 100%;

    align-items: center;
}


/* ============================================================
   MAIN NAV
   ============================================================ */

.main-nav {
    position: relative;

    width: 100%;
}

.nav-list,
.submenu {
    margin: 0;
    padding: 0;

    list-style: none;
}

.nav-list {
    display: flex;
    align-items: center;
    justify-content: center;

    gap: 1rem;
}

.nav-item {
    position: relative;

    list-style: none;
}

.nav-parent {
    display: flex;
    align-items: center;
}

.nav-link {
    display: inline-flex;
    align-items: center;

    padding: 10px 12px;

    color: var(--text);

    border-radius: var(--radius-small);

    text-decoration: none;
    white-space: nowrap;

    transition:
        background var(--transition-fast),
        color var(--transition-fast);
}

.nav-link:hover,
.nav-link:focus {
    background: rgba(31, 63, 108, 0.08);

    color: var(--primary);

    text-decoration: none;
}


/* ============================================================
   SUBMENU ARROW BUTTON
   ============================================================ */

.submenu-toggle {
    position: relative;

    flex: 0 0 30px;

    width: 30px;
    height: 30px;

    padding: 0;
    margin-left: -6px;

    border: 0;

    background: transparent;

    cursor: pointer;
}

.submenu-toggle span {
    position: absolute;

    top: 50%;
    left: 50%;

    width: 8px;
    height: 8px;

    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);

    transform: translate(-50%, -65%) rotate(45deg);

    transition: transform var(--transition-fast);
}


/* ============================================================
   DESKTOP MENU >= 992px
   ============================================================ */

@media (min-width: 992px) {

    .menu-toggle,
    .menu-overlay {
        display: none !important;
    }

    .main-nav {
        display: block !important;
    }


    /* ========================================================
       FIRST LEVEL DROPDOWN
       ======================================================== */

    .nav-list > .has-children > .submenu {
        position: absolute;

        top: calc(100% + 2px);
        left: 0;

        z-index: 1200;

        display: block;

        min-width: 290px;
        width: max-content;
        max-width: 360px;

        padding: 12px;

        background: var(--surface);

        border: 1px solid var(--border);
        border-radius: var(--radius-large);

        box-shadow: 0 14px 30px rgba(31, 63, 108, 0.14);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transform: translateY(8px);

        transition:
            opacity var(--transition-fast),
            visibility var(--transition-fast),
            transform var(--transition-fast);
    }

    .nav-list > .has-children:hover > .submenu,
    .nav-list > .has-children:focus-within > .submenu,
    .nav-list > .has-children.is-open > .submenu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;

        transform: translateY(0);
    }


    /* ---------- SUBMENU ITEMS ---------- */

    .submenu > .nav-item {
        width: 100%;
    }

    .submenu .nav-parent {
        width: 100%;
    }

    .submenu .nav-link {
        flex: 1 1 auto;

        width: 100%;
        min-width: 240px;

        justify-content: flex-start;

        padding: 11px 14px;

        border-radius: 10px;
    }


    /* ========================================================
       SECOND LEVEL DROPDOWN
       ======================================================== */

    .submenu > .has-children {
        position: relative;
    }

    .submenu > .has-children > .submenu {
        position: absolute;

        top: -12px;
        left: calc(100% - 1px);

        z-index: 1300;

        display: block;

        min-width: 290px;
        width: max-content;
        max-width: 380px;

        padding: 12px;

        background: var(--surface);

        border: 1px solid var(--border);
        border-radius: var(--radius-large);

        box-shadow: 0 14px 30px rgba(31, 63, 108, 0.14);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transform: translateX(8px);

        transition:
            opacity var(--transition-fast),
            visibility var(--transition-fast),
            transform var(--transition-fast);
    }

    .submenu > .has-children:hover > .submenu,
    .submenu > .has-children:focus-within > .submenu,
    .submenu > .has-children.is-open > .submenu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;

        transform: translateX(0);
    }


    /* Стрелка второго уровня смотрит вправо */

    .submenu .submenu-toggle span {
        transform: translate(-65%, -50%) rotate(-45deg);
    }

}


/* ============================================================
   BURGER / OVERLAY DEFAULT
   ============================================================ */

.menu-toggle {
    display: none;
}

.menu-overlay {
    display: none;
}


/* ============================================================
   MOBILE / TABLET MENU <= 991px
   ============================================================ */

@media (max-width: 991px) {

    body.menu-lock {
        overflow: hidden;
    }


    /* ---------- BOTTOM HEADER ---------- */

    .bottom-header {
        padding: 8px 0;
    }

    .header-inner {
        display: flex;

        min-height: 44px;

        align-items: center;
        justify-content: flex-end !important;
    }


    /* ========================================================
       BURGER
       ======================================================== */

    .menu-toggle {
        position: relative;

        z-index: 1401;

        display: flex !important;

        flex-direction: column;
        align-items: center;
        justify-content: center;

        width: 44px;
        height: 44px;

        padding: 0;

        border: 1px solid var(--border);
        border-radius: 10px;

        background: var(--white);

        cursor: pointer;
    }

    .menu-toggle span {
        position: absolute;

        display: block;

        width: 22px;
        height: 2px;

        margin: 0;

        background: var(--primary);

        border-radius: 2px;

        transition:
            transform 0.25s ease,
            opacity 0.2s ease,
            top 0.25s ease;
    }

    .menu-toggle span:nth-child(1) {
        top: 13px;
    }

    .menu-toggle span:nth-child(2) {
        top: 20px;
    }

    .menu-toggle span:nth-child(3) {
        top: 27px;
    }


    /* ---------- BURGER ACTIVE ---------- */

    .site-header.menu-open .menu-toggle span:nth-child(1),
    .menu-toggle.active span:nth-child(1) {
        top: 20px;

        transform: rotate(45deg);
    }

    .site-header.menu-open .menu-toggle span:nth-child(2),
    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .site-header.menu-open .menu-toggle span:nth-child(3),
    .menu-toggle.active span:nth-child(3) {
        top: 20px;

        transform: rotate(-45deg);
    }


    /* ========================================================
       DARK OVERLAY
       ======================================================== */

    .menu-overlay {
        position: fixed;

        inset: 0;

        z-index: 1390;

        display: block;

        background: rgba(20, 31, 46, 0.48);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition:
            opacity 0.25s ease,
            visibility 0.25s ease;
    }

    .site-header.menu-open .menu-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }


    /* ========================================================
       SIDE MENU
       ======================================================== */

    .main-nav {
        position: fixed;

        top: 0;
        right: 0;

        z-index: 1400;

        display: block !important;

        width: min(88vw, 390px);
        height: 100vh;
        height: 100dvh;

        padding: 74px 18px 30px;

        overflow-y: auto;

        overscroll-behavior: contain;

        background: var(--white);

        box-shadow: -18px 0 45px rgba(31, 63, 108, 0.18);

        transform: translateX(105%);

        visibility: hidden;
        pointer-events: none;

        transition:
            transform 0.3s ease,
            visibility 0.3s ease;
    }

    .main-nav.is-open,
    .main-nav.active {
        transform: translateX(0);

        visibility: visible;
        pointer-events: auto;
    }


    /* ---------- MOBILE NAV LIST ---------- */

    .nav-list {
        display: flex;

        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;

        gap: 0;

        width: 100%;
    }

    .nav-item {
        width: 100%;

        border-bottom: 1px solid var(--border);
    }

    .nav-parent {
        display: flex;

        align-items: stretch;

        width: 100%;
    }

    .nav-link {
        flex: 1 1 auto;

        width: 100%;

        padding: 15px 10px;

        border-radius: 0;

        font-size: 1rem;

        white-space: normal;
    }


    /* ---------- MOBILE SUBMENU BUTTON ---------- */

    .submenu-toggle {
        flex: 0 0 46px;

        width: 46px;
        height: auto;
        min-height: 48px;

        margin: 0;
    }

    .has-children.is-open > .nav-parent .submenu-toggle span,
    .has-children.active > .nav-parent .submenu-toggle span {
        transform: translate(-50%, -35%) rotate(225deg);
    }


    /* ========================================================
       MOBILE ACCORDION SUBMENU
       ======================================================== */

    .submenu {
        position: static !important;

        display: none !important;

        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;

        margin: 0 !important;

        padding: 4px 0 8px 14px !important;

        background: #f8fafc !important;

        border: 0 !important;
        border-left: 2px solid rgba(31, 63, 108, 0.14) !important;
        border-radius: 0 !important;

        box-shadow: none !important;

        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;

        transform: none !important;
    }

    .has-children.is-open > .submenu,
    .has-children.active > .submenu {
        display: block !important;
    }

    .submenu .nav-item {
        border-bottom: 0;
    }

    .submenu .nav-link {
        padding: 12px 10px;

        font-size: 0.95rem;
    }

    .submenu .submenu {
        padding-left: 14px !important;

        background: #fff !important;
    }

}


/* ============================================================
   SMALL MOBILE <= 767px
   ============================================================ */

@media (max-width: 767px) {

    .top-header {
        padding: 10px 0;
    }

    .top-header .container {
        gap: 10px !important;
    }

    .brand-logo {
        width: 190px;
    }

    .header-apps {
        gap: 6px;
    }

    .header-app-badge {
        width: 100px;
    }

    .header-branches {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .header-branch {
        padding: 11px;
    }

    .header-branch__address {
        margin-bottom: 8px;

        font-size: 16px;
        line-height: 1.35;
        font-weight: 700;
    }

    .header-contact-line {
        display: flex;
        flex-direction: row;
        align-items: baseline;
        flex-wrap: wrap;

        column-gap: 6px;
        row-gap: 3px;

        width: 100%;

        margin-top: 6px;
    }

    .header-contact-line__label {
        flex: 0 0 auto;

        font-size: 16px;
        line-height: 1.4;
        font-weight: 500;

        white-space: nowrap;
    }

    .header-contact-line__phone {
        display: inline-block;
        flex: 0 0 auto;

        font-size: 18px;
        line-height: 1.4;
        font-weight: 700;

        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    .header-contact-line--secondary {
        margin-top: 7px;
    }

    .header-contact-line--secondary .header-contact-line__label {
        font-size: 14px;
        line-height: 1.4;
        font-weight: 400;

        white-space: nowrap;
    }

    .header-contact-line--secondary .header-contact-line__phone {
        font-size: 15px;
        line-height: 1.4;
        font-weight: 500;

        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }

    .header-actions {
        display: flex;
        align-items: center;
        justify-content: center;

        gap: 14px;

        width: 100%;
    }

    .messenger {
        display: flex;
        justify-content: center;
    }

    .btn-callback {
        width: auto;
        padding: 10px 18px;
    }

}


/* ============================================================
   VERY SMALL MOBILE <= 480px
   ============================================================ */

@media (max-width: 480px) {

    .header-apps {
        gap: 5px;
    }

    .header-app-badge {
        width: 94px;
    }

    .header-branches {
        gap: 7px;
    }

    .header-branch {
        padding: 10px;
    }

    .header-branch__address {
        font-size: 15px;
    }

    .header-contact-line__label {
        font-size: 15px;
    }

    .header-contact-line__phone {
        font-size: 17px;
    }

    .header-contact-line--secondary .header-contact-line__label {
        font-size: 13px;
    }

    .header-contact-line--secondary .header-contact-line__phone {
        font-size: 14px;
    }

}


/* ============================================================
   EXTREMELY SMALL MOBILE <= 380px
   ============================================================ */

@media (max-width: 380px) {

    .header-apps {
        flex-wrap: wrap;
    }

    .header-app-badge {
        width: 90px;
    }

    .header-branches {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .header-branch {
        padding: 12px 14px;
    }

    .header-branch__address {
        font-size: 16px;
    }

    .header-contact-line__label {
        font-size: 16px;
    }

    .header-contact-line__phone {
        font-size: 18px;
    }

    .header-contact-line--secondary .header-contact-line__label {
        font-size: 14px;
    }

    .header-contact-line--secondary .header-contact-line__phone {
        font-size: 15px;
    }

}


/* ============================================================
   SERVICES — MOBILE 2 COLUMNS
   ============================================================ */

@media (max-width: 600px) {

    .services-grid {
        display: grid;

        grid-template-columns: repeat(2, minmax(0, 1fr));

        gap: 12px;

        margin: 20px 0;
    }

    .service-card {
        min-width: 0;

        padding: 10px;

        border-radius: 16px;
    }

    .service-card img {
        width: 100%;

        aspect-ratio: 4 / 3;
        object-fit: cover;

        margin-bottom: 10px;

        border-radius: 12px;
    }

    .service-card h3 {
        margin: 0;

        font-size: 14px;
        line-height: 1.3;

        text-align: center;
    }

}


/* ============================================================
   END: HEADER
   ============================================================ */