/* ShopAI - Premium Interface with ChatGPT-style Sidebar */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    /* Premium Dark Theme */
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-sidebar: #171717;
    --bg-hover: #2a2a2a;
    --bg-glass: rgba(255, 255, 255, 0.05);

    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --accent-glow: rgba(99, 102, 241, 0.4);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;

    /* Functional */
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px var(--accent-glow);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   APP WRAPPER - Sidebar Layout
   ========================================= */

.app-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* =========================================
   SIDEBAR (ChatGPT Style)
   ========================================= */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: relative;
}

.sidebar-header {
    padding: 1rem;
}

.new-chat-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.15s ease;
}

.new-chat-btn:hover {
    background: var(--bg-hover);
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

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

.sidebar-history::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

.chat-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all 0.15s ease;
    margin-bottom: 0.25rem;
}

.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-item-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

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

.chat-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.sidebar-footer {
    padding: 0.5rem;
    border-top: 1px solid var(--border-subtle);
}

.sidebar-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
    transition: background 0.15s ease;
    margin-bottom: 0.25rem;
}

.sidebar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-btn .badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    margin-top: 0.5rem;
}

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
}

.sidebar-user span {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.logout-icon {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.logout-icon:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

/* =========================================
   MAIN CHAT CONTAINER
   ========================================= */

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    overflow: hidden;
}

.chat-container.initial-view {
    justify-content: center;
    align-items: center;
}

.chat-container.initial-view .messages,
.chat-container.initial-view .chat-form {
    display: none !important;
}

/* =========================================
   HERO SECTION (Centered Input)
   ========================================= */

.hero-section {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 700px;
    padding: 2rem;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.chat-container.initial-view .hero-section {
    display: flex;
}

.hero-logo {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.hero-form {
    width: 100%;
    max-width: 600px;
    margin-bottom: 2rem;
}

/* =========================================
   INPUT ROW - Unified Structure
   ========================================= */

.input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.input-icon-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.input-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.text-input {
    flex: 1;
    height: 44px;
    padding: 0 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.15s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--border-light);
    background: var(--bg-secondary);
}

.text-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.send-btn:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Stop / Cancel mode */
.send-btn.stop-mode {
    background: var(--error, #ef4444);
    animation: stopPulse 1.5s ease-in-out infinite;
}

.send-btn.stop-mode:hover {
    background: #dc2626;
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
}

@keyframes stopPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.hero-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.hero-chip {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hero-chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* =========================================
   CHAT HEADER
   ========================================= */

.chat-header {
    padding: 1rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 {
    font-size: 1.1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header h1::before {
    content: '🛍️';
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* =========================================
   MESSAGES
   ========================================= */

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    list-style: none;
}

.messages::-webkit-scrollbar {
    width: 6px;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.message.user {
    flex-direction: row-reverse;
}

.message.user .bubble {
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    max-width: 70%;
    padding: 1rem 1.25rem;
}

.message.bot .bubble {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    max-width: 100%;
    padding: 1rem 1.25rem;
}

/* =========================================
   PRODUCT CARDS
   ========================================= */

.results-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    width: 100%;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    width: 100%;
}

.product-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.25s ease;
}

.product-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.15);
}

/* Magical glow while try-on is generating */
.product-card.tryon-generating {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 60px rgba(139, 92, 246, 0.15);
    animation: cardPulse 2s ease-in-out infinite;
}

.product-card.tryon-generating .product-image-carousel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 30%,
        rgba(139, 92, 246, 0.12) 45%,
        rgba(99, 102, 241, 0.2) 50%,
        rgba(139, 92, 246, 0.12) 55%,
        transparent 70%
    );
    background-size: 200% 100%;
    animation: shimmerSweep 1.8s ease-in-out infinite;
    z-index: 2;
    pointer-events: none;
    border-radius: inherit;
}

.auto-tryon-status {
    margin: 0.35rem auto 0.75rem;
    padding: 0.45rem 0.7rem;
    width: fit-content;
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(15, 15, 25, 0.82);
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.auto-tryon-stop {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0.22rem 0.58rem;
}

.auto-tryon-stop:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.45);
}

@keyframes shimmerSweep {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes cardPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.4), 0 0 60px rgba(139, 92, 246, 0.1); }
    50%      { box-shadow: 0 0 30px rgba(99, 102, 241, 0.6), 0 0 80px rgba(139, 92, 246, 0.25); }
}

/* =========================================
   IMAGE CAROUSEL (within Product Card)
   ========================================= */

