/*
 * Overlays
 * Оверлеи: меню, поиск, корзина, профиль
 */

/* Common Overlay Styles */
.mobile-menu-overlay,
.mobile-search-overlay,
.mobile-cart-overlay,
.mobile-profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    pointer-events: none; /* Отключаем клики на фоне */
}

.mobile-menu-overlay.active,
.mobile-search-overlay.active,
.mobile-cart-overlay.active,
.mobile-profile-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Включаем клики когда активно */
}

/* Все ссылки внутри оверлеев должны быть кликабельны */
.mobile-cart-overlay a,
.mobile-profile-overlay a {
    pointer-events: auto !important;
    position: relative;
    z-index: 10;
}

.mobile-menu-overlay.active,
.mobile-search-overlay.active,
.mobile-cart-overlay.active,
.mobile-profile-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Menu Overlay */
.mobile-menu-content {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 60%;
    max-width: 320px;
    background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
    padding: 60px 24px 24px;
    transform: translateX(-100%);
    transition: transform 0.8s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    border-radius: 0 24px 24px 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    pointer-events: auto; /* Гарантируем кликабельность контента */
}

.mobile-menu-overlay.active .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #52525b;
    transition: all 0.2s ease;
}

.mobile-menu-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #18181b;
}

.mobile-menu-close svg {
    width: 20px;
    height: 20px;
}

.mobile-nav-menu {
    list-style: none;
}

.mobile-nav-menu li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.mobile-nav-menu a {
    display: block;
    padding: 16px 0;
    font-size: 18px;
    font-weight: 500;
    color: #18181b;
    transition: all 0.2s ease;
}

.mobile-nav-menu a:hover {
    color: #007aff;
    padding-left: 8px;
}

/* Search Overlay */
.mobile-search-content {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
    padding: 50px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.32, 0.72, 0, 1);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    pointer-events: auto; /* Гарантируем кликабельность контента */
}

.mobile-search-overlay.active .mobile-search-content {
    transform: translateY(0);
}

.mobile-search-close {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #52525b;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.mobile-search-close:hover {
    background: #fff;
    color: #18181b;
    transform: translateX(-50%) scale(1.05);
}

.mobile-search-close svg {
    width: 20px;
    height: 20px;
}

.mobile-search-form {
    display: flex;
    gap: 12px;
}

.mobile-search-input {
    flex: 1;
    padding: 14px 18px;
    font-size: 16px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
}

.mobile-search-input:focus {
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.mobile-search-submit {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #52525b 0%, #3f3f46 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
}

.mobile-search-submit:hover {
    background: linear-gradient(135deg, #3f3f46 0%, #52525b 100%);
    transform: translateY(-2px);
}

.mobile-search-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mobile-search-submit svg {
    width: 20px;
    height: 20px;
}

/* Cart Overlay */
.mobile-cart-content {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    max-height: 80vh;
    background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.32, 0.72, 0, 1);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    pointer-events: auto; /* Гарантируем кликабельность контента */
}

.mobile-cart-overlay.active .mobile-cart-content {
    transform: translateY(0);
}

.mobile-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.mobile-cart-title {
    font-size: 20px;
    font-weight: 700;
    color: #18181b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-count-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #52525b 0%, #3f3f46 100%);
    border-radius: 12px;
}

.mobile-cart-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #52525b;
    transition: all 0.2s ease;
}

.mobile-cart-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #18181b;
}

.mobile-cart-close svg {
    width: 18px;
    height: 18px;
}

.mobile-cart-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    max-height: 50vh;
}

/* Landscape ориентация на мобильных */
@media (max-height: 500px) and (orientation: landscape) {
    .mobile-cart-content,
    .mobile-profile-content {
        max-height: 90vh;
    }
    
    .mobile-cart-body {
        max-height: 60vh;
    }
    
    .mobile-menu-content {
        width: 50%;
        max-width: 300px;
    }
    
    .mobile-profile-header {
        flex-direction: row;
        gap: 16px;
        margin-bottom: 16px;
    }
    
    .mobile-profile-avatar {
        margin-bottom: 0;
    }
}

.mobile-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #86868b;
}

.mobile-cart-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.mobile-cart-empty p {
    font-size: 16px;
}

.mobile-cart-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-cart-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    overflow: hidden;
}

