/* menu.css - Современные стили для выпадающего меню профиля в стиле Google/Yandex */

:root {
    --menu-bg: #ffffff;
    --menu-hover: #f8f9fa;
    --menu-active: #e8f0fe;
    --menu-text: #3c4043;
    --menu-text-secondary: #5f6368;
    --menu-border: #e8eaed;
    --menu-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --menu-shadow-hover: 0 4px 15px rgba(0,0,0,0.15);
    --accent-color: #1a73e8;
    --accent-hover: #1557b0;
    --logout-color: #d93025;
    --logout-hover: #b52d20;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --menu-bg: #2d2e30;
        --menu-hover: #3c4043;
        --menu-active: #2d3748;
        --menu-text: #e8eaed;
        --menu-text-secondary: #9aa0a6;
        --menu-border: #5f6368;
        --menu-shadow: 0 2px 10px rgba(0,0,0,0.3);
        --menu-shadow-hover: 0 4px 15px rgba(0,0,0,0.4);
    }
}

.profile-header {
    display: flex;
    justify-content: flex-end;
    padding: 0;
    position: fixed;
    top: 1rem;
    right: 2rem;
    z-index: 1000;
}

.profile-menu-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    position: relative;
}

.profile-menu-trigger:hover {
    background-color: var(--menu-hover);
}

.profile-menu-trigger.active {
    background-color: var(--menu-active);
}

.avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #4285f4);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
    transition: var(--transition);
}

.profile-menu-trigger:hover .avatar-small {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
}

/* Overlay для мобильных устройств */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 999;
    backdrop-filter: blur(2px);
}

/* Кнопка закрытия для мобильных */
.mobile-menu-close {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background-color: var(--menu-bg);
    border-radius: 50%;
    box-shadow: var(--menu-shadow);
    cursor: pointer;
    z-index: 1001;
    align-items: center;
    justify-content: center;
    color: var(--menu-text);
    font-size: 20px;
    transition: var(--transition);
}

.mobile-menu-close:hover {
    background-color: var(--menu-hover);
    transform: scale(1.1);
}

/* Основной контейнер меню */
.profile-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-width: 90vw;
    background-color: var(--menu-bg);
    border: 1px solid var(--menu-border);
    border-radius: 16px;
    box-shadow: var(--menu-shadow);
    z-index: 1000;
    overflow: hidden;
    animation: menuSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top right;
}

@keyframes menuSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.profile-menu-dropdown.active {
    display: block;
}

/* Заголовок меню */
.dropdown-header {
    padding: 24px;
    border-bottom: 1px solid var(--menu-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.avatar-large {
    width: 64px;
    height: 64px;
    position: relative;
    flex-shrink: 0;
}

.avatar-text {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #4285f4);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
}

.avatar-ring {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #4285f4);
    z-index: -1;
    opacity: 0;
    animation: ringPulse 2s infinite;
}

@keyframes ringPulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.1); }
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    margin: 0 0 4px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--menu-text);
    line-height: 1.3;
}

.user-email {
    margin: 0;
    font-size: 0.875rem;
    color: var(--menu-text-secondary);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Секции меню */
.dropdown-section {
    border-bottom: 1px solid var(--menu-border);
}

.dropdown-section:last-child {
    border-bottom: none;
}

.section-content {
    padding: 8px;
}

/* Элементы меню */
.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--menu-text);
    border-radius: 8px;
    transition: var(--transition);
    min-height: 48px;
}

.menu-item:hover {
    background-color: var(--menu-hover);
    transform: translateX(2px);
}

.menu-item:active {
    background-color: var(--menu-active);
}

.item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--menu-text-secondary);
    font-size: 18px;
    flex-shrink: 0;
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-title {
    display: block;
    font-weight: 500;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--menu-text);
}

.item-subtitle {
    display: block;
    font-size: 0.8rem;
    color: var(--menu-text-secondary);
    line-height: 1.2;
    margin-top: 2px;
}

.item-arrow {
    color: var(--menu-text-secondary);
    font-size: 14px;
    opacity: 0;
    transition: var(--transition);
}

.menu-item:hover .item-arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* Раздел аккаунтов */
.accounts-details {
    width: 100%;
    background-color: transparent;
    border: none;
}

