/**
 * Стили фронтенда для Quick Buy WooCommerce
 */

/* Основной контейнер */
.qbwc-wrapper {
   margin-bottom: 10px;
}

/* Специальные стили для страницы товара */
.qbwc-single-product-wrapper {
   
}

.qbwc-single-product-wrapper .qbwc-wrapper {
   
}

/* Специальные стили для каталога */
.qbwc-loop-product-wrapper {
    margin-top: 10px;
    margin-bottom: 10px;
}

.woocommerce ul.products li.product .qbwc-loop-product-wrapper .qbwc-wrapper {
   
}

/* Иконка и текст над кнопкой */
.qbwc-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    font-weight: 500;
    color: #495057;
}

.qbwc-icon {
    display: inline-block;
    margin-right: 8px;
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.qbwc-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.qbwc-icon-text {
    font-size: 14px;
}

/* Контейнер кнопок */
.qbwc-button-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Иконка и текст внутри кнопки */
button.qbwc-quick-buy-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    font-weight: 700;
    border: none;
    padding: 15px 30px;
    border-radius: 2em;
}

.qbwc-button-icon {
    display: inline-flex;
    align-items: center;
    width: 20px;
    height: 20px;
}

.qbwc-button-icon svg {
    width: 100%;
    height: 100%;
}

.qbwc-button-text {
    display: inline-block;
}

/* Кнопка быстрой покупки */
.qbwc-quick-buy-button {
    width: 100%;
}

.qbwc-quick-buy-button:active {
    transform: translateY(0) !important;
}

.qbwc-quick-buy-button:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Текстовый блок над кнопкой */
.qbwc-info-text {
    display: flex;
    flex-wrap: wrap;
    column-gap: 10px;
    margin-bottom: 12px;
    align-items: center;
    justify-content: center;
}

/* Иконка в текстовом блоке */
.qbwc-info-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-top: 2px;

}

.qbwc-info-icon svg {
    display: block;
    width: 24px;
    height: 24px;
}

/* Контент текстового блока */
.qbwc-info-text-content {
  
}

/* Ссылка в текстовом блоке */
.qbwc-info-text .qbwc-info-link {
    flex: 0 0 100%;
    font-size: 0.8em;
    text-align: center;
}

.qbwc-info-text .qbwc-info-link:hover {

}

/* Попап overlay */
.qbwc-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.qbwc-popup-overlay.show {
    opacity: 1;
}

/* Контент попапа */
.qbwc-popup-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.qbwc-popup-overlay.show .qbwc-popup-content {
    transform: scale(1);
}

/* Заголовок попапа */
.qbwc-popup-header {
    padding: 20px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qbwc-popup-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #212529;
}

.qbwc-popup-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.qbwc-popup-close:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Тело попапа */
.qbwc-popup-body {
    padding: 20px;
}

.qbwc-popup-text {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: #495057;
}

/* Форма */
.qbwc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.qbwc-form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qbwc-form-field label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.qbwc-form-field .required {
    color: #dc3545;
}

.qbwc-form-field .qbwc-input {
    padding: 12px 16px !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    /*font-size: 16px;*/
    transition: all 0.3s ease;
    /*background: white;*/
}

.qbwc-form-field .qbwc-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.qbwc-form-field .qbwc-input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.qbwc-form-field .qbwc-input {

}

/* Кнопка отправки формы */
.qbwc-form-actions {
    margin-top: 10px;
}

.qbwc-submit-button {
    padding: 14px 30px !important;
    border-radius: 8px !important;
    width: 100% !important;
    text-transform: none !important;
    
}

.qbwc-submit-button:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.qbwc-submit-button.loading {
    position: relative;
    color: transparent !important;
}

.qbwc-submit-button.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: qbwc-spin 1s linear infinite;
}

@keyframes qbwc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Сообщения формы */
.qbwc-form-messages {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 15px;
}

.qbwc-form-messages.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.qbwc-form-messages.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Адаптивность */
@media (max-width: 768px) {
    .qbwc-popup-content {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .qbwc-popup-header {
        padding: 15px 15px 0;
    }
    
    .qbwc-popup-body {
        padding: 15px;
    }
    
    .qbwc-popup-title {
        font-size: 20px;
    }
    
    .qbwc-button-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .qbwc-quick-buy-button {
        min-width: 100% !important;
    }
    
    .qbwc-wrapper {
        margin: 10px 0;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .qbwc-icon-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    
    .qbwc-icon {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .qbwc-input {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
}

/* Стили для каталога товаров */
.woocommerce ul.products li.product .qbwc-wrapper {
    margin: 10px 0;
}

.woocommerce ul.products li.product .qbwc-quick-buy-button {
    
}

.woocommerce ul.products li.product .qbwc-icon-wrapper {
    margin-bottom: 8px;
}

.woocommerce ul.products li.product .qbwc-icon-text {
    font-size: 12px;
}

/* Интеграция с темами */
.woocommerce-page .qbwc-wrapper {
    margin-top: 20px;
}

/* Анимации появления */
.qbwc-wrapper {
    animation: qbwc-fadeInUp 0.5s ease;
}

@keyframes qbwc-fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Состояние загрузки для кнопки быстрой покупки */
.qbwc-quick-buy-button.loading {
    pointer-events: none;
}

/* Улучшенные состояния ошибок */
.qbwc-form-field.has-error .qbwc-input {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.qbwc-form-field .field-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.qbwc-form-field.has-error .field-error {
    display: block;
}

/* Стили для RTL */
[dir="rtl"] .qbwc-icon {
    margin-right: 0;
    margin-left: 8px;
}

[dir="rtl"] .qbwc-button-wrapper {
    direction: rtl;
}

/* Accessibility улучшения */
.qbwc-quick-buy-button:focus,
.qbwc-submit-button:focus,
.qbwc-popup-close:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Высокий контраст */
@media (prefers-contrast: high) {
    .qbwc-wrapper {
        border: 2px solid #000;
    }
    
    .qbwc-quick-buy-button {
        background: #000 !important;
        border: 2px solid #000 !important;
    }
    
    .qbwc-info-link {
        color: #000 !important;
        border-bottom-color: #000 !important;
    }
}

/* Уменьшенная анимация */
@media (prefers-reduced-motion: reduce) {
    .qbwc-wrapper,
    .qbwc-quick-buy-button,
    .qbwc-popup-overlay,
    .qbwc-popup-content,
    .qbwc-input {
        animation: none;
        transition: none;
    }
}