.mobile-cart-item:last-child {
    border-bottom: none;
}

.mobile-cart-item-image {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-cart-item-info {
    flex: 1;
    min-width: 0;
}

.mobile-cart-item-name {
    font-size: 15px;
    font-weight: 600;
    color: #18181b;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.mobile-cart-item-qty {
    font-size: 13px;
    color: #86868b;
    margin-bottom: 4px;
}

.mobile-cart-item-price {
    font-size: 15px;
    font-weight: 700;
    color: #52525b;
}

.mobile-cart-qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}

.qty-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    color: #52525b;
    transition: all 0.2s ease;
}

.qty-btn:hover {
    background: #f4f4f5;
    border-color: rgba(0, 0, 0, 0.2);
}

.qty-btn:active {
    transform: scale(0.95);
}

.qty-btn svg {
    width: 14px;
    height: 14px;
}

.qty-value {
    min-width: 24px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: #18181b;
}

.mobile-cart-item-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #86868b;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

.mobile-cart-item-remove:hover {
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 8px;
}

.mobile-cart-item-remove svg {
    width: 18px;
    height: 18px;
}

.mobile-cart-footer {
    padding: 20px 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(180deg, rgba(244, 244, 245, 0.5) 0%, #f4f4f5 100%);
    border-radius: 0 0 24px 24px;
    position: relative;
    z-index: 5;
}

.mobile-cart-total-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 16px;
    font-weight: 700;
    color: #18181b;
}

.mobile-cart-tax-amount {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 13px;
    color: #86868b;
}

.cart-total-amount {
    font-size: 20px;
    font-weight: 700;
    color: #18181b;
}

.mobile-cart-button {
    display: block;
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, #52525b 0%, #3f3f46 100%);
    border-radius: 12px;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    z-index: 10;
    cursor: pointer;
    border: none;
}

.mobile-cart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.mobile-cart-button:last-child {
    margin-bottom: 0;
}

.mobile-cart-checkout {
    background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
}

.mobile-cart-checkout:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* Profile Overlay */
.mobile-profile-content {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 0;
    max-height: 70vh;
    background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
    transform: translateY(100%);
    transition: transform 0.8s cubic-bezier(0.32, 0.72, 0, 1);
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    pointer-events: auto; /* Гарантируем кликабельность контента */
}

.mobile-profile-overlay.active .mobile-profile-content {
    transform: translateY(0);
}

.mobile-profile-close {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #52525b;
    transition: all 0.2s ease;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.mobile-profile-close:hover {
    background: #fff;
    color: #18181b;
    transform: translateX(-50%) scale(1.05);
}

.mobile-profile-close svg {
    width: 20px;
    height: 20px;
}

.mobile-profile-body {
    padding: 24px;
    overflow-y: auto;
}

.mobile-profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.mobile-profile-avatar {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e4e4e7 0%, #d4d4d8 100%);
    border-radius: 50%;
    margin-bottom: 12px;
    color: #71717a;
}

.mobile-profile-avatar svg {
    width: 32px;
    height: 32px;
}

.mobile-profile-title {
    font-size: 20px;
    font-weight: 700;
    color: #18181b;
}

.mobile-profile-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-profile-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    color: #18181b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.mobile-profile-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mobile-profile-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 10px;
    color: #52525b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mobile-profile-icon svg {
    width: 20px;
    height: 20px;
}

.mobile-profile-label {
    font-size: 16px;
    font-weight: 500;
}

.mobile-profile-logout {
    margin-top: 8px;
    color: #ff3b30;
}

.mobile-profile-logout .mobile-profile-icon {
    color: #ff3b30;
    background: rgba(255, 59, 48, 0.1);
}

.mobile-profile-auth {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 0;
    gap: 16px;
}

.mobile-profile-auth p {
    font-size: 14px;
    color: #71717a;
    margin-bottom: 8px;
}

.mobile-profile-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #007aff 0%, #0051d5 100%);
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
}

.mobile-profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.mobile-profile-btn-outline {
    background: linear-gradient(135deg, #52525b 0%, #3f3f46 100%);
    color: #fff;
    border: none;
}

.mobile-profile-btn-outline:hover {
    background: linear-gradient(135deg, #3f3f46 0%, #52525b 100%);
    color: #fff;
}