.accounts-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
    border-radius: 8px;
    transition: var(--transition);
    min-height: 48px;
    color: var(--menu-text);
}

.accounts-summary:hover {
    background-color: var(--menu-hover);
    transform: translateX(2px);
}

.accounts-summary::-webkit-details-marker {
    display: none;
}

.chevron-container {
    color: var(--menu-text-secondary);
    font-size: 14px;
}

.chevron-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accounts-details[open] > .accounts-summary .chevron-icon {
    transform: rotate(180deg);
}

.details-content {
    padding: 8px 16px 16px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 300px;
        transform: translateY(0);
    }
}

.accounts-list {
    margin-bottom: 12px;
}

.account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--menu-text);
    border-radius: 6px;
    transition: var(--transition);
    margin-bottom: 4px;
}

.account-item:hover {
    background-color: var(--menu-hover);
    transform: translateX(4px);
}

.account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #34a853, #137333);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-email {
    font-size: 0.875rem;
    color: var(--menu-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accounts-divider {
    height: 1px;
    background-color: var(--menu-border);
    margin: 12px 0;
}

.add-account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--accent-color);
    border-radius: 6px;
    transition: var(--transition);
    font-weight: 500;
}

.add-account-item:hover {
    background-color: var(--menu-active);
    transform: translateX(4px);
}

.add-icon {
    color: var(--accent-color);
    background-color: var(--menu-active);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
}

/* Секция выхода */
.logout-item {
    color: var(--logout-color);
}

.logout-item:hover {
    background-color: rgba(217, 48, 37, 0.1);
}

.logout-icon {
    color: var(--logout-color);
}

/* Подвал меню */
.dropdown-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--menu-border);
    background-color: var(--menu-hover);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.footer-link {
    color: var(--menu-text-secondary);
    text-decoration: none;
    font-size: 0.75rem;
    transition: var(--transition);
}

.footer-link:hover {
    color: var(--accent-color);
}

.footer-separator {
    color: var(--menu-text-secondary);
    font-size: 0.75rem;
}

/* Мобильные стили */
@media (max-width: 768px) {
    .profile-header {
        right: 16px;
        top: 16px;
    }

    .menu-overlay.active {
        display: block;
    }

    .mobile-menu-close.active {
        display: flex;
    }

    .profile-menu-dropdown {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
        animation: mobileSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        padding-top: 80px;
    }

    @keyframes mobileSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .dropdown-header {
        padding: 32px 24px 24px;
    }

    .user-info {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .avatar-large {
        width: 80px;
        height: 80px;
    }

    .avatar-text {
        width: 80px;
        height: 80px;
        font-size: 2.2rem;
    }

    .user-name {
        font-size: 1.5rem;
    }

    .user-email {
        font-size: 1rem;
    }

    .section-content {
        padding: 12px 16px;
    }

    .menu-item,
    .accounts-summary {
        padding: 16px 20px;
        min-height: 56px;
    }

    .item-title {
        font-size: 1rem;
    }

    .item-subtitle {
        font-size: 0.875rem;
    }

    .account-item {
        padding: 12px 16px;
        min-height: 48px;
    }

    .account-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .account-email {
        font-size: 1rem;
    }

    .add-account-item {
        padding: 12px 16px;
        font-size: 1rem;
    }

    .dropdown-footer {
        padding: 24px;
        margin-top: auto;
    }

    body.mobile-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* Анимации для улучшения UX */
.menu-item,
.accounts-summary,
.account-item,
.add-account-item {
    position: relative;
    overflow: hidden;
}

.menu-item::before,
.accounts-summary::before,
.account-item::before,
.add-account-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.menu-item:hover::before,
.accounts-summary:hover::before,
.account-item:hover::before,
.add-account-item:hover::before {
    left: 100%;
}

/* Улучшенная анимация для иконок */
.item-icon i {
    transition: var(--transition);
}

.menu-item:hover .item-icon i {
    transform: scale(1.1);
}

.logout-item:hover .logout-icon i {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Скрытие стандартных стилей для details */
details summary {
    outline: none;
}

details summary::-webkit-details-marker {
    display: none;
}