/* Полный оптимизированный pay.css для Android WebView */

/* Слайдер заказа в стиле мобильных тултипов - оптимизированный */
.purchase-slider {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    transform: translate3d(0, 100%, 0);
    transition: transform 0.25s ease-out;
    z-index: 1050;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 16px 16px 0 0;
    
    /* GPU acceleration для плавности */
    will-change: transform;
    -webkit-transform: translate3d(0, 100%, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.purchase-slider.show {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.purchase-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 16px 16px 0 0;
    position: relative;
    min-height: 70px;
    flex-shrink: 0;
}

/* Индикатор для свайпа - упрощенный */
.purchase-slider-header::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    background: #cbd5e0;
    border-radius: 2px;
    opacity: 0.8;
}

.purchase-slider-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
    letter-spacing: -0.02em;
}

.purchase-close-btn {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    font-size: 18px;
    color: #4a5568;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.15s ease;
    font-weight: 500;
    will-change: background-color;
}

.purchase-close-btn:hover {
    background: #edf2f7;
    color: #2d3748;
}

.purchase-slider-content {
    padding: 20px 24px 24px;
    overflow-y: auto;
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    
    /* Оптимизация прокрутки для мобильных */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Компактные стили для выбора услуг */
.services-selection {
    margin-bottom: 20px;
}

.services-selection-title {
    margin: 0 0 12px;
    font-weight: 600;
    color: #2d3748;
    font-size: 16px;
}

#servicesContainer {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    background: #f8f9fa;
    max-height: 300px;
    overflow-y: auto;
    
    /* Оптимизация прокрутки */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.service-item {
    display: flex;
    align-items: center;
    padding: 12px 8px;
    border-bottom: 1px solid #e8e8e8;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-radius: 6px;
    will-change: background-color;
}

.service-item:last-child {
    border-bottom: none;
}

.service-item:hover {
    background-color: rgba(66, 153, 225, 0.06);
}

.service-checkbox {
    margin-right: 12px;
    transform: scale(1.1);
    cursor: pointer;
    accent-color: #4299e1;
}

.service-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.service-details {
    flex: 1;
}

.service-name {
    font-weight: 500;
    color: #2d3748;
    font-size: 15px;
    margin-bottom: 2px;
}

.service-description {
    font-size: 12px;
    color: #718096;
    line-height: 1.3;
}

.service-price {
    font-weight: 600;
    color: #4299e1;
    margin-left: 12px;
    font-size: 14px;
}

.service-free {
    color: #38a169;
}

/* Компактные поля формы */
.form-section {
    margin-bottom: 16px;
}

.form-section-title {
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
    font-size: 16px;
}

.compact-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 12px;
    transition: border-color 0.15s ease;
    background: #ffffff;
    box-sizing: border-box;
}

.compact-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.1);
}

.compact-input.error {
    border-color: #e53e3e;
    background: #fed7d7;
}

.error-text {
    display: none;
    color: #e53e3e;
    font-size: 12px;
    margin-top: -8px;
    margin-bottom: 12px;
}

.form-hint {
    font-size: 12px;
    color: #718096;
    margin-top: -8px;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Компактный промо-код */
.promo-section {
    margin-bottom: 16px;
}

.promo-input-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.promo-input-group input {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    height: 44px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.15s ease;
    background: #ffffff;
    box-sizing: border-box;
}

.promo-input-group input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.1);
}

.promo-input-group button {
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    width: 44px;
    flex-shrink: 0;
    border: 1px solid #4299e1;
    background: transparent;
    border-radius: 6px;
    color: #4299e1;
    cursor: pointer;
    transition: background-color 0.15s ease;
    will-change: background-color;
}

.promo-input-group button:hover {
    background-color: #4299e1;
    color: white;
}

.promo-input-group button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.promo-input-group button.btn-success {
    border-color: #38a169;
    background-color: #38a169;
    color: white;
}

.promo-input-group button.btn-success:hover {
    background-color: #2f855a;
    border-color: #276749;
}

.promo-status {
    display: block;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.3;
}

.promo-status.success {
    color: #38a169;
}

.promo-status.error {
    color: #e53e3e;
}

