:root {
    --bg-color: #0c0a15;
    --text-primary: #ffffff;
    --text-secondary: #948fa3;
    --accent: #5e43f3;
    --accent-glow: rgba(94, 67, 243, 0.4);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-hover: rgba(255, 255, 255, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs for Visual Aesthetics */
.blob {
    position: absolute;
    filter: blur(100px);
    z-index: -1;
    border-radius: 50%;
    animation: drift 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(94,67,243,0.5) 0%, rgba(12,10,21,0) 70%);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(236,72,153,0.3) 0%, rgba(12,10,21,0) 70%);
    bottom: -200px;
    right: -100px;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, -50px); }
}

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    z-index: 10;
}

.hero {
    text-align: center;
}

.logo {
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Glassmorphism Search Bar */
.search-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 99px;
    padding: 0.5rem;
    backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    background: rgba(255, 255, 255, 0.08);
}

.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.upload-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
}

#textInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.1rem;
    padding: 0 1rem;
}

#textInput::placeholder {
    color: rgba(148, 143, 163, 0.5);
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--text-primary);
    color: var(--bg-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* Image Preview Styles */
.image-preview {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 0.75rem;
    width: fit-content;
    animation: fadeIn 0.3s ease;
}

.preview-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#imagePreview {
    height: 60px;
    width: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.image-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
}

.remove-btn:hover {
    background: rgba(236, 72, 153, 0.2);
    color: #ec4899;
}

.hidden {
    display: none !important;
}

/* Action Bar (Info & History) */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.history-wrapper, .info-wrapper {
    position: relative;
}

.action-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-toggle-btn:hover {
    background: var(--glass-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.action-toggle-btn.active {
    background: rgba(94, 67, 243, 0.15);
    border-color: var(--accent);
    color: var(--text-primary);
}

.action-panel {
    position: absolute;
    top: calc(100% + 8px);
    width: 320px;
    background: rgba(20, 18, 30, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 200;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.history-panel {
    right: 0;
    max-height: 300px;
}

.info-panel {
    left: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.clear-btn {
    background: transparent;
    border: none;
    color: #ec4899;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(236, 72, 153, 0.15);
}

.panel-empty {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

/* History List specific */
.history-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 220px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.history-item:hover {
    background: var(--glass-hover);
}

.history-item .history-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
    opacity: 0.6;
}

.history-item .history-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .history-time {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Info Panel specific */
.panel-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.info-item strong {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.info-item p {
    margin: 0;
    padding-left: 20px;
}

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

/* Results Container & Product Gallery */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.4s ease;
}

.chat-response {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 1.5rem;
    border-radius: 16px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.product-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.product-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    border-color: var(--accent);
}

.product-img-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    background: #ffffff; /* White bg for product photos since most Amazon photos are white */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply; /* Helps transparentize white backgrounds */
}

/* XAI Badges */
.xai-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(20, 20, 20, 0.85);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.product-info {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.product-category {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #10b981; /* Nice emerald green for pricing */
    margin-top: auto;
}

.buy-btn {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: white;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.buy-btn:hover {
    background: #4630cc;
}

/* Spinner and Error Styling */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

.loading-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

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

.error-msg {
    color: #ec4899;
    font-weight: 600;
}
