/* ========================================
 * MODAL — Модальные окна
 * ======================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal {
    position: relative;
    background: var(--color-white, #fff);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(0) scale(1);
    transition: transform 0.3s ease;
}

.modal-backdrop.hidden .modal {
    transform: translateY(-20px) scale(0.95);
}

/* Close Button */
.modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-gray-100, #f3f4f6);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal__close:hover {
    background: var(--color-gray-200, #e5e7eb);
    transform: rotate(90deg);
}

.modal__close svg {
    width: 20px;
    height: 20px;
    stroke: var(--color-gray-600, #4b5563);
}

/* Title */
.modal__title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 16px 0;
    padding-right: 40px;
    color: var(--color-text, #1f2937);
}

.modal__desc {
    color: var(--color-gray-600, #6b7280);
    margin-bottom: 24px;
    font-size: 15px;
    line-height: 1.5;
}

/* ========================================
 * QUICK BUY MODAL — Купить в 1 клик
 * ======================================== */

.modal--quick-buy {
    max-width: 480px;
}

.quick-buy__product {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--color-gray-50, #f9fafb);
    border-radius: 12px;
    margin-bottom: 20px;
}

.quick-buy__image {
    width: 80px;
    height: 80px;
    min-width: 80px;
    object-fit: cover;
    border-radius: 8px;
    background: #fff;
}

.quick-buy__info {
    flex: 1;
    min-width: 0;
}

.quick-buy__name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--color-text, #1f2937);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.quick-buy__price {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary, #2D5A27);
}

/* Form Inputs */
.modal .f-input,
.modal input[type="text"],
.modal input[type="tel"],
.modal input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-gray-200, #e5e7eb);
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.modal .f-input:focus,
.modal input:focus {
    outline: none;
    border-color: var(--color-primary, #2D5A27);
    box-shadow: 0 0 0 4px rgba(45, 90, 39, 0.1);
}

/* Submit Button */
.modal .f-btn,
.modal button[type="submit"] {
    width: 100%;
    padding: 16px 24px;
    background: var(--color-accent, #FF6B35);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.modal .f-btn:hover,
.modal button[type="submit"]:hover {
    background: var(--color-accent-dark, #e85a2a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
}

/* Agreement Checkbox */
.modal .f-agree {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-gray-600, #6b7280);
    cursor: pointer;
}

.modal .f-agree input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 2px 0 0 0;
    cursor: pointer;
    accent-color: var(--color-primary, #2D5A27);
}

.modal .f-agree a {
    color: var(--color-primary, #2D5A27);
    text-decoration: underline;
}

.modal .f-agree a:hover {
    text-decoration: none;
}

/* Contact Form 7 in Modal */
.modal .wpcf7 {
    margin: 0;
}

.modal .wpcf7-form-control-wrap {
    display: block;
    margin-bottom: 12px;
}

.modal .wpcf7 input[type="text"],
.modal .wpcf7 input[type="tel"],
.modal .wpcf7 input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--color-gray-200, #e5e7eb);
    border-radius: 10px;
    font-size: 16px;
}

.modal .wpcf7 input[type="submit"] {
    width: 100%;
    padding: 16px 24px;
    background: var(--color-accent, #FF6B35);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* ========================================
 * MOBILE MODAL FIXES
 * ======================================== */

@media (max-width: 768px) {
    .modal-backdrop {
        padding: 12px;
        align-items: flex-end;
    }
    
    .modal {
        padding: 24px;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        margin-bottom: 0;
    }
    
    .modal__title {
        font-size: 20px;
    }
    
    .quick-buy__product {
        padding: 12px;
        gap: 12px;
    }
    
    .quick-buy__image {
        width: 64px;
        height: 64px;
        min-width: 64px;
    }
    
    .quick-buy__name {
        font-size: 14px;
    }
    
    .quick-buy__price {
        font-size: 16px;
    }
}

/* Body lock when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* iOS Safari fix */
@supports (-webkit-touch-callout: none) {
    body.modal-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
}

/* ========================================
 * QUICK BUY SUCCESS
 * ======================================== */

.quick-buy-success {
    text-align: center;
    padding: 20px;
}

.quick-buy-success__icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.quick-buy-success__title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary, #2D5A27);
    margin: 0 0 8px 0;
}

.quick-buy-success__text {
    color: var(--color-gray-600, #6b7280);
    margin: 0;
}

/* Button loading state */
.f-btn {
    position: relative;
}

.f-btn__loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.f-btn__loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}