.promo-input-group input:disabled {
    background-color: #f7fafc;
    cursor: not-allowed;
}

/* Компактная итоговая стоимость */
.total-price-section {
    background: #f0f8ff;
    border: 1px solid #90cdf4;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.total-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.total-price-label {
    font-weight: 600;
    color: #2d3748;
    font-size: 16px;
}

#totalPrice {
    font-size: 20px;
    font-weight: 700;
    color: #1a365d;
    transition: color 0.2s ease;
}

#priceBreakdown {
    font-size: 12px;
    color: #4a5568;
    line-height: 1.4;
    margin-top: 4px;
}

/* Кнопка оплаты - упрощенная для производительности */
.pay-button-container {
    padding-top: 8px;
}

.pay-button {
    background: #1976d2;
    border: none;
    color: white;
    padding: 16px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 56px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: 0.02em;
    will-change: background-color, transform;
}

.pay-button:hover {
    background: #1565c0;
    transform: translateY(-1px);
}

.pay-button:active {
    transform: translateY(0);
    background: #0d47a1;
}

.pay-button:disabled {
    background: #90a4ae;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pay-button.loading {
    background: #90a4ae;
    cursor: default;
    transform: none;
}

/* Загрузочный спиннер */
.spinner-border {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    vertical-align: text-bottom;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Адаптация для планшетов */
@media (min-width: 768px) and (max-width: 1024px) {
    .purchase-slider {
        right: 20px;
        left: auto;
        width: 450px;
        max-height: 85vh;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        transform: translate3d(100%, 0, 0);
        bottom: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

    .purchase-slider.show {
        transform: translate3d(0, 0, 0);
    }
    
    .purchase-slider-header {
        border-radius: 12px 12px 0 0;
    }
}

/* Адаптация для больших экранов */
@media (min-width: 1025px) {
    .purchase-slider {
        width: 500px;
        right: 20px;
        left: auto;
        max-height: 90vh;
        border-radius: 12px;
        border: 1px solid #e2e8f0;
        transform: translate3d(100%, 0, 0);
        bottom: 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

    .purchase-slider.show {
        transform: translate3d(0, 0, 0);
    }
}

/* Оверлей для слайдера */
.purchase-slider-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.purchase-slider-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    .purchase-slider {
        background: #1a202c;
        border-top-color: #4a5568;
        color: #f7fafc;
    }
    
    .purchase-slider-header {
        background: #2d3748;
        border-bottom-color: #4a5568;
    }
    
    .purchase-slider-title {
        color: #f7fafc;
    }
    
    .purchase-close-btn {
        background: #4a5568;
        color: #f7fafc;
        border-color: #718096;
    }
    
    .purchase-close-btn:hover {
        background: #718096;
    }

    #servicesContainer {
        background: #2d3748;
        border-color: #4a5568;
    }

    .service-item:hover {
        background-color: rgba(99, 179, 237, 0.1);
    }

    .compact-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #f7fafc;
    }

    .compact-input:focus {
        border-color: #63b3ed;
        box-shadow: 0 0 0 2px rgba(99, 179, 237, 0.1);
    }

    .total-price-section {
        background: #2a4365;
        border-color: #4299e1;
    }

    .total-price-label {
        color: #f7fafc;
    }

    #totalPrice {
        color: #90cdf4;
    }

    #priceBreakdown {
        color: #cbd5e0;
    }
}

/* Специальные оптимизации для Android WebView */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Ускорение анимаций через GPU */
    .purchase-slider,
    .purchase-close-btn,
    .service-item,
    .pay-button,
    .promo-input-group button {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    /* Упрощение теней для Android */
    .purchase-slider {
        box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    }
    
    .pay-button {
        box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    }
}

/* Дополнительные оптимизации для старых Android устройств */
@media screen and (max-device-width: 767px) and (-webkit-min-device-pixel-ratio: 1) {
    /* Упрощение для слабых устройств */
    .purchase-slider {
        transition: transform 0.2s ease;
    }
    
    .service-item,
    .pay-button,
    .compact-input {
        transition: none;
    }
    
    /* Убираем тени на слабых устройствах */
    .purchase-slider,
    .pay-button {
        box-shadow: none;
    }
}