/* Кабінет у шапці: випадаюча форма входу / меню користувача */

.header-auth {
    position: relative;
    flex-shrink: 0;
    z-index: 1001;
}

.header-auth-trigger,
.header-auth-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(var(--color-accent-rgb), 0.28);
    background: rgba(255, 255, 255, 0.98);
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.header-auth-trigger:hover,
.header-auth-user-trigger:hover {
    border-color: rgba(var(--color-accent-rgb), 0.55);
    box-shadow: 0 4px 14px rgba(var(--color-accent-rgb), 0.14);
}

.header-auth-trigger:focus-visible,
.header-auth-user-trigger:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.header-auth-trigger-icon {
    display: flex;
    color: var(--color-accent);
}

.header-auth-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    z-index: 1002;
}

.header-auth-dropdown[hidden] {
    display: none !important;
}

.header-auth-title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.header-auth-field {
    margin-bottom: 10px;
}

.header-auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.header-auth-field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e1e5f1;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.header-auth-field input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(var(--color-accent-rgb), 0.2);
}

.header-auth-submit {
    width: 100%;
    margin-top: 4px;
}

.header-auth .header-auth-status {
    min-height: 0;
    margin-top: 8px !important;
    font-size: 0.85rem;
}

.header-auth-register-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-accent-strong);
    text-decoration: none;
}

.header-auth-register-link:hover {
    text-decoration: underline;
}

.header-auth-user-trigger {
    max-width: min(220px, 42vw);
}

.header-auth-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-strong));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.header-auth-user-email {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-text);
}

.header-auth-dropdown--user {
    padding: 8px;
    min-width: 200px;
}

.header-auth-menu-link {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.header-auth-menu-link:hover,
.header-auth-menu-link:focus-visible {
    background: #f0f7ff;
    outline: none;
}

.header-auth-menu-logout {
    width: 100%;
    margin-top: 4px;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #c62828;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
}

.header-auth-menu-logout:hover,
.header-auth-menu-logout:focus-visible {
    background: #ffebee;
    outline: none;
}

@media (max-width: 768px) {
    /* Один ряд: логотип | кабінет (справа від лого) | бургер; меню — наступним рядком */
    .logo-link {
        order: 1;
    }

    .header-auth {
        order: 2;
        margin-left: auto;
    }

    .mobile-menu-toggle {
        order: 3;
    }

    nav {
        order: 4;
    }

    .header-cta {
        order: 5;
    }

    .header-auth-trigger-text {
        display: none;
    }

    .header-auth-trigger {
        padding: 10px 12px;
    }

    .header-auth-user-email {
        max-width: 72px;
    }

    .header-auth-user-trigger {
        max-width: 130px;
        padding: 8px 10px;
    }
}
