/* Search Page Styles */

.search-page {
    padding-top: 100px; /* Navbar compensation */
    padding-bottom: 80px;
}

.search-header {
    margin-bottom: 40px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.search-header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.search-header h1 {
    font-family: 'Inter', sans-serif;
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0;
}

.search-header h1 span {
    font-weight: 700;
    color: var(--text-main);
}

.result-count {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.search-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-header-right label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sort-select {
    padding: 8px 32px 8px 12px;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    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 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 180px;
}

.sort-select:hover {
    border-color: var(--primary-color);
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 95, 45, 0.1);
}

/* Admin P-index slider */
.admin-pindex {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 10px;
    background: linear-gradient(135deg, #fff3e0, #fff8e1);
    border: 1px solid #ffcc80;
    border-radius: 6px;
    font-size: 0.75rem;
}

.admin-pindex label {
    color: #e65100;
    font-weight: 600;
    white-space: nowrap;
}

.admin-pindex .pindex-value {
    display: inline-block;
    min-width: 24px;
    text-align: right;
}

.pindex-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #ffcc80;
    border-radius: 3px;
    outline: none;
    min-width: 80px;
}

.pindex-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #e65100;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

.pindex-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.pindex-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #e65100;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ============================================
   Active Filters Bar
   ============================================ */

.search-results-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.active-filters-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa, #fff);
    border: 1px solid #e9ecef;
    border-radius: 10px;
    margin-bottom: 16px;
}

.active-filters-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.active-filters-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.active-filter-chip:hover {
    border-color: var(--primary-color);
    background: #f0f7f0;
}

.active-filter-chip .filter-type {
    color: var(--text-secondary);
    font-weight: 500;
}

.active-filter-chip .filter-value {
    font-weight: 600;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.active-filter-chip .remove-filter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #e9ecef;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    color: #666;
    transition: all 0.2s ease;
    padding: 0;
}

.active-filter-chip .remove-filter:hover {
    background: #dc3545;
    color: white;
}

.clear-all-filters-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #dc3545;
    border-radius: 20px;
    color: #dc3545;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.clear-all-filters-btn:hover {
    background: #dc3545;
    color: white;
}

@media (max-width: 768px) {
    .active-filters-bar {
        padding: 10px 12px;
    }
    
    .active-filters-label {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .clear-all-filters-btn {
        margin-top: 8px;
    }
}

.search-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 40px;
    align-items: start;
}

/* Sidebar Filters */
.filters-sidebar {
    background: white;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #f0f0f0;
}

.filter-group {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-title {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-main);
}

.filter-list {
    list-style: none;
}

.filter-list li {
    margin-bottom: 10px;
}

/* Category tree styles */
.category-tree {
    margin: 0;
    padding: 0;
    list-style: none;
}

.category-item {
    margin-bottom: 0;
}

.category-parent {
    border-bottom: 1px solid #f0f0f0;
}

.category-parent:last-child {
    border-bottom: none;
}

.category-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 0;
    transition: all 0.15s ease;
}

.category-link:hover {
    background: linear-gradient(135deg, #f8faf8 0%, #f0f5f0 100%);
    color: #2C5F2D;
}

.category-link.selected {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    color: #2C5F2D;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(44, 95, 45, 0.1);
}

.category-name {
    font-size: 0.95rem;
}

.category-count {
    font-size: 0.8rem;
    color: #888;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 28px;
    text-align: center;
}

.category-link.selected .category-count {
    background: rgba(44, 95, 45, 0.15);
    color: #2C5F2D;
}

.category-children {
    list-style: none;
    padding-left: 0;
    margin: 0;
    background: transparent;
    border-radius: 0;
    overflow: hidden;
}

.category-child .category-link {
    padding: 8px 12px 8px 24px;
    font-size: 0.9rem;
    border-radius: 0;
    margin: 0;
    border-left: 3px solid transparent;
}

.category-child .category-link:hover {
    border-left-color: #c8e6c9;
    background: #f5f9f5;
}

.category-child .category-link.selected {
    border-left-color: #2C5F2D;
    background: #e8f5e9;
}

.btn-clear-category {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 12px;
    font-size: 13px;
    color: #e74c3c;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 0;
    transition: color 0.15s;
}

.btn-clear-category:hover {
    color: #c0392b;
    text-decoration: underline;
}

.checkbox-label {
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Price Range */
.price-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-input {
    font-family: 'Inter', sans-serif;
    width: 80px;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.btn-apply {
    font-family: 'Inter', sans-serif;
    padding: 8px 12px;
    background: var(--text-main);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Search Results List */
.search-results {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 16px;
    overflow: hidden;
}

.product-list-item {
    display: grid;
    grid-template-columns: 200px 1fr 1.2fr; /* Wider right column */
    background: transparent;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid #f0f0f0;
    padding: 24px;
    gap: 24px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.product-list-item:hover {
    background: #fafafa;
}

.product-list-item:last-child {
    border-bottom: none;
}

.item-image {
    height: 200px;
    background: #f9f9f9;
    border-radius: 12px;
    overflow: hidden;
}

.item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* No transform transition */
}

/* Removed image hover scale */

.item-center {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 8px;
}

.item-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem; /* Smaller font size */
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
}

.item-right {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
    gap: 12px;
}

.item-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #000;
    text-align: left; /* Left aligned */
}

.item-delivery {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--success);
    background: #f0fff4;
    padding: 8px 12px;
    border-radius: 8px;
    width: 100%; /* Full width in column */
    box-sizing: border-box;
}

.item-delivery i {
    font-size: 1.2rem;
}

.item-delivery strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 2px;
    color: var(--primary-dark);
}

.item-delivery span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.item-delivery .timer {
    color: var(--text-main);
    font-weight: 600;
}

.item-actions {
    margin-top: auto; /* Push to bottom */
    display: flex;
    gap: 8px;
}

.item-actions .btn-add-cart {
    flex: 1;
    padding: 12px 16px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: background 0.2s ease;
}

.item-actions .btn-add-cart:hover {
    background: #6c757d;
}

.item-actions .btn-add-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.item-actions .btn-details {
    padding: 12px 16px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    background: white;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    transition: all 0.2s ease;
}

.item-actions .btn-details:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Tag count in filter */
.tag-count {
    color: #999;
    font-size: 0.85em;
    margin-left: 4px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    border-top: 1px solid #f0f0f0;
}

.page-btn {
    min-width: 40px;
    height: 40px;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.page-btn:hover {
    background: #f5f5f5;
    border-color: var(--primary-color);
}

.page-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Loading & Error states */
.loading-state,
.error-state,
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

/* Filter group collapse animation */
.filter-group .filter-list {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-group.collapsed .filter-list {
    max-height: 0;
}

/* Responsive */
@media (max-width: 992px) {
    .search-layout {
        grid-template-columns: 1fr;
    }

    .filters-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .product-list-item {
        grid-template-columns: 1fr; /* Stack on mobile */
        gap: 16px;
        padding: 16px;
    }

    .item-image {
        height: 200px;
    }
    
    .item-right {
        padding-top: 0;
    }
}
