/* Search bar, search results, header search and category search. From Code Snippet #21. */
/* ================================
   SEARCH BAR STYLES
   ================================ */

.tillett-search-bar {
    background: #1a1a1a;
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.tillett-search-bar.standalone {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.tillett-search-form {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.tillett-search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.tillett-search-input {
    width: 100%;
    height: 50px;
    padding-top: 0 !important;
    padding-right: 44px !important;
    padding-bottom: 0 !important;
    padding-left: 52px !important;
    font-size: 16px;
    font-weight: 400;
    color: #fff;
    background: #2a2a2a;
    border: 2px solid #333;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    box-sizing: border-box !important;
    text-indent: 0 !important;
}

.tillett-search-input::placeholder {
    color: #888;
}

.tillett-search-input:focus {
    border-color: #F9D616;
    background: #252525;
}

.tillett-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
    transition: color 0.2s ease;
    z-index: 2;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tillett-search-input:focus ~ .tillett-search-icon,
.tillett-search-input-wrapper:focus-within .tillett-search-icon {
    color: #F9D616;
}

.tillett-search-submit {
    background: #F9D616;
    color: #000;
    border: none;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.tillett-search-submit:hover {
    background: #e5c414;
}

.tillett-search-submit:active {
    transform: scale(0.98);
}

/* Clear search button */
.tillett-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: none;
    transition: color 0.2s ease;
    z-index: 2;
    width: 18px;
    height: 18px;
    line-height: 1;
}

.tillett-search-clear svg {
    display: block;
    width: 18px;
    height: 18px;
}

.tillett-search-clear:hover {
    color: #F9D616;
}

.tillett-search-input:not(:placeholder-shown) ~ .tillett-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================
   SEARCH RESULTS SECTION
   ================================ */

.tillett-search-results {
    margin-top: 24px;
}

.tillett-search-results .products-filters-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tillett-search-results .filters-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.tillett-search-results .filters-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tillett-search-results .products-count {
    color: #aaa;
    font-size: 14px;
}

.tillett-search-results .search-query-display {
    color: #fff;
    font-size: 14px;
}

.tillett-search-results .search-query-display strong {
    color: #F9D616;
}

/* Sort dropdown */
.tillett-search-results .products-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tillett-search-results .products-sort label {
    color: #aaa;
    font-size: 14px;
}

.tillett-search-results .tillett-sort-select {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.tillett-search-results .tillett-sort-select:focus {
    border-color: #F9D616;
    outline: none;
}

/* Products grid wrapper */
.tillett-search-results .products-grid-wrapper {
    position: relative;
    min-height: 200px;
}

/* Loading state */
.tillett-search-results .products-loading {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #888;
    z-index: 10;
}

.tillett-search-results .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #F9D616;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* No results */
.tillett-search-results .no-results-found {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.tillett-search-results .no-results-found h3 {
    color: #fff;
    font-size: 20px;
    margin-bottom: 12px;
}

.tillett-search-results .no-results-found p {
    margin-bottom: 8px;
}

.tillett-search-results .no-results-found .search-suggestions {
    margin-top: 24px;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.tillett-search-results .no-results-found .search-suggestions h4 {
    color: #fff;
    font-size: 14px;
    margin-bottom: 8px;
}

.tillett-search-results .no-results-found .search-suggestions ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tillett-search-results .no-results-found .search-suggestions li {
    padding: 4px 0;
    color: #aaa;
    font-size: 13px;
}

.tillett-search-results .no-results-found .search-suggestions li::before {
    content: "•";
    color: #F9D616;
    margin-right: 8px;
}

/* Initial state - before search */
.tillett-search-results .search-initial {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.tillett-search-results .search-initial svg {
    color: #444;
    margin-bottom: 16px;
}

.tillett-search-results .search-initial h3 {
    color: #fff;
    font-size: 20px;
    margin-bottom: 8px;
}

/* Pagination */
.tillett-search-results .products-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.tillett-search-results .pagination-btn {
    background: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tillett-search-results .pagination-btn:hover {
    border-color: #F9D616;
    color: #F9D616;
}

.tillett-search-results .pagination-btn.active {
    background: #F9D616;
    color: #000;
    border-color: #F9D616;
}

.tillett-search-results .pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================
   SEARCH RESULTS GRID
   (Matches existing product grid styling)
   ================================ */

.tillett-search-results .products-grid {
    display: grid;
    gap: 24px;
}

/* ================================
   PRODUCT IMAGE FIX
   Contain with white background (respects use-cover class)
   ================================ */

/* Base wrapper styles */
.tillett-search-results .product-card-image-wrapper {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 aspect ratio */
    overflow: hidden;
}

/* Wrapper background - white for contain mode only */
.tillett-search-results .product-card-image-wrapper:not(.use-cover) {
    background: #ffffff !important;
}

/* Wrapper background - transparent for cover mode */
.tillett-search-results .product-card-image-wrapper.use-cover {
    background: transparent !important;
}

/* Base image positioning */
.tillett-search-results .product-card .product-card-image-wrapper .product-card-image,
.tillett-search-results .product-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* CONTAIN MODE (default) - for images WITHOUT use-cover class */
.tillett-search-results .product-card .product-card-image-wrapper .product-card-image:not(.use-cover),
.tillett-search-results .product-card-image:not(.use-cover) {
    background-size: contain !important;
    background-color: #ffffff !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* COVER MODE - for images WITH use-cover class */
.tillett-search-results .product-card .product-card-image-wrapper .product-card-image.use-cover,
.tillett-search-results .product-card-image.use-cover {
    background-size: cover !important;
    background-color: transparent !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
}

/* ================================
   SKELETON LOADING CARDS
   ================================ */

.tillett-search-results .skeleton-grid {
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 20px 0;
}

.tillett-search-results .skeleton-grid.columns-2 { grid-template-columns: repeat(2, 1fr); }
.tillett-search-results .skeleton-grid.columns-3 { grid-template-columns: repeat(3, 1fr); }
.tillett-search-results .skeleton-grid.columns-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 992px) {
    .tillett-search-results .skeleton-grid.columns-3,
    .tillett-search-results .skeleton-grid.columns-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .tillett-search-results .skeleton-grid { grid-template-columns: 1fr; }
}

.tillett-search-results .skeleton-card {
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.tillett-search-results .skeleton-image {
    width: 100%;
    padding-top: 100%;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: searchShimmer 1.5s infinite;
}

.tillett-search-results .skeleton-content {
    padding: 16px;
}

.tillett-search-results .skeleton-category {
    height: 12px;
    width: 60px;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: searchShimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 10px;
}

.tillett-search-results .skeleton-title {
    height: 18px;
    width: 85%;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: searchShimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.tillett-search-results .skeleton-title-2 {
    height: 18px;
    width: 55%;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: searchShimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.tillett-search-results .skeleton-price {
    height: 20px;
    width: 70px;
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: searchShimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes searchShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Show skeleton when loading */
.tillett-search-results.is-loading .skeleton-grid {
    display: grid;
}

.tillett-search-results.is-loading .products-grid {
    opacity: 0.3;
    pointer-events: none;
}

.tillett-search-results.is-loading .products-loading {
    display: none;
}

.tillett-search-results .products-grid.columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.tillett-search-results .products-grid.columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.tillett-search-results .products-grid.columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive grid */
@media (max-width: 992px) {
    .tillett-search-results .products-grid.columns-3,
    .tillett-search-results .products-grid.columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .tillett-search-results .products-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive search form */
@media (max-width: 768px) {
    .tillett-search-form {
        flex-direction: column;
    }

    .tillett-search-submit {
        justify-content: center;
    }

    .tillett-search-results .products-filters-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .tillett-search-results .filters-right {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 576px) {
    .tillett-search-bar {
        padding: 16px;
    }

    .tillett-search-input {
        height: 46px;
        padding-left: 48px !important;
        padding-right: 40px !important;
        font-size: 15px;
    }

    .tillett-search-submit {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* ================================
   HEADER SEARCH (Minimalist)
   ================================ */

.tillett-header-search {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.tillett-header-search-form {
    display: flex;
    align-items: center;
    position: relative;
}

.tillett-header-search-input {
    width: 0;
    height: 40px;
    padding: 0;
    font-size: 14px;
    font-weight: 400;
    color: #fff;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    outline: none;
    transition: width 0.3s ease, padding 0.3s ease, border-color 0.3s ease;
    box-sizing: border-box;
}

.tillett-header-search-input::placeholder {
    color: #888;
}

.tillett-header-search.expanded .tillett-header-search-input,
.tillett-header-search-input:focus {
    width: 200px;
    padding: 0 12px 0 0;
    border-bottom-color: #F9D616;
}

.tillett-header-search-btn {
    background: #000 !important;
    border: none !important;
    color: #F9D616 !important;
    cursor: pointer;
    padding: 8px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 4px;
}

.tillett-header-search-btn:hover {
    background: #000 !important;
    color: #fff !important;
}

.tillett-header-search-btn svg {
    width: 20px;
    height: 20px;
}

/* Expanded state with background */
.tillett-header-search.with-bg {
    background: #2a2a2a;
    border-radius: 20px;
    padding: 0 4px;
}

.tillett-header-search.with-bg .tillett-header-search-input {
    width: 180px;
    padding: 0 12px;
}

.tillett-header-search.with-bg .tillett-header-search-input:focus {
    width: 220px;
}

/* Icon-only trigger version */
.tillett-header-search.icon-trigger .tillett-header-search-input {
    position: absolute;
    right: 100%;
    width: 0;
    opacity: 0;
}

.tillett-header-search.icon-trigger.expanded .tillett-header-search-input {
    position: relative;
    right: auto;
    width: 200px;
    opacity: 1;
    margin-right: 8px;
}

@media (max-width: 768px) {
    .tillett-header-search.expanded .tillett-header-search-input,
    .tillett-header-search-input:focus {
        width: 150px;
    }

    .tillett-header-search.with-bg .tillett-header-search-input {
        width: 140px;
    }

    .tillett-header-search.with-bg .tillett-header-search-input:focus {
        width: 180px;
    }
}

/* ================================
   CATEGORY SEARCH
   ================================ */

.tillett-category-search {
    background: #1a1a1a;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.tillett-category-search-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tillett-category-search-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.tillett-category-search-input {
    width: 100%;
    height: 44px;
    padding-top: 0 !important;
    padding-right: 40px !important;
    padding-bottom: 0 !important;
    padding-left: 44px !important;
    font-size: 14px;
    font-weight: 400;
    color: #fff;
    background: #2a2a2a;
    border: 2px solid #333;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    box-sizing: border-box !important;
}

.tillett-category-search-input::placeholder {
    color: #888;
}

.tillett-category-search-input:focus {
    border-color: #F9D616;
    background: #252525;
}

.tillett-category-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    pointer-events: none;
    z-index: 2;
    width: 18px;
    height: 18px;
}

.tillett-category-search-input:focus ~ .tillett-category-search-icon,
.tillett-category-search-wrapper:focus-within .tillett-category-search-icon {
    color: #F9D616;
}

.tillett-category-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0;
    display: none;
    z-index: 2;
    width: 16px;
    height: 16px;
}

.tillett-category-search-clear svg {
    display: block;
    width: 16px;
    height: 16px;
}

.tillett-category-search-clear:hover {
    color: #F9D616;
}

.tillett-category-search-input:not(:placeholder-shown) ~ .tillett-category-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tillett-category-search-submit {
    background: #F9D616;
    color: #000;
    border: none;
    height: 44px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tillett-category-search-submit:hover {
    background: #e5c414;
}

.tillett-category-search-submit svg {
    width: 16px;
    height: 16px;
}

.tillett-category-search-label {
    color: #888;
    font-size: 12px;
    margin-bottom: 8px;
    display: block;
}

.tillett-category-search-label strong {
    color: #F9D616;
}

@media (max-width: 576px) {
    .tillett-category-search {
        width: 90%;
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
        padding: 12px;
        border-radius: 6px;
        margin-bottom: 16px;
        box-sizing: border-box;
    }

    .tillett-category-search-label {
        font-size: 11px;
        margin-bottom: 6px;
        line-height: 1.3;
    }

    /* Stay on one row */
    .tillett-category-search-form {
        flex-direction: row;
        gap: 6px;
        align-items: stretch;
        width: 100%;
    }

    .tillett-category-search-wrapper {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
    }

    .tillett-category-search-input {
        width: 100%;
        height: 42px;
        font-size: 14px;
        padding-left: 38px !important;
        padding-right: 32px !important;
        border-width: 1px;
    }

    .tillett-category-search-icon {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    .tillett-category-search-clear {
        right: 8px;
        width: 14px;
        height: 14px;
    }

    .tillett-category-search-clear svg {
        width: 14px;
        height: 14px;
    }

    /* Icon-only submit on mobile */
    .tillett-category-search-submit {
        height: 42px;
        width: 42px;
        padding: 0;
        flex: 0 0 42px;
        justify-content: center;
        gap: 0;
        font-size: 0;
        border-radius: 4px;
    }

    .tillett-category-search-submit svg {
        width: 18px;
        height: 18px;
    }
}
