/**
 * Smort WooCommerce Custom Search Styles
 *
 * @package Smort_WooCommerce_Custom_Search
 * @since 2.0
 */

/* Search Trigger Styles */
.swcs-search-trigger {
    display: inline-block;
    padding: 10px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    line-height: 1.5;
    box-sizing: border-box;
}

/* Style 1 - Simple */
.swcs-search-trigger.swcs-trigger-style1 {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid #000;
    text-align: left;
    padding-left: 20px;
}

/* Style 2 - Bordered */
.swcs-search-trigger.swcs-trigger-style2 {
    background-color: transparent;
    border: 1px solid #000;
    border-radius: 4px;
    text-align: left;
    padding-left: 20px;
}

/* Style 3 - Button */
.swcs-search-trigger.swcs-trigger-style3 {
    background-color: #000; /* Kommer att ersättas av dynamisk CSS */
    color: #fff;
    border: none;
    border-radius: 4px; /* Kommer att ersättas av dynamisk CSS */
    text-align: center;
}

/* Style 4 - Icon Only */
.swcs-search-trigger.swcs-trigger-style4 {
    background-color: transparent;
    border: none;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swcs-search-trigger.swcs-trigger-style4 svg {
    width: 24px;
    height: 24px;
    fill: #000;
}

/* Width Classes */
.swcs-search-trigger.swcs-width-25 {
    width: 25%;
}

.swcs-search-trigger.swcs-width-50 {
    width: 50%;
}

.swcs-search-trigger.swcs-width-75 {
    width: 75%;
}

.swcs-search-trigger.swcs-width-100 {
    width: 100%;
}

/* Search Overlay */
.swcs-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.98);
    z-index: 999999;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.swcs-search-overlay.active {
    display: flex;
    opacity: 1;
}

/* Body class when overlay is open */
body.swcs-overlay-open {
    overflow: hidden;
}

/* Search Bar */
.swcs-search-bar {
    width: 100%;
    padding: 20px;
    background-color: #000;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    border-bottom: 1px solid #000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Search Input */
#swcs_search_input {
    width: 80%;
    padding: 15px 20px;
    font-size: 20px;
    border: none;
    border-radius: 30px; /* Kommer att ersättas av dynamisk CSS */
    background-color: #fff;
    color: #333;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#swcs_search_input:focus {
    outline: none;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
    width: 85%;
}

/* Close Button */
.swcs-search-close {
    position: absolute;
    top: 50%;
    right: 40px;
    transform: translateY(-50%);
    font-size: 30px;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
}

