/**
 * ES Search Widget Styles
 * 
 * @package EsSearch
 * @version 1.0.0
 */

/* ============================================
   WIDGET CONTAINER
   ============================================ */
.es-search-widget {
    width: 100%;
    max-width: 100%;
    position: relative;
}
button.es-search-button {
    display: none;
}
input.es-search-input {
    border-radius: 16px;
    border: 0;
}
/* ============================================
   FORM
   ============================================ */
.es-search-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
    width: 100%;
}

/* ============================================
   INPUT WRAPPER
   ============================================ */
.es-search-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    border: 4px solid transparent;
    border-radius: 16px;
    background-image: linear-gradient(white, white), linear-gradient(90deg, rgba(118, 184, 42, 0.8) 0%, rgba(0, 140, 210, 0.9) 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

/* ============================================
   SEARCH ICON
   ============================================ */
.es-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    z-index: 2;
    font-size: 16px;
}

.es-search-input-wrapper .es-search-icon + .es-search-input {
    padding-left: 45px;
}

/* ============================================
   INPUT
   ============================================ */
.es-search-input {
    width: 100%;
    height: 50px;
    padding: 0 45px 0 15px;
    font-size: 16px;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.es-search-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.es-search-input::placeholder {
    color: #999;
}

/* ============================================
   CLEAR BUTTON
   ============================================ */
.es-search-clear {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    line-height: 1;
    z-index: 2;
    transition: color 0.3s ease;
}

.es-search-clear:hover {
    color: #333;
}

/* ============================================
   SUBMIT BUTTON
   ============================================ */
.es-search-button {
    padding: 0 30px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background-color: #0073aa;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    height: 50px;
    line-height: 1;
}

.es-search-button:hover {
    background-color: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.es-search-button:active {
    transform: translateY(0);
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */
.es-recent-searches,
.es-search-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 5px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}
.es-recent-searches::-webkit-scrollbar,
.es-search-autocomplete::-webkit-scrollbar {
    width: 8px;
}
.es-recent-searches::-webkit-scrollbar-track,
.es-search-autocomplete::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 5px 5px 0;
}
.es-recent-searches::-webkit-scrollbar-thumb,
.es-search-autocomplete::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}
.es-recent-searches::-webkit-scrollbar-thumb:hover,
.es-search-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.es-recent-searches {
    padding: 1.5rem;
    display: none;
}
.es-search-autocomplete {
    display: block;
    padding: 1.5rem;
}
.es-search-autocomplete .no-results {
    padding: 24px;
    text-align: center;
    color: #666;
    font-size: 14px;
}
.es-search-autocomplete .es-search-view-all {
    display: none;
    background: #f0fbff !important;
    padding: 8px 16px;
    border-radius: 18px;
    font-weight: bold;
    color: #008CD2 !important;
    display: flex;
    justify-content: space-between;
}

/* ============================================
   AUTOCOMPLETE ITEMS
   ============================================ */

.es-search-autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    text-align: left;
}
.es-recent-searches-list:last-child,
.es-search-autocomplete-item:last-child {
    border-bottom: none;
}

.es-recent-search-item:hover,
.es-recent-search-item.active,
.es-search-autocomplete-item:hover,
.es-search-autocomplete-item.active {
    background-color: #0073aa;
    color: #fff;
}


.es-search-autocomplete-item:hover .es-search-autocomplete-type,
.es-search-autocomplete-item.active .es-search-autocomplete-type {
    color: rgba(255, 255, 255, 0.8);
}

.es-recent-searches-title {
    text-align: left;
    color: #1F2937;
    margin: 15px 0;
    letter-spacing: 0.5px;
}
.es-recent-searches-list .es-recent-search-item {
    border-radius: 0;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #D1D5DB;
    text-align: left;
    padding: 10px 5px;
}
.es-search-autocomplete-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    line-height: 1.4;
}

.es-search-autocomplete-type {
    font-size: 12px;
    color: #666;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.es-recent-searches-list {
    display: block;
    width: 100%;
}
.es-search-autocomplete-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h3.es-search-type-title {
    text-align: left;
    color: #1F2937;
    margin: 15px 0;
    letter-spacing: 0.5px;
    font-size: 18px !important;
    line-height: 26px !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .es-search-form {
        flex-direction: column;
        gap: 10px;
    }
    
    .es-search-button {
        width: 100%;
        padding: 15px 30px;
    }
    
    .es-search-input {
        font-size: 16px; /* Evitar zoom en iOS */
    }
}

@media (max-width: 480px) {
    .es-search-icon {
        left: 12px;
        font-size: 14px;
    }
    
    .es-search-input-wrapper .es-search-icon + .es-search-input {
        padding-left: 40px;
    }
    
    .es-search-input {
        height: 45px;
        padding: 0 40px 0 12px;
        font-size: 14px;
    }
    
    .es-search-clear {
        right: 12px;
        font-size: 14px;
    }
    
    .es-search-button {
        height: 45px;
        font-size: 15px;
    }
    
    .es-search-autocomplete-item {
        padding: 10px 12px;
    }
    
    .es-search-autocomplete-title {
        font-size: 13px;
    }
    
    .es-search-autocomplete-type {
        font-size: 11px;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.es-search-widget.loading .es-search-input,
.es-search-widget.loading .es-search-button {
    opacity: 0.6;
    pointer-events: none;
}

.es-search-widget.loading .es-search-button::after {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 10px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   ELEMENTOR EDITOR FIXES
   ============================================ */
.elementor-editor-active .es-search-autocomplete {
    pointer-events: none;
}

/* ============================================
   RTL SUPPORT
   ============================================ */
[dir="rtl"] .es-search-icon {
    left: auto;
    right: 15px;
}

[dir="rtl"] .es-search-input-wrapper .es-search-icon + .es-search-input {
    padding-left: 15px;
    padding-right: 45px;
}

[dir="rtl"] .es-search-clear {
    right: auto;
    left: 15px;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.es-search-input:focus-visible,
.es-search-button:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.es-search-autocomplete-item:focus {
    outline: none;
    background-color: #0073aa;
    color: #fff;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