.product-image-carousel {
    position: relative;
    width: 100%;
    height: 220px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.product-image-carousel .carousel-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 1rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.product-image-carousel .carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
    position: relative;
}

/* Carousel Navigation Arrows */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: all 0.2s ease;
    opacity: 0;
}

.product-image-carousel:hover .carousel-nav {
    opacity: 1;
}

.carousel-prev {
    left: 6px;
}

.carousel-next {
    right: 6px;
}

.carousel-nav:hover {
    background: var(--accent-primary);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.5);
}

/* Dot Indicators */
.carousel-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 4;
}

.carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
}

.carousel-dot.active {
    background: var(--accent-primary);
    width: 18px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(99, 102, 241, 0.6);
}

/* Slide Label Badge */
.carousel-label {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 100px;
    z-index: 4;
}

/* Try-On Overlay Button */
.tryon-btn-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    background: rgba(99, 102, 241, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 5;
    opacity: 0;
    transition: all 0.25s ease;
}

.product-card:hover .tryon-btn-overlay {
    opacity: 1;
}

.tryon-btn-overlay:hover {
    background: var(--accent-primary);
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);
}

.tryon-btn-overlay:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed;
    transform: none;
}

.tryon-btn-overlay.generating {
    opacity: 1 !important;
    background: rgba(99, 102, 241, 0.7);
    pointer-events: none;
}

/* =========================================
   KLOTHIFY SCAN ANIMATION (Try-On highlight)
   ========================================= */

@keyframes klothifyScanLine {
    0%   { top: 0%; opacity: 1; }
    100% { top: 100%; opacity: 1; }
}

@keyframes klothifyRevealClip {
    0%   { clip-path: inset(0 0 100% 0); opacity: 1; }
    100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

.tryon-reveal-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1rem;
    box-sizing: border-box;
    object-fit: contain;
    pointer-events: none;
    opacity: 0;
}

.product-card.klothify-scan .product-image-carousel .carousel-slide.active .tryon-reveal-img {
    animation: klothifyRevealClip 2s ease-in-out infinite alternate;
}

@keyframes klothifyGlow {
    0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
    30%  { box-shadow: 0 0 18px 4px rgba(99, 102, 241, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

/* Scan bar element inside carousel */
.product-image-carousel .klothify-scan-bar {
    position: absolute;
    top: -4px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(99, 102, 241, 0.3) 15%,
        rgba(129, 140, 248, 0.9) 40%,
        #a5b4fc 50%,
        rgba(129, 140, 248, 0.9) 60%,
        rgba(99, 102, 241, 0.3) 85%,
        transparent 100%);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    filter: blur(0.5px);
    box-shadow:
        0 0 12px 4px rgba(99, 102, 241, 0.4),
        0 0 30px 8px rgba(129, 140, 248, 0.15);
    transform: translateY(-50%);
}

/* Looping animation on cards with try-on */
.product-card.klothify-scan .product-image-carousel .carousel-slide.active .klothify-scan-bar {
    animation: klothifyScanLine 2s ease-in-out infinite alternate;
}

.product-card.klothify-scan {
    animation: klothifyGlow 2.4s ease-out infinite;
    animation-delay: 0.5s;
}

.product-info {
    padding: 1rem;
}

.product-info a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-info a:hover {
    color: var(--accent-primary);
}

.product-info div {
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* =========================================
   CHAT FORM (Bottom)
   ========================================= */

.chat-form {
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-subtle);
}

.chat-form .input-row {
    max-width: 800px;
    margin: 0 auto;
}

/* =========================================
   AUTH OVERLAY
   ========================================= */

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-overlay.hidden {
    display: none;
}

.auth-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-tertiary);
    padding: 0.35rem;
    border-radius: var(--radius-md);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.auth-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: none;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.auth-submit {
    width: 100%;
    padding: 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
}

.auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* =========================================
   PHOTOS MODAL
   ========================================= */

.photos-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.photos-modal.active {
    display: flex;
}

.photos-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

.photos-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 2rem;
}

.photos-header h2 {
    font-size: 1.25rem;
}

.photos-header p {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.close-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.close-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 2rem;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-zone h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.upload-zone p {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

#photoUpload {
    display: none;
}

.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1rem;
}

.photo-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.delete-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.photo-card:hover .delete-btn {
    opacity: 1;
}

.photos-tip {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1.5rem;
}

.photos-tip span {
    font-size: 1.25rem;
}