.swcs-search-close:hover {
    color: #fff;
    background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

/* Popular Searches */
.swcs-popular-searches {
    padding: 20px 15px;
    background-color: #fff;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    border-bottom: 1px solid #eee;
}

.swcs-popular-searches p {
    margin: 0;
    padding: 0;
}

.swcs-popular-search {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    border: 1px solid #000;
    border-radius: 20px; /* Kommer att ersättas av dynamisk CSS */
    color: #000;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
}

.swcs-popular-search:hover {
    background-color: #000; /* Kommer att ersättas av dynamisk CSS */
    color: #fff;
}

/* Search Results */
.swcs-search-results {
    width: 100%;
    padding: 20px;
    background-color: #fff;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* Loading Spinner */
.swcs-loading {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px 0;
}

.swcs-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #000;
    animation: swcs-spin 1s ease-in-out infinite;
}

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

/* Search Results Container */
.swcs-search-results-container {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.swcs-search-results-container::after {
    content: "";
    display: table;
    clear: both;
}

/* Clearfix för att hantera flytande element */
.swcs-products-column::after {
    content: "";
    display: table;
    clear: both;
}

/* Category Filter */
.swcs-categories-column {
    width: 25%;
    float: left;
    background-color: #fff;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.swcs-categories-column h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.swcs-categories-list {
    margin-bottom: 20px;
}

.swcs-categories-list label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 5px 0;
    flex-grow: 1;
}

.swcs-category-item {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 5px;
    position: relative;
}

.swcs-category-toggle {
    margin-left: 5px;
    cursor: pointer;
    font-weight: bold;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #f0f0f0;
    font-size: 14px;
    line-height: 1;
}

.swcs-subcategories {
    width: 100%;
    padding-left: 10px;
}

.swcs-categories-list label:hover {
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-category-checkbox {
    margin-right: 10px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    outline: none;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.swcs-category-checkbox:checked {
    background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
    border-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-category-checkbox:checked:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.swcs-clear-categories {
    background-color: transparent;
    border: 1px solid #ad0000; /* Kommer att ersättas av dynamisk CSS */
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
    padding: 8px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 20px; /* Kommer att ersättas av dynamisk CSS */
    font-size: 14px;
    font-weight: 500;
    width: 100%; /* Täck hela bredden */
    text-align: center;
}

.swcs-clear-categories:hover {
    background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
    color: #fff;
}

/* Products Column */
.swcs-products-column {
    width: 100%;
    float: left;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    margin: 0; /* Kommer att ersättas av dynamisk CSS */
}

/* När kategorifiltret är aktivt */
.swcs-has-category-filter .swcs-products-column {
    width: 75%;
    padding-left: 20px;
}

/* No Products Message */
.swcs-no-products {
    width: 100%;
    padding: 50px 0;
    text-align: center;
    font-size: 18px;
    color: #666;
    background-color: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}

/* Product Card - Grid Layout */
.swcs-layout-layout1 .swcs-product-card {
    width: calc(25% - 15px); /* Kommer att ersättas av dynamisk CSS */
    margin-bottom: 20px;
    box-sizing: border-box;
    float: left;
    padding: 0; /* Kommer att ersättas av dynamisk CSS */
    margin: 7.5px; /* Kommer att ersättas av dynamisk CSS */
}

/* Justera antalet produkter per rad när kategorifiltret är aktivt */
.swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
    width: calc(33.333% - 15px); /* Kommer att ersättas av dynamisk CSS */
}

.swcs-product-grid {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 8px; /* Kommer att ersättas av dynamisk CSS */
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 350px; /* Fixerad höjd för alla kort */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.swcs-product-grid:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
}

.swcs-product-grid a {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.swcs-product-grid .swcs-product-image {
    height: 180px;
    overflow: hidden;
    background-color: #f9f9f9; /* Kommer att ersättas av dynamisk CSS */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.swcs-product-grid .swcs-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.swcs-product-grid:hover .swcs-product-image img {
    transform: scale(1.05);
}

.swcs-product-grid .swcs-product-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
}

.swcs-product-grid .swcs-product-title h2 {
    font-size: 16px;
    font-weight: bold;
    margin: 0 0 10px;
    color: #333;
    line-height: 1.4;
    min-height: 45px;
    max-height: 45px;
    overflow: hidden;
    transition: color 0.3s ease;
}

.swcs-product-grid:hover .swcs-product-title h2 {
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-product-grid .swcs-product-sku {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.swcs-product-grid .swcs-product-price {
    margin-top: auto;
    font-weight: bold;
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
    font-size: 18px;
}

/* Product Card - List Layout */
.swcs-layout-layout2 .swcs-product-card {
    width: 100%;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.swcs-product-list {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
}

.swcs-product-list:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.swcs-product-list a {
    display: flex;
    width: 100%;
}

.swcs-product-list .swcs-product-image {
    width: 200px;
    min-width: 200px;
    height: 200px;
    overflow: hidden;
}

.swcs-product-list .swcs-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.swcs-product-list .swcs-product-content {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.swcs-product-list .swcs-product-title h2 {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 10px;
    color: #333;
    line-height: 1.4;
}

.swcs-product-list .swcs-product-sku {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.swcs-product-list .swcs-product-excerpt {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
    line-height: 1.5;
}

.swcs-product-list .swcs-product-price {
    margin-top: auto;
    font-weight: bold;
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

/* Product Card - Compact Layout */
.swcs-layout-layout3 .swcs-product-card {
    width: calc(33.33% - 14px);
    margin-bottom: 20px;
    box-sizing: border-box;
}

.swcs-product-compact {
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.swcs-product-compact:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
}

.swcs-product-compact .swcs-product-image {
    height: 150px;
    overflow: hidden;
}

.swcs-product-compact .swcs-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.swcs-product-compact .swcs-product-content {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.swcs-product-compact .swcs-product-title h2 {
    font-size: 14px;
    font-weight: bold;
    margin: 0 0 5px;
    color: #333;
    line-height: 1.3;
    min-height: 36px;
}

.swcs-product-compact .swcs-product-price {
    margin-top: auto;
    font-weight: bold;
    color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
    font-size: 14px;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    .swcs-layout-layout1 .swcs-product-card {
        width: calc(33.33% - 14px);
    }

    .swcs-layout-layout3 .swcs-product-card {
        width: calc(50% - 10px);
    }
}

@media (max-width: 992px) {
    .swcs-layout-layout1 .swcs-product-card {
        width: calc(50% - 10px);
    }

    .swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
        width: calc(50% - 10px);
    }

    .swcs-categories-column {
        width: 30%;
    }

    .swcs-has-category-filter .swcs-products-column {
        width: 70%;
    }

    .swcs-product-list .swcs-product-image {
        width: 150px;
        min-width: 150px;
        height: 150px;
    }

    #swcs_search_input {
        width: 75%;
    }
}

@media (max-width: 768px) {
    .swcs-layout-layout1 .swcs-product-card,
    .swcs-layout-layout3 .swcs-product-card,
    .swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
        width: 100%;
    }

    .swcs-search-results-container {
        flex-direction: column;
    }

    .swcs-categories-column {
        width: 100%;
        float: none;
        max-height: none;
        margin-bottom: 20px;
    }

    .swcs-products-column,
    .swcs-has-category-filter .swcs-products-column {
        width: 100%;
        float: none;
        padding-left: 0;
    }

    .swcs-product-list a {
        flex-direction: column;
    }

    .swcs-product-list .swcs-product-image {
        width: 100%;
        height: 200px;
    }

    #swcs_search_input {
        width: 80%;
        font-size: 16px;
        padding: 12px 15px;
    }

    .swcs-search-close {
        right: 15px;
        width: 35px;
        height: 35px;
        font-size: 24px;
    }

    .swcs-search-bar {
        padding: 15px;
    }

    .swcs-popular-searches {
        padding: 15px 10px;
    }

    .swcs-popular-search {
        padding: 6px 12px;
        font-size: 13px;
        margin: 3px;
    }
}

@media (max-width: 480px) {
    #swcs_search_input {
        width: 75%;
        font-size: 14px;
    }

    .swcs-search-close {
        right: 10px;
        width: 30px;
        height: 30px;
        font-size: 20px;
    }

    .swcs-product-grid .swcs-product-image {
        height: 180px;
    }

    .swcs-product-grid .swcs-product-title h2 {
        font-size: 14px;
        min-height: 40px;
    }

    .swcs-product-grid .swcs-product-price {
        font-size: 16px;
    }

    .swcs-categories-column {
        padding: 15px;
    }

    .swcs-categories-column h3 {
        font-size: 16px;
    }
}
