/* Dflex Woo Theme - AJAX Search Styles */

.dflex-search-modal,
.dflex-search-modal *,
.dflex-search-overlay {
    box-sizing: border-box;
}

body.dflex-search-open {
    overflow: hidden;
}

.dflex-search-form-modal input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

/* Inline Form */
.dflex-search-form-wrap {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.dflex-search-mobile-trigger {
    display: none !important;
}

@media (max-width: 768px) {
    .dflex-search-mobile-icon-enabled .dflex-search-form-inner {
        display: none !important;
    }

    .dflex-search-mobile-icon-enabled .dflex-search-mobile-trigger {
        display: flex !important;
    }
}

.dflex-search-form {
    display: flex;
    position: relative;
    background: white;

    border-radius: 20px;
    overflow: hidden;
    border: 1px solid #CADAF1;
    transition: all 0.2s;
}

.dflex-search-form:focus-within {
    background: #fff;
    border-color: #CADAF1;
    box-shadow: none;
}

.dflex-search-input {
    flex: 1;
    padding: 10px 10px 10px 20px;
    border: none !important;
    font-size: 15px;
    outline: none !important;
    box-shadow: none !important;
}

.dflex-search-input:focus {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.dflex-search-submit {
    border: none;
    background: none !important;
    padding: 0 15px;
    cursor: pointer;
    color: var(--dflex-btn-bg, var(--dflex-color-primary, #888));
    font-size: 18px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dflex-search-submit i {
    color: var(--dflex-btn-bg, var(--dflex-color-primary, #888));
}

.dflex-search-submit:hover {
    color: var(--dflex-btn-hover-bg, var(--dflex-color-primary-hover, #E53935));
}

.dflex-search-submit.dflex-search-disabled,
.dflex-search-submit.dflex-search-disabled i {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

/* Dropdown Results (Inline) */
.dflex-search-results-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    /* Смещаем вправо, чтобы не выходило за экран, если поиск в шапке */
    min-width: 100%;
    width: 600px;
    max-width: 100vw;
    /* На мобильных не больше экрана */
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    margin-top: 10px;
    z-index: 1000;
    display: none;
    overflow: hidden;
    border: 1px solid #eee;
}

.dflex-search-results-dropdown.active {
    display: block;
}

/* Popup Search */
.dflex-search-icon-trigger {
    font-size: 22px;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
}

.dflex-search-icon-trigger:hover {
    color: var(--dflex-color-primary, #E53935);
}

.dflex-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 999998;
    backdrop-filter: blur(12px);
}

.dflex-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dflex-search-modal {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    width: 90%;
    max-width: 800px;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.dflex-search-modal.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.dflex-search-close {
    position: absolute;
    top: -30px;
    right: 0;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #1a1a1a;
    transition: color 0.2s;
}

.dflex-search-close:hover {
    color: var(--dflex-color-primary, #E53935);
}

.dflex-search-form-modal {
    position: relative;
    display: flex;
    align-items: center;
    border-bottom: 2px solid #ddd;
    padding-bottom: 15px;
    transition: border-color 0.3s;
}

.dflex-search-form-modal:focus-within {
    border-color: #ddd;
}

.dflex-search-modal-icon-left {
    font-size: 28px;
    color: #888;
    margin-right: 20px;
    display: flex;
    align-items: center;
}

.dflex-search-form-modal input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 36px;
    font-weight: 600;
    outline: none;
    padding: 0;
}

.dflex-search-form-modal input::placeholder {
    color: #ccc;
}

.dflex-search-form-modal input::-webkit-search-cancel-button {
    margin-right: 35px;
    /* Push the native X away from the right edge so spinner can fit */
}

.dflex-search-spinner {
    display: none;
    position: absolute;
    right: 0;
    font-size: 24px;
    color: var(--dflex-color-primary, #E53935);
    pointer-events: none;
}

.dflex-search-results-modal {
    margin-top: 40px;
    max-height: calc(100vh - 15vh - 120px);
    /* 15vh (top) + 110px (form + gaps) + 10px (bottom margin) */
    overflow-y: auto;
}

/* Result Items (Shared) */
.dflex-search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    margin-bottom: 12px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.dflex-search-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

.dflex-search-item-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}

.dflex-search-item-img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 20px;
}

.dflex-search-item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.dflex-search-item-info {
    flex: 1;
    min-width: 0;
    padding-right: 20px;
}

.dflex-search-item-title {
    font-size: var(--dflex-card-title-size, 20px);
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dflex-search-item-sku {
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.dflex-search-item-price {
    gap: 5px;
    font-size: 18px;
    font-weight: var(--dflex-card-price-weight, 500);
    color: var(--dflex-card-price-color, var(--dflex-color-primary));
    display: flex;
    flex-direction: row;
    line-height: 1.2;
    align-items: flex-end;
    justify-content: flex-start;
    margin-top: 5px;
}

.dflex-search-item-price del {
    color: var(--dflex-color-text-muted, #999);
    font-size: 13px;
    font-weight: 400;
    text-decoration: line-through;
    opacity: 0.8;
}

.dflex-search-item-price ins {
    text-decoration: none;
    font-weight: var(--dflex-card-price-weight, 500);
    color: var(--dflex-card-price-color, var(--dflex-color-primary));
}

.dflex-search-item-price .dflex-price-from {
    font-size: 13px;
    font-weight: 500;
    color: var(--dflex-color-text-muted, #888);
    margin-bottom: 2px;
}

.dflex-search-item-action {
    flex-shrink: 0;
}

.dflex-search-item-action .added_to_cart {
    display: none !important;
}

.dflex-search-add {
    background: var(--dflex-btn-bg, var(--dflex-color-primary, #E53935));
    color: var(--dflex-btn-text, #fff);
    border: var(--dflex-btn-border, none);
    border-radius: var(--dflex-btn-radius, 43px);
    height: 38px;
    padding: 0 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    min-width: 110px;
}

.dflex-search-add:hover {
    background: var(--dflex-btn-hover-bg, var(--dflex-color-primary-hover, #c62828));
    color: var(--dflex-btn-hover-text, #fff);
    border: var(--dflex-btn-border-hover, none);
}

.dflex-search-add.is-added {
    background: var(--dflex-color-success, #4CAF50) !important;
}

/* Empty / Show All states */
.dflex-search-empty {
    padding: 60px 20px;
    text-align: center;
    color: #888;
    background: #fff;
    border-radius: 12px;
    border: 1px solid #eee;
}

.dflex-search-show-all {
    display: block;
    text-align: center;
    padding: 18px;
    background: var(--dflex-btn-bg, #f9f9f9);
    color: var(--dflex-btn-text, var(--dflex-color-primary, #E53935));
    border: var(--dflex-btn-border, 1px solid #eee);
    border-radius: var(--dflex-btn-radius, 12px);
    height: auto;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.dflex-search-show-all:hover {
    background: var(--dflex-btn-hover-bg, #fff);
    color: var(--dflex-btn-hover-text, var(--dflex-color-primary, #E53935));
    border: var(--dflex-btn-border-hover, 1px solid var(--dflex-color-primary, #E53935));
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .dflex-search-modal {
        top: 40px;
        width: 92%;
    }

    .dflex-search-form-modal input {
        font-size: 24px;
    }

    .dflex-search-modal-icon-left {
        font-size: 20px;
        margin-right: 12px;
    }

    .dflex-search-item {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .dflex-search-item-info {
        padding-right: 0;
    }

    .dflex-search-add {
        width: 100%;
    }

    .dflex-search-results-modal {
        max-height: calc(100vh - 60px - 80px);
    }
}