/* --- Root Variables & Basic Setup --- */
:root {
    --primary-color: #A3C86C;
    --primary-dark: #7D9A4D;
    --background-white: #FFFFFF;
    --background-light: #F1F8E4;
    --text-color: #4F4A35;
    --text-light: #7D7B55;
    --divider-color: rgba(79, 74, 53, 0.1);
    --price-color: #FF5722;
    --skeleton-bg: #e0e0e0;
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-light);
    color: var(--text-color);
    padding-top: 60px; /* Space for the fixed header */
}

/* --- Search Page Header --- */
.search-page-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--background-white);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 100;
    box-sizing: border-box;
}

.back-link {
    font-size: 1.2rem;
    color: var(--text-color);
    text-decoration: none;
    margin-right: 15px;
}

/* ★★★ NEW V5 SEARCH STYLES ★★★ */
.search-input-wrapper.v5 {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    height: 48px; /* Set a fixed height for consistency */
}

#searchInput {
    width: 100%;
    height: 100%; /* Fill the wrapper height */
    border: 1px solid #E0E0E0;
    border-radius: 12px;
    background-color: var(--background-light);
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    padding: 0 45px 0 45px; /* Icon and clear button space */
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    caret-color: var(--primary-color);
    -webkit-appearance: none;
    box-sizing: border-box;
}

#searchInput::placeholder {
    color: transparent; /* Placeholder text is handled by animated span */
}

#searchInput:focus {
    border-color: var(--primary-color);
    background-color: var(--background-white);
    box-shadow: 0 0 0 2px rgba(163, 200, 108, 0.3);
}

/* Search Icon Positioning (Using ID for clarity) */
#search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    transition: color 0.3s ease;
    z-index: 1;
}

#searchInput:focus~#search-icon {
    color: var(--primary-color);
}

/* Animated placeholder's style */
#placeholder-container {
    position: absolute;
    left: 45px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    transition: opacity 0.2s ease;
    opacity: 1;
    white-space: nowrap;
    overflow: hidden;
    right: 45px;
}

#placeholder-container.hidden {
    opacity: 0;
}

#placeholder-text {
    color: var(--text-lighter, #888);
    font-size: 1rem;
    transition: opacity 0.4s ease-in-out;
}

/* Clear Button Positioning (Updated for new styles) */
.clear-button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) scale(0.7);
    background: none;
    border: none;
    font-size: 1.6em;
    color: var(--text-light);
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 2; /* Ensure it's above placeholder */
}

.clear-button.visible {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.clear-button:hover {
    color: var(--primary-dark);
}

/* Spinner animation added for loading state */
.fas.fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* --- Main Content & Views --- */
.search-content {
    padding: 20px;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.visible {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Suggestions Section (Recent & Trending) --- */
.search-suggestions-section {
    margin-bottom: 30px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--primary-dark);
}

.clear-recent-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.suggestions-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag {
    background-color: var(--background-white);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    border: 1px solid var(--divider-color);
    transition: all 0.3s ease;
}

.tag:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* --- Results & Message Containers --- */
.no-results-container, .error-container {
    text-align: center;
    padding: 40px 20px;
    display: none; /* Hidden by default */
}

.no-results-container img {
    max-width: 180px;
    margin-bottom: 20px;
}

.no-results-container h3, .error-container h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.no-results-container p, .error-container p {
    color: var(--text-light);
}

/* --- Results Grid & Cards --- */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.result-card {
    display: flex;
    align-items: center;
    background-color: var(--background-white);
    border-radius: 12px;
    padding: 12px;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: cardFadeIn 0.5s ease forwards;
    opacity: 0;
}

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

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.result-card-image {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 15px;
    flex-shrink: 0;
    background-color: #f0f0f0;
}

.result-card-info h4 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.result-card-info .category {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 8px;
    text-transform: capitalize;
}

.result-card-info .price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--price-color);
}

/* --- Skeleton Loader --- */
.result-card-skeleton {
    display: flex;
    background-color: var(--background-white);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.skeleton {
    background-color: var(--skeleton-bg);
    border-radius: 4px;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    50% { opacity: 0.5; }
}

.skeleton-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    margin-right: 15px;
}

.skeleton-info {
    flex-grow: 1;
    padding-top: 5px;
}

.skeleton-text {
    height: 20px;
    margin-bottom: 10px;
}

.skeleton-text.short {
    width: 60%;
    height: 15px;
}