/* Premium Smart Search Styles - Black & Orange Theme with Original Dimensions */
/* Keeping original layout/sizing from paste 1, applying colors from paste 2 */

.compact-smart-search {
    background: linear-gradient(135deg, var(--theme-black) 0%, var(--theme-dark-gray) 100%);
    padding: 20px 0;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

/* Subtle geometric pattern overlay */
.compact-smart-search::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 25% 25%, rgba(241, 90, 41, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(241, 90, 41, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.compact-search-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50px;
    padding: 8px 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

.compact-search-wrapper:hover,
.compact-search-wrapper:focus-within {
    background: rgba(255, 255, 255, 1);
    box-shadow:
        0 8px 25px rgba(0,0,0,0.15),
        0 0 0 2px rgba(241, 90, 41, 0.1);
}

.search-icon {
    color: var(--theme-orange);
    font-size: 1.2rem;
    margin-right: 12px;
    transition: all 0.3s ease;
}

.compact-search-wrapper:focus-within .search-icon {
    transform: scale(1.1);
    color: var(--theme-orange-dark);
}

.compact-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    padding: 8px 0;
    color: var(--theme-dark-gray);
}

.compact-search-input::placeholder {
    color: #888;
    font-weight: 400;
}

.compact-search-btn {
    background: linear-gradient(135deg, var(--theme-orange) 0%, var(--theme-orange-dark) 100%);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(241, 90, 41, 0.3);
    position: relative;
    overflow: hidden;
}

.compact-search-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.compact-search-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(241, 90, 41, 0.4);
}

.compact-search-btn:hover::before {
    left: 100%;
}

.search-suggestions {
    text-align: center;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.suggestion-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    margin: 0 5px 5px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.suggestion-tag:hover {
    background: rgba(255, 255, 255, 0.9);
    color: var(--theme-orange);
    transform: translateY(-1px);
}

/* Expandable Chat Styles */
.expandable-chat {
    display: none;
    background: white;
    border-top: 1px solid #e1e5e9;
    animation: slideDown 0.3s ease-out;
}

.expandable-chat.show {
    display: block;
}

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

.chat-container {
    background: white;
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-weight: 600;
    color: var(--theme-dark-gray);
    flex: 1;
}

.close-chat-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-chat-btn:hover {
    background: #e9ecef;
    color: var(--theme-orange);
}

.chat-content {
    max-height: 500px;
    overflow-y: auto;
}

.chat-messages {
    padding: 20px;
    min-height: 100px;
}

.search-results {
    padding: 0 20px 20px;
}

.chat-input-area {
    border-top: 1px solid #e1e5e9;
    padding: 15px 20px;
    background: #f8f9fa;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: white;
    border-radius: 25px;
    padding: 8px 15px;
    border: 1px solid #e1e5e9;
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--theme-orange);
    box-shadow: 0 0 0 3px rgba(241, 90, 41, 0.1);
}

.follow-up-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 8px 0;
    font-size: 0.95rem;
}

.send-follow-up-btn {
    background: linear-gradient(135deg, var(--theme-orange) 0%, var(--theme-orange-dark) 100%);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(241, 90, 41, 0.3);
}

.send-follow-up-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(241, 90, 41, 0.4);
}

/* Message Styles */
.ai-message {
    margin-bottom: 15px;
}

.message-content {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 15px 15px 15px 5px;
    color: var(--theme-dark-gray);
    line-height: 1.5;
}

.user-message {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    margin-bottom: 1rem;
    margin-left: auto;
    width: fit-content;  /* Add this back */
    max-width: 60%;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--theme-orange) 0%, var(--theme-orange-dark) 100%);
    color: white;
    border-radius: 15px 15px 5px 15px;
    /* Remove display: inline-block and max-width: 80% */
    box-shadow: 0 4px 12px rgba(241, 90, 41, 0.25);
    word-wrap: break-word;
    word-break: break-word;
}

/* Results Grid (Medium Smaller Version) */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.result-card {
    border: 1px solid #e1e5e9;
    border-radius: 7px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
}

.result-card:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    border-color: var(--theme-orange);
}

.result-image {
    width: 100%;
    height: 110px;
    object-fit: cover;
}

.result-content {
    padding: 9px;
}

.result-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--theme-dark-gray);
    font-size: 0.65rem;
}

.result-price {
    color: var(--theme-orange);
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 0.75rem;
}

.result-meta {
    font-size: 0.6rem;
    color: #6c757d;
}

/* Animation classes that can be added dynamically */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    background-color: var(--theme-orange);
    display: inline-block;
    margin-right: 2px;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Fade in animation for suggestion tags */
.suggestion-tag {
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: both;
}

.suggestion-tag:nth-child(1) { animation-delay: 0.1s; }
.suggestion-tag:nth-child(2) { animation-delay: 0.2s; }
.suggestion-tag:nth-child(3) { animation-delay: 0.3s; }
.suggestion-tag:nth-child(4) { animation-delay: 0.4s; }

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

/* Focus states for accessibility */
.compact-search-btn:focus,
.send-follow-up-btn:focus,
.close-chat-btn:focus {
    outline: 2px solid var(--theme-orange);
    outline-offset: 2px;
}

.suggestion-tag:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .compact-smart-search {
        padding: 15px 0;
        border-radius: 15px;
    }

    .compact-search-wrapper {
        padding: 6px 12px;
    }

    .compact-search-input {
        font-size: 0.9rem;
    }

    .search-suggestions {
        margin-top: 10px;
    }

    .suggestion-tag {
        font-size: 0.8rem;
        padding: 3px 8px;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 10px;
    }

    .chat-header {
        padding: 12px 15px;
    }

    .chat-messages {
        padding: 15px;
    }

    .search-results {
        padding: 0 15px 15px;
    }

    .chat-input-area {
        padding: 12px 15px;
    }
}

/* Add to your smart-search-chat.css or main CSS */

.expandable-chat {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-content {
    /* Prevent layout shift during content updates */
    min-height: 200px;
    overflow-anchor: none; /* Disable scroll anchoring that causes jumps */
}

.chat-messages {
    /* Smooth scrolling behavior */
    scroll-behavior: smooth;
    overflow-y: auto;
    /* Prevent content jumping */
    scrollbar-gutter: stable;
}

.search-results {
    /* Prevent layout shifts when results load */
    will-change: contents;
    contain: layout style;
}

.results-grid {
    /* Optimize for dynamic content */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    /* Prevent grid recalculation jumps */
    grid-auto-rows: minmax(auto, max-content);
}

.result-card {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: calc(var(--i) * 0.05s);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card:nth-child(1) { animation-delay: 0.05s; }
.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.15s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px) translateZ(0);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}