.photos-tip p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* =========================================
   MODALS
   ========================================= */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 90%;
    max-width: 420px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-content h2 {
    font-size: 1.25rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body label {
    display: block;
    margin-bottom: 1rem;
}

.modal-body label span {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.modal-body input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.modal-actions button {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
}

.btn-primary,
#saveOpts {
    background: var(--accent-gradient);
    border: none;
    color: white;
}

.btn-secondary,
#resetOpts {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

/* =========================================
   IMAGE VIEWER
   ========================================= */

.image-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    cursor: zoom-out;
}

.image-viewer.active {
    display: flex;
}

.image-viewer img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.viewer-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
}

/* =========================================
   LOADING
   ========================================= */

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* =========================================
   BACKGROUND & ANIMATIONS
   ========================================= */

.bg-gradient {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

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

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

/* =========================================
   TOAST
   ========================================= */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.info {
    border-left: 4px solid var(--info);
}

/* =========================================
   SETTINGS MODAL (New Premium Style)
   ========================================= */

.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.settings-modal.hidden {
    display: none;
}

.settings-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.2s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.settings-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.settings-header p {
    color: var(--text-tertiary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Scrollable body */
.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.settings-body::-webkit-scrollbar {
    width: 6px;
}

.settings-body::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

.settings-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.settings-section:last-of-type {
    border-bottom: none;
}

.settings-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
}

/* Toggle Grid */
.toggle-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-item:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.toggle-item input {
    display: none;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-primary);
    border-radius: 10px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-tertiary);
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toggle-item input:checked+.toggle-switch {
    background: var(--accent-primary);
}

.toggle-item input:checked+.toggle-switch::after {
    left: 18px;
    background: white;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toggle-item input:checked~.toggle-label {
    color: var(--text-primary);
}

/* Results Slider */
.results-slider {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.results-slider label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-wrapper input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s ease;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider-value {
    background: var(--accent-primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

/* Settings Actions */
.settings-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-subtle);
}

.settings-actions button {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-actions .btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
}

.settings-actions .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.settings-actions .btn-secondary {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.settings-actions .btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* =========================================
   PRICE HEADER (Always Visible Top Bar)
   ========================================= */

.price-header {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.price-filter-inline {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.price-filter-tag {
    background: var(--accent-gradient);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Custom Price Inputs */
.price-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0 0.45rem;
    gap: 0.15rem;
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

.price-input-wrap:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.price-input-prefix {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
}

.price-custom-input {
    width: 58px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    padding: 0.35rem 0;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.price-custom-input::-webkit-outer-spin-button,
.price-custom-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Dual Range Slider */
.dual-range-container {
    position: relative;
    flex: 2;
    height: 32px;
    display: flex;
    align-items: center;
    min-width: 160px;
}

.dual-range-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    transform: translateY(-50%);
    pointer-events: none;
}

.dual-range-fill {
    position: absolute;
    top: 50%;
    height: 5px;
    background: var(--accent-gradient);
    border-radius: 3px;
    transform: translateY(-50%);
    pointer-events: none;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.35);
    transition: left 0.05s, right 0.05s;
}

.dual-range {
    position: absolute;
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    pointer-events: none;
    z-index: 2;
}

.dual-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.25);
}

.dual-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.25), 0 4px 14px rgba(99, 102, 241, 0.5);
}

.dual-range::-webkit-slider-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.3), 0 4px 16px rgba(99, 102, 241, 0.6);
}

.dual-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 2px 8px rgba(99, 102, 241, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

/* Price Reset Button */
.price-reset-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.price-reset-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
    transform: rotate(-45deg);
}

/* =========================================
   SORT CONTROLS (Results Header)
   ========================================= */

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.25rem;
    margin-bottom: 0.5rem;
}

.results-count {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.results-count strong {
    color: var(--success);
    font-weight: 700;
}

.sort-pills {
    display: flex;
    gap: 0.15rem;
    align-items: center;
}

.sort-pill {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.sort-pill:hover {
    color: var(--text-primary);
}

.sort-pill.active {
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.sort-pill.active:hover {
    background: var(--accent-secondary);
}

/* =========================================
   STREAMING SKELETON (from Ankit's branch)
   ========================================= */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Skeleton shimmer inside product card */
.product-card .img-skeleton {
    width: 100%;
    height: 220px;
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-hover) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--text-tertiary);
}

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 999;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    .toggle-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-content {
        max-width: 95%;
        margin: 1rem;
    }

    .price-header {
        padding: 0.75rem 1rem;
    }

    .price-filter-inline {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .price-filter-tag {
        display: none;
    }

    .dual-range-container {
        min-width: 100px;
    }

    .results-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }

    .sort-pills {
        justify-content: center;
    }

    .sort-pill {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
}
