/**
 * Gorilla Search Frontend Styles
 * Icon-as-Button Design with Customizable Presets
 *
 * @package Gorilla_Search
 * @version 0.0.18
 */

/* ============================================
   SEARCH FORM WRAPPER
   ============================================ */
.gorilla-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    /* overflow: hidden removed - allows autocomplete dropdown to display */
}

/* ============================================
   SEARCH FORM
   ============================================ */
.gorilla-search-form {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch;
    position: relative;
    width: 100%;
    overflow: hidden;        /* Clips input/button borders for clean rounded corners */
    border-radius: 6px;      /* Rounded corners for the entire search form */
}

/* ============================================
   SEARCH INPUT
   ============================================ */
.gorilla-search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: none !important;
    padding: 12px 60px 12px 16px !important; /* Right padding for icon button */
    font-size: 15px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd !important;
    border-right: none !important; /* No border on right where button connects */
    border-radius: 6px 0 0 6px !important; /* Rounded left, square right for button connection */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* ============================================
   INPUT STATES
   ============================================ */
.gorilla-search-input:focus {
    outline: none !important;
    border-color: #4A89DD !important;
    box-shadow: 0 0 0 3px rgba(74, 137, 221, 0.1), 0 2px 8px rgba(0,0,0,0.08);
}

/* ============================================
   ICON BUTTON (RIGHT SIDE - ICON-AS-BUTTON DESIGN)
   ============================================ */
.gorilla-search-submit {
    position: absolute !important;
    right: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    width: 50px;
    min-width: 50px;
    padding: 0 !important;
    margin: 0 !important;
    background-color: #4482d5;
    background-image: none;
    border: none !important;
    border-radius: 0 6px 6px 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.gorilla-search-submit:hover {
    background-color: #376fc3;
    background-image: none;
    opacity: 1;
}

.gorilla-search-submit:active {
    background-color: #3068bb;
    background-image: none;
    opacity: 0.8;
}

.gorilla-search-submit:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 137, 221, 0.2);
}

/* ============================================
   SEARCH ICON (INSIDE BUTTON)
   ============================================ */
.gorilla-search-icon {
    width: 18px;
    height: 18px;
    stroke: #fff;
    fill: none;
    display: block;
    margin: auto;
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */
.gorilla-search-autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08);
    max-height: 480px;
    overflow-y: auto;
    z-index: 9999;
}

.gorilla-search-autocomplete.open {
    display: block;
    animation: fadeInDown 0.2s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.gorilla-search-loading {
    padding: 24px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* ============================================
   RESULTS LIST
   ============================================ */
.gorilla-search-results {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

/* ============================================
   RESULT ITEM
   ============================================ */
.gorilla-search-result {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.gorilla-search-result:last-child {
    border-bottom: none;
}

.gorilla-search-result:hover,
.gorilla-search-result.selected {
    background-color: #f8f9fa;
}

.gorilla-search-result:hover .gorilla-search-result-title {
    color: #4A89DD;
}

/* ============================================
   RESULT IMAGE
   ============================================ */
.gorilla-search-result-image {
    flex-shrink: 0;
    margin-right: 14px;
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    background-color: #f5f5f5;
}

.gorilla-search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================
   RESULT CONTENT
   ============================================ */
.gorilla-search-result-content {
    flex: 1;
    min-width: 0;
}

/* ============================================
   RESULT TITLE
   ============================================ */
.gorilla-search-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #23282d;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s ease;
}

/* ============================================
   RESULT EXCERPT
   ============================================ */
.gorilla-search-result-excerpt {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 6px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ============================================
   RESULT PRICE
   ============================================ */
.gorilla-search-result-price {
    margin-top: 6px;
    font-size: 15px;
    font-weight: 700;
    color: #4A89DD;
}

.gorilla-search-result-price del {
    color: #999;
    font-weight: 400;
    font-size: 13px;
    margin-right: 6px;
}

.gorilla-search-result-price ins {
    text-decoration: none;
    color: #d32f2f;
}

/* ============================================
   NO RESULTS / ERROR STATES
   ============================================ */
.gorilla-search-no-results,
.gorilla-search-error {
    padding: 32px 24px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.gorilla-search-error {
    color: #d32f2f;
}

/* ============================================
   FOOTER (TOTAL RESULTS COUNT)
   ============================================ */
.gorilla-search-footer {
    padding: 12px 16px;
    border-top: 1px solid #f5f5f5;
    text-align: center;
    background: #fafafa;
}

.gorilla-search-view-all {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    color: #4A89DD;
    text-decoration: none;
    transition: color 0.15s ease;
}

.gorilla-search-view-all:hover {
    color: #376fc3;
    text-decoration: underline;
}

.gorilla-search-stats {
    font-size: 13px;
    color: #666;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .gorilla-search-autocomplete {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin-top: 0;
        max-height: 70vh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
    }

    .gorilla-search-wrapper {
        max-width: 100%;
    }

    .gorilla-search-input {
        padding: 10px 50px 10px 14px !important;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .gorilla-search-submit {
        width: 45px;
        min-width: 45px;
    }

    .gorilla-search-icon {
        width: 16px;
        height: 16px;
    }

    .gorilla-search-result {
        padding: 10px 14px;
    }

    .gorilla-search-result-image {
        width: 56px;
        height: 56px;
        margin-right: 12px;
    }

    .gorilla-search-result-title {
        font-size: 14px;
    }

    .gorilla-search-result-excerpt {
        font-size: 12px;
    }

    .gorilla-search-result-price {
        font-size: 14px;
    }
}

/* ============================================
   INSTANT SEARCH MODE (FULL PAGE)
   ============================================ */
.gorilla-instant-search {
    padding: 24px;
}

.gorilla-instant-search-header {
    margin-bottom: 24px;
}

.gorilla-instant-search-results {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 24px;
}

@media (max-width: 992px) {
    .gorilla-instant-search-results {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .gorilla-instant-search {
        padding: 16px;
    }

    .gorilla-instant-search-results {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ============================================
   WOOCOMMERCE SPECIFIC STYLES
   ============================================ */
.woocommerce .gorilla-search-result-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.woocommerce .gorilla-search-result-price .sale {
    color: #d32f2f;
}

.woocommerce .gorilla-search-result-price del {
    color: #999;
    font-weight: 400;
}

/* ============================================
   SCROLLBAR STYLING (WEBKIT)
   ============================================ */
.gorilla-search-autocomplete::-webkit-scrollbar {
    width: 8px;
}

.gorilla-search-autocomplete::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 0 8px 8px 0;
}

.gorilla-search-autocomplete::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.gorilla-search-autocomplete::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
.gorilla-search-result:focus {
    outline: 2px solid #4A89DD;
    outline-offset: -2px;
    background-color: #f8f9fa;
}

/* ============================================
   RTL SUPPORT
   ============================================ */
.rtl .gorilla-search-submit {
    right: auto;
    left: 0;
    border-radius: 6px 0 0 6px !important;
}

.rtl .gorilla-search-input {
    padding: 12px 16px 12px 60px !important;
    border-radius: 0 6px 6px 0 !important; /* Rounded right, square left for RTL */
}

.rtl .gorilla-search-result-image {
    margin-right: 0;
    margin-left: 14px;
}

/* ============================================
   DESIGN PRESETS
   ============================================ */

/* Modern Blue (default - already applied above) */
.gs-preset-modern-blue .gorilla-search-submit {
    background-color: #4482d5;
    background-image: none;
}

.gs-preset-modern-blue .gorilla-search-submit:hover {
    background-color: #376fc3;
    background-image: none;
}

/* Professional Dark */
.gs-preset-professional-dark .gorilla-search-submit {
    background-color: #333;
    background-image: none;
}

.gs-preset-professional-dark .gorilla-search-submit:hover {
    background-color: #444;
    background-image: none;
}

/* Minimal Light */
.gs-preset-minimal-light .gorilla-search-submit {
    background-color: #f5f5f5;
    background-image: none;
}

.gs-preset-minimal-light .gorilla-search-submit:hover {
    background-color: #e0e0e0;
    background-image: none;
}

.gs-preset-minimal-light .gorilla-search-icon {
    stroke: #333; /* Dark icon on light background */
}

/* Triangle Decoration */
.gs-show-triangle .gorilla-search-submit:before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 8px 0;
    border-color: transparent #4482d5 transparent transparent;
    outline: none !important;
    box-shadow: none !important;
    background: none !important;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    transition: border-color 0.2s ease;
}

/* Triangle hover for Modern Blue (default) */
.gs-preset-modern-blue.gs-show-triangle .gorilla-search-submit:hover:before,
.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent #376fc3 transparent transparent;
}

/* Triangle for Professional Dark preset */
.gs-preset-professional-dark.gs-show-triangle .gorilla-search-submit:before {
    border-color: transparent #333 transparent transparent;
}

.gs-preset-professional-dark.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent #444 transparent transparent;
}

/* Triangle for Minimal Light preset */
.gs-preset-minimal-light.gs-show-triangle .gorilla-search-submit:before {
    border-color: transparent #f5f5f5 transparent transparent;
}

.gs-preset-minimal-light.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent #e0e0e0 transparent transparent;
}

/* RTL Triangle positioning */
.rtl.gs-show-triangle .gorilla-search-submit:before {
    left: auto;
    right: -8px;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent #4482d5;
}

/* RTL Triangle hover for Modern Blue (default) */
.rtl.gs-preset-modern-blue.gs-show-triangle .gorilla-search-submit:hover:before,
.rtl.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent transparent transparent #376fc3;
}

.rtl.gs-preset-professional-dark.gs-show-triangle .gorilla-search-submit:before {
    border-color: transparent transparent transparent #333;
}

.rtl.gs-preset-professional-dark.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent transparent transparent #444;
}

.rtl.gs-preset-minimal-light.gs-show-triangle .gorilla-search-submit:before {
    border-color: transparent transparent transparent #f5f5f5;
}

.rtl.gs-preset-minimal-light.gs-show-triangle .gorilla-search-submit:hover:before {
    border-color: transparent transparent transparent #e0e0e0;
}

/* ============================================
   BUTTON STYLES
   ============================================ */

/* Text Only Button */
.gs-button-text .gorilla-search-submit {
    width: auto;
    min-width: 70px;
    padding: 0 16px !important;
    font-size: 14px;
    font-weight: 600;
}

.gs-button-text .gorilla-search-icon {
    display: none;
}

/* Icon + Text Button */
.gs-button-icon-text .gorilla-search-submit {
    width: auto;
    min-width: 90px;
    padding: 0 16px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.gs-button-icon-text .gorilla-search-icon {
    margin: 0;
}

/* Update input padding for text/icon+text buttons (they're wider) */
.gs-button-text .gorilla-search-input {
    padding-right: 90px !important;
}

.gs-button-icon-text .gorilla-search-input {
    padding-right: 110px !important;
}

/* Mobile adjustments for text buttons */
@media (max-width: 768px) {
    .gs-button-text .gorilla-search-submit {
        min-width: 60px;
        padding: 0 12px !important;
        font-size: 13px;
    }

    .gs-button-icon-text .gorilla-search-submit {
        min-width: 75px;
        padding: 0 12px !important;
        font-size: 13px;
        gap: 6px;
    }

    .gs-button-text .gorilla-search-input {
        padding-right: 75px !important;
    }

    .gs-button-icon-text .gorilla-search-input {
        padding-right: 90px !important;
    }
}
