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

:root {
    /* Cosmic Dark Theme */
    --bg-primary: #1a1a1a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #1a1a1a;
    --bg-sidebar: #111111;
    --bg-hover: #222222;
    --bg-glass: rgba(255, 255, 255, 0.03);

    /* Accent Colors — fashion poster palette */
    --accent-primary: #FED325;
    --accent-secondary: #FB3021;
    --accent-gradient: linear-gradient(135deg, #FED325 0%, #FFB71B 48%, #FB3021 100%);
    --accent-glow: rgba(254, 211, 37, 0.35);
    --rainbow-gradient: linear-gradient(90deg, #FED325, #FFB71B, #FB3021, #000000, #FED325);

    /* Text Colors */
    --text-primary: #e8eaf0;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

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

    /* Borders */
    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-light: rgba(148, 163, 184, 0.14);

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

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

:root[data-theme="light"] {
    /* Cosmic Light Theme */
    --bg-primary: #fff6d1;
    --bg-secondary: #fff3bf;
    --bg-tertiary: #ffe892;
    --bg-sidebar: #fff3bf;
    --bg-hover: #ffe892;
    --bg-glass: rgba(0, 0, 0, 0.03);

    /* Accent Colors — fashion poster palette */
    --accent-primary: #FED325;
    --accent-secondary: #FB3021;
    --accent-gradient: linear-gradient(135deg, #FED325 0%, #FFB71B 48%, #FB3021 100%);
    --accent-glow: rgba(254, 211, 37, 0.22);

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;

    /* Borders */
    --border-subtle: rgba(15, 23, 42, 0.08);
    --border-light: rgba(15, 23, 42, 0.14);
}

* {
    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);
    height: 100vh;
    overflow: hidden;
    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);
    backdrop-filter: blur(20px);
    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: rgba(232, 249, 124, 0.1);
    border-color: rgba(232, 249, 124, 0.3);
}

.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: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    margin-bottom: 0.25rem;
    border-left: 2px solid transparent; /* Ready for active state */
}

.chat-item:hover,
.chat-item.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent-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: background-color 0.15s ease, color 0.15s ease, opacity 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);
}

/* =========================================
   EXCHANGE HISTORY CARDS
   ========================================= */

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    opacity: 0.6;
}

.history-empty svg {
    width: 22px;
    height: 22px;
    opacity: 0.5;
}

.history-skeleton {
    padding: 0.35rem 0.25rem;
}

.history-skeleton-row {
    height: 54px;
    margin: 0 0 0.45rem;
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.035));
    background-size: 220% 100%;
    animation: historySkeletonSweep 1.4s ease-in-out infinite;
}

.history-skeleton-row.short {
    width: 72%;
}

.history-skeleton-row.medium {
    width: 86%;
}

@keyframes historySkeletonSweep {
    0% {
        background-position: 120% 0;
    }
    100% {
        background-position: -120% 0;
    }
}

.exchange-card {
    padding: 0.75rem 0.75rem 0.65rem 0.75rem;
    cursor: pointer;
    border-left: 2px solid transparent;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s ease, border-color 0.15s ease;
    position: relative;
}

.exchange-card:last-child {
    border-bottom: none;
}

.exchange-card:hover,
.exchange-card.active {
    background: var(--bg-tertiary);
    border-left-color: var(--accent-primary);
}

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

.exchange-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
    text-transform: uppercase;
    opacity: 0.6;
}

.exchange-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exchange-card:hover .exchange-delete {
    opacity: 1;
}

.exchange-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.12);
}

.exchange-you-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    text-transform: uppercase;
    opacity: 0.45;
    margin-bottom: 0.15rem;
}

.exchange-query {
    font-size: 0.78rem;
    font-style: italic;
    color: var(--text-secondary);
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.35;
    margin-bottom: 0.45rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.exchange-bot-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    text-transform: uppercase;
    opacity: 0.4;
}

.exchange-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
    color: var(--text-tertiary);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.exchange-time-row span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exchange-time-row span:last-child {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.profile-home-section.hidden,
.profile-history-view.hidden {
    display: none;
}

.profile-history-section {
    margin: 0 0 18px;
}

.profile-history-btn {
    width: 100%;
    min-height: 58px;
    border: 1px solid rgba(232, 249, 124, 0.2);
    border-radius: 16px;
    background: rgba(232, 249, 124, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.85rem 1rem;
    text-align: left;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.profile-history-btn:hover {
    background: rgba(232, 249, 124, 0.13);
    border-color: rgba(232, 249, 124, 0.35);
    transform: translateY(-1px);
}

.profile-history-btn strong {
    display: block;
    font-size: 0.92rem;
    line-height: 1.2;
}

.profile-history-btn small {
    display: block;
    margin-top: 3px;
    color: var(--text-tertiary);
    font-size: 0.72rem;
}

.profile-history-arrow {
    color: var(--accent-primary);
    font-size: 1.4rem;
    line-height: 1;
}

.profile-history-view {
    min-height: 360px;
}

.profile-history-view-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0 0.95rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.profile-history-view-head button {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.profile-history-view-head span {
    display: block;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.profile-history-view-head small {
    display: block;
    margin-top: 3px;
    color: var(--text-tertiary);
    font-size: 0.72rem;
}

.profile-product-history-list {
    max-height: 460px;
    overflow-y: auto;
    padding: 0 0.1rem 0.5rem;
}

.profile-history-session {
    margin-bottom: 1rem;
}

.profile-history-session:last-child {
    margin-bottom: 0;
}

.profile-history-session-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 0.55rem;
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 700;
}

.profile-history-session-title span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-history-session-title span:last-child {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.profile-history-session-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: -0.25rem 0 0.6rem;
    color: var(--text-tertiary);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.profile-history-session-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-history-session-meta span:last-child {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.profile-history-products {
    display: flex;
    gap: 0.65rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scroll-snap-type: x proximity;
}

.profile-history-product {
    flex: 0 0 132px;
    scroll-snap-align: start;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    text-decoration: none;
}

.profile-history-product img {
    width: 100%;
    aspect-ratio: 1 / 1.12;
    display: block;
    object-fit: cover;
    background: var(--bg-primary);
}

.profile-history-product-image-empty {
    aspect-ratio: 1 / 1.12;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: 0.7rem;
}

.profile-history-product-info {
    padding: 0.55rem;
}

.profile-history-product-name {
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    min-height: 2.5em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.profile-history-product-meta {
    margin-top: 0.35rem;
    color: var(--accent-primary);
    font-size: 0.68rem;
    font-weight: 800;
}


.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-left: 2px solid transparent;
    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, border-color 0.15s ease;
    margin-bottom: 0.25rem;
}

.sidebar-btn:hover,
.sidebar-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-left: 2px solid var(--accent-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: rgba(232, 249, 124, 0.06);
    border: 1px solid rgba(232, 249, 124, 0.1);
    margin-top: 0.5rem;
}

.sidebar-user .user-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    flex-shrink: 0;
    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: background-color 0.15s ease, color 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.6s ease-out;
}

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

.hero-logo {
    font-size: 4.5rem;
    margin-bottom: 1.5rem;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(232, 249, 124, 0.35));
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #f4fcd8 0%, #b8c940 40%, #818cf8 100%);
    -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;
    position: relative;
}

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



.input-icon-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* =========================================
   INPUT ROW & TEXT INPUT (Sleek Pill Shape)
   ========================================= */



.input-row {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    background: rgba(17, 24, 39, 0.4);
    border-radius: 32px;
    padding: 0.35rem 0.5rem;
    backdrop-filter: blur(12px);
    z-index: 1;
}

@keyframes aiSightRainbow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Crisp glowing border */
.input-row::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 32px;
    padding: 2px;
    background: linear-gradient(90deg, #ff6b6b, #845ef7, #339af0, #20c997, #ff922b);
    background-size: 300% 300%;
    animation: aiSightRainbow 6s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* Soft outer glow */
.input-row::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 34px;
    background: linear-gradient(90deg, #ff6b6b, #845ef7, #339af0, #20c997, #ff922b);
    background-size: 300% 300%;
    animation: aiSightRainbow 6s linear infinite;
    filter: blur(8px);
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.input-row:focus-within::after {
    opacity: 0.6;
    filter: blur(12px);
}

.text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    padding: 0 0.5rem;
    height: 40px;
    font-family: inherit;
}

.text-input:focus {
    outline: none;
    background: transparent;
    border: none;
    box-shadow: none;
}

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

.send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.send-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    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.6rem 1.2rem;
    background: rgba(232, 249, 124, 0.08);
    border: 1px solid rgba(232, 249, 124, 0.2);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hero-chip:hover {
    background: rgba(232, 249, 124, 0.18);
    border-color: rgba(232, 249, 124, 0.5);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(232, 249, 124, 0.15);
}

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

.chat-header {
    padding: 1rem 1.5rem;
    background: transparent;
    border-bottom: none;
    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;
}

.header-logo {
    height: 28px;
    vertical-align: middle;
}

/* =========================================
   AUTO TRY-ON TOGGLE
   ========================================= */

.auto-tryon-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 99px;
    cursor: pointer;
    padding: 6px 10px;
    outline: none;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.auto-tryon-toggle:hover {
    background: rgba(30, 41, 59, 0.6);
    border-color: var(--border-subtle);
}

#autoTryOnToggleLabel {
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: right;
    letter-spacing: 0.5px;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

.hero-title-klothify {
    background: linear-gradient(90deg, #ff6b6b, #845ef7, #339af0, #20c997, #ff922b);
    background-size: 300% 300%;
    animation: aiSightRainbow 6s linear infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(132, 94, 247, 0.3));
}

.toggle-switch-ui {
    position: relative;
    width: 36px;
    height: 20px;
    background: #2563eb; /* Bright blue when active */
    border-radius: 20px;
    transition: background-color 0.3s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.toggle-switch-ui::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: right 0.3s;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.auto-tryon-toggle.off .toggle-switch-ui {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.auto-tryon-toggle.off .toggle-switch-ui::after {
    right: 18px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.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: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

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

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

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.messages::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
}

.search-page {
    display: none;
    flex-direction: column;
    width: 100%;
    list-style: none;
}

.search-page.active {
    display: flex;
}

.search-page-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.search-page-pager {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    list-style: none;
    padding: 0.85rem 0 0.25rem;
    margin: auto 0 0;
    border-top: 1px solid var(--border-subtle);
}

.search-page-btn {
    min-width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(232, 249, 124, 0.24);
    background: rgba(255, 255, 255, 0.035);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.search-page-btn:hover,
.search-page-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #1a1f00;
}

.search-page-btn:hover {
    transform: translateY(-1px);
}

.message {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    animation: slideIn 0.3s ease-out;
}

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

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

.message.user {
    width: 100%;
    margin-bottom: 0;
}

.exchange-section {
    width: 100%;
}

.exchange-section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    padding-top: 1.5rem;
}

.exchange-section-divider::before,
.exchange-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.exchange-section-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: #888888;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0.7;
    font-family: 'Inter', sans-serif;
}

.exchange-section-you {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    padding-bottom: 0.75rem;
}

.exchange-section-you-tag {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #b8c940;
    text-transform: uppercase;
    flex-shrink: 0;
    opacity: 1;
}

.exchange-section-query {
    font-family: 'Lora', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

/* SHOPBOT REPLIES header in bot messages */
.exchange-bot-header {
    width: 100%;
    margin-bottom: 0.75rem;
}

.exchange-bot-replies-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--text-tertiary);
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 0.35rem;
}

.exchange-bot-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 0.65rem;
}

.exchange-bot-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.exchange-bot-meta-count {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    opacity: 0.6;
}

.exchange-bot-meta-sort {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    opacity: 0.45;
}

.message.user .bubble {
    display: none;
}

.message.bot {
    width: 100%;
    margin-bottom: 1.5rem;
}

.message.bot .bubble {
    background: transparent;
    backdrop-filter: none;
    border: none;
    max-width: 100%;
    padding: 0;
}

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

.results-container {
    background: transparent;
    border-radius: 0;
    padding: 0;
    border: none;
    width: 100%;
    backdrop-filter: none;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* More small */
    gap: 0;
    width: 100%;
    margin-top: 1rem;
    border: none; /* Removed overall border */
}

.product-card {
    background: #1a1a1a;
    border-radius: 0;
    overflow: hidden;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.22s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    border: 0.5px solid rgba(255, 255, 255, 0.1);
    margin: -0.25px; /* Collapse borders */
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.product-card:hover {
    border-color: var(--border-subtle);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

/* Magical glow while try-on is generating */
.product-card.tryon-generating {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(232, 249, 124, 0.4), 0 0 60px rgba(212, 230, 92, 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(212, 230, 92, 0.12) 45%,
        rgba(232, 249, 124, 0.2) 50%,
        rgba(212, 230, 92, 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(232, 249, 124, 0.28);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.auto-tryon-stop {
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--bg-hover);
    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(232, 249, 124, 0.4), 0 0 60px rgba(212, 230, 92, 0.1); }
    50%      { box-shadow: 0 0 30px rgba(232, 249, 124, 0.6), 0 0 80px rgba(212, 230, 92, 0.25); }
}

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

.product-image-carousel {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #202020;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.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 var(--border-subtle);
    color: white;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 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(232, 249, 124, 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: width 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    border: none;
}

.carousel-dot.active {
    background: var(--accent-primary);
    width: 18px;
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(232, 249, 124, 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 var(--border-subtle);
    color: var(--text-secondary);
    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(232, 249, 124, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    border-radius: 100px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s 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(232, 249, 124, 0.45);
}

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

.tryon-btn-overlay.generating {
    opacity: 1 !important;
    background: rgba(232, 249, 124, 0.7);
    pointer-events: none;
}

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

:root {
    --tryon-scan-duration: 2.8s;
    --tryon-scan-easing: cubic-bezier(0.45, 0, 0.2, 1);
}

@keyframes klothifyScanOpacity {
    0%   { opacity: 0.85; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { opacity: 0.85; }
}

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

@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: 0;
    box-sizing: border-box;
    object-fit: cover;
    pointer-events: none;
    opacity: 0;
}

.product-card.klothify-scan .product-image-carousel .carousel-slide.active .tryon-reveal-img {
    animation: klothifyRevealClip var(--tryon-scan-duration) var(--tryon-scan-easing) infinite alternate both;
}

@keyframes klothifyGlow {
    0%   { box-shadow: 0 0 0 0 rgba(232, 249, 124, 0); }
    30%  { box-shadow: 0 0 18px 4px rgba(232, 249, 124, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(232, 249, 124, 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(232, 249, 124, 0.18) 12%,
        var(--accent-secondary) 38%,
        var(--accent-primary) 50%,
        var(--accent-secondary) 62%,
        rgba(232, 249, 124, 0.18) 88%,
        transparent 100%);
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    filter: blur(0.5px);
    box-shadow:
        0 0 12px 4px var(--accent-glow),
        0 0 30px 8px rgba(232, 249, 124, 0.16);
    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 var(--tryon-scan-duration) var(--tryon-scan-easing) infinite alternate both,
        klothifyScanOpacity var(--tryon-scan-duration) linear infinite alternate both;
}

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

.product-info {
    padding: 0.75rem 0.6rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.product-source-label {
    font-size: 0.52rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #b8c940;
    text-transform: uppercase;
    margin-bottom: 0.1rem;
}

.product-info a {
    color: var(--text-primary);
    text-decoration: none;
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 0.78rem; /* Smaller for 5-column grid */
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.1rem;
}

.product-brand {
    font-family: 'Lora', serif;
    font-size: 0.6rem;
    color: #777777;
    margin-bottom: 0.3rem;
}

.product-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    color: var(--text-primary) !important;
    font-family: 'Lora', serif;
    font-weight: 700;
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.product-rating {
    display: flex;
    gap: 1px;
    color: #fb923c;
    font-size: 0.65rem;
}

.product-rating .star-filled {
    color: #fb923c;
}

.product-rating .star-empty {
    color: #444444;
}

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

.chat-form {
    padding: 1rem 1.5rem;
    background: transparent;
    border-top: none;
}

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

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

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

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

.auth-modal {
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 60px rgba(232, 249, 124, 0.08);
    backdrop-filter: blur(20px);
}

.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);
}

#firebaseui-auth-container {
    margin-bottom: 1rem;
}

.auth-helper {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
}

.auth-divider {
    align-items: center;
    color: var(--text-tertiary);
    display: flex;
    font-size: 0.75rem;
    gap: 0.75rem;
    letter-spacing: 0.08em;
    margin: 1rem 0;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    background: var(--border-light);
    content: "";
    flex: 1;
    height: 1px;
}

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

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

.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: background-color 0.15s ease, color 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: transform 0.2s ease, box-shadow 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: border-color 0.2s ease, background-color 0.2s ease;
    margin-bottom: 2rem;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(232, 249, 124, 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(232, 249, 124, 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 {
    display: none;
}

@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: absolute;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    padding: 0.85rem 1.5rem;
    background: color-mix(in srgb, var(--phone-card) 90%, transparent);
    border: 1px solid color-mix(in srgb, var(--phone-border) 60%, transparent);
    border-radius: 99px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--phone-text);
    font-size: 0.9rem;
    font-weight: 500;
    width: max-content;
    max-width: calc(100% - 3rem);
    text-align: left;
    line-height: 1.4;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: color-mix(in srgb, #10b981 15%, var(--phone-card));
    border-color: rgba(16, 185, 129, 0.3);
    color: #10b981;
}

.toast.error {
    background: color-mix(in srgb, #ef4444 15%, var(--phone-card));
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.toast.info {
    background: color-mix(in srgb, #3b82f6 15%, var(--phone-card));
    border-color: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.toast.warning {
    background: color-mix(in srgb, #f59e0b 15%, var(--phone-card));
    border-color: rgba(245, 158, 11, 0.3);
    color: #f59e0b;
}

/* =========================================
   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: rgba(17, 24, 39, 0.95);
    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: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(232, 249, 124, 0.06);
    animation: modalSlideUp 0.2s ease;
    backdrop-filter: blur(20px);
}

@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: background-color 0.15s ease, border-color 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: background-color 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: left 0.24s cubic-bezier(0.34, 1.2, 0.64, 1), background-color 0.24s ease;
}

.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(232, 249, 124, 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: background-color 0.2s ease, border-color 0.2s ease, color 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 FILTER (Inside Settings Modal)
   ========================================= */

.price-filter-settings {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.price-inputs-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-separator {
    color: var(--text-tertiary);
    font-size: 0.9rem;
    padding: 0 0.25rem;
}

/* 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: 1;
    transition: border-color 0.2s ease;
}

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

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

.price-custom-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    padding: 0.5rem 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;
    width: 100%;
    height: 32px;
    display: flex;
    align-items: center;
}

.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(232, 249, 124, 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(232, 249, 124, 0.2), 0 2px 8px rgba(232, 249, 124, 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(232, 249, 124, 0.25), 0 4px 14px rgba(232, 249, 124, 0.5);
}

.dual-range::-webkit-slider-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(232, 249, 124, 0.3), 0 4px 16px rgba(232, 249, 124, 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(232, 249, 124, 0.2), 0 2px 8px rgba(232, 249, 124, 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: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 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: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease, border-radius 0.2s ease;
    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);
}

/* =========================================
   MOBILE HAMBURGER BUTTON
   ========================================= */

.mobile-menu-btn {
    display: flex;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
    padding: 0;
    transition: background-color 0.18s ease,
                border-color 0.18s ease,
                box-shadow 0.18s ease;
    z-index: 100;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}

.mobile-menu-btn:hover {
    background: var(--bg-hover);
}

.menu-btn-logo {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}

.mobile-menu-btn::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 6px;
    background: rgba(232, 249, 124, 0.14);
    opacity: 0;
    transform: scale(0.86);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: -1;
}

.mobile-menu-btn svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
    overflow: visible;
    transition: opacity 0.18s ease,
                transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mobile-menu-btn .hamburger-line {
    transform-box: view-box;
    transform-origin: 12px 12px;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.16s ease;
}

.mobile-menu-btn:focus-visible {
    outline: 2px solid rgba(232, 249, 124, 0.8);
    outline-offset: 3px;
    background: var(--bg-hover);
    border-color: rgba(232, 249, 124, 0.42);
    color: var(--text-primary);
}

.mobile-menu-btn:focus-visible::before {
    opacity: 1;
    transform: scale(1);
}

.mobile-menu-btn:active {
    transform: scale(0.97);
}

.mobile-menu-btn.is-open {
    background: rgba(255, 255, 255, 0.065);
    border-color: rgba(232, 249, 124, 0.38);
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.mobile-menu-btn.is-open::before {
    opacity: 1;
    transform: scale(1);
}

.mobile-menu-btn.is-open .hamburger-line-top {
    transform: translateY(6px) rotate(45deg);
}

.mobile-menu-btn.is-open .hamburger-line-middle {
    opacity: 0;
    transform: scaleX(0.25);
}

.mobile-menu-btn.is-open .hamburger-line-bottom {
    transform: translateY(-6px) rotate(-45deg);
}

@media (hover: hover) and (pointer: fine) {
    .mobile-menu-btn:hover {
        background: var(--bg-hover);
        color: var(--text-primary);
        border-color: rgba(232, 249, 124, 0.34);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
        transform: translateY(-1px);
    }

    .mobile-menu-btn:hover::before {
        opacity: 1;
        transform: scale(1);
    }

    .mobile-menu-btn:hover .hamburger-line-top {
        transform: translateY(-1px);
    }

    .mobile-menu-btn:hover .hamburger-line-bottom {
        transform: translateY(1px);
    }

    .mobile-menu-btn.is-open:hover .hamburger-line-top {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-menu-btn.is-open:hover .hamburger-line-bottom {
        transform: translateY(-6px) rotate(-45deg);
    }

}

@media (prefers-reduced-motion: reduce) {
    .mobile-menu-btn,
    .mobile-menu-btn::before,
    .mobile-menu-btn .hamburger-line,
    .mobile-menu-btn svg,
    .sidebar,
    .sidebar-overlay {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Sidebar overlay backdrop on mobile */
.sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0s linear 0.22s;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
}

/* =========================================
   RESPONSIVE — Tablets (≤ 1024px)
   ========================================= */

@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}

/* =========================================
   RESPONSIVE — Mobile (≤ 768px)
   ========================================= */

@media (max-width: 768px) {
    /* Show hamburger */
    .mobile-menu-btn {
        display: flex;
    }

    /* Sidebar becomes a fixed slide-in drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 260px;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        will-change: transform;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5);
    }

    /* Chat header: add room for hamburger */
    .chat-header {
        padding: 0.75rem 1rem;
    }

    .chat-header h1 {
        font-size: 1rem;
    }

    .auto-tryon-toggle {
        gap: 6px;
    }

    #autoTryOnToggleLabel {
        font-size: 0.65rem;
    }

    /* Hero section */
    .hero-section {
        padding: 1.25rem;
    }

    .hero-logo {
        font-size: 3rem;
        margin-bottom: 1rem;
    }

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

    .hero-content p {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .hero-chips {
        gap: 0.5rem;
    }

    .hero-chip {
        padding: 0.4rem 0.75rem;
        font-size: 0.78rem;
    }

    /* Product grid: 2 columns on mobile */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .product-image-carousel {
        height: 180px;
    }

    .product-info {
        padding: 0.6rem;
    }

    .product-info a {
        font-size: 0.78rem;
    }

    .product-info div {
        font-size: 0.95rem;
        margin-top: 0.3rem;
    }

    /* Make try-on button always visible on mobile (no hover) */
    .tryon-btn-overlay {
        opacity: 1;
        padding: 4px 10px;
        font-size: 0.68rem;
        bottom: 6px;
        right: 6px;
    }

    /* Carousel navs always visible on mobile */
    .product-image-carousel .carousel-nav {
        opacity: 0.7;
        width: 26px;
        height: 26px;
        font-size: 1rem;
    }

    /* Results container */
    .results-container {
        padding: 0.5rem;
    }

    /* Messages area */
    .messages {
        padding: 0.75rem;
        gap: 1rem;
    }

    .exchange-section-query {
        font-size: 0.95rem;
    }

    .exchange-section-divider {
        padding-top: 1rem;
    }

    .message.bot .bubble {
        max-width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Chat form */
    .chat-form {
        padding: 0.6rem 0.75rem;
    }

    .chat-form .input-row {
        gap: 0.4rem;
    }

    .text-input {
        height: 42px;
        font-size: 0.9rem;
        padding: 0 0.75rem;
    }

    .input-icon-btn {
        width: 36px;
        height: 36px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
    }

    /* Settings modal */
    .settings-modal {
        padding: 0;
        align-items: flex-end;
    }

    .settings-content {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 85vh;
    }

    .settings-section {
        padding: 0.75rem 1rem;
    }

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

    .toggle-item {
        padding: 0.5rem 0.6rem;
        gap: 0.4rem;
    }

    .toggle-label {
        font-size: 0.72rem;
    }

    .toggle-switch {
        width: 32px;
        height: 18px;
    }

    .toggle-switch::after {
        width: 14px;
        height: 14px;
    }

    .toggle-item input:checked+.toggle-switch::after {
        left: 16px;
    }

    .settings-actions {
        padding: 1rem;
    }

    .settings-actions button {
        padding: 0.65rem 1.25rem;
        font-size: 0.85rem;
    }

    /* Results header / Sort controls */
    .results-header {
        flex-direction: column;
        gap: 0.4rem;
        align-items: stretch;
    }

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

    .sort-pill {
        flex: 1;
        text-align: center;
        justify-content: center;
        padding: 0.35rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Auth modal */
    .auth-modal {
        max-width: 95vw;
        padding: 1.75rem;
        margin: 0.75rem;
    }

    .auth-logo {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .auth-header h1 {
        font-size: 1.3rem;
    }

    /* Photos modal */
    .photos-container {
        max-width: 95vw;
        padding: 1.25rem;
        margin: 0.75rem;
        max-height: 90vh;
    }

    /* Image viewer */
    .viewer-close {
        top: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }

    /* Toast */
    .toast {
        bottom: 5.5rem; /* slightly higher on mobile to clear bottom nav */
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }

    /* Auto try-on status bar */
    .auto-tryon-status {
        font-size: 0.72rem;
        padding: 0.35rem 0.55rem;
        gap: 0.4rem;
    }
}

/* =========================================
   RESPONSIVE — Small phones (≤ 480px)
   ========================================= */

@media (max-width: 480px) {
    .hero-content h1 {
        font-size: 1.5rem;
        letter-spacing: -0.3px;
    }

    .hero-content p {
        font-size: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .hero-logo {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    /* Single column for very small screens */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .product-image-carousel {
        height: 150px;
    }

    .product-info {
        padding: 0.5rem;
    }

    .product-info a {
        font-size: 0.72rem;
        -webkit-line-clamp: 2;
    }

    .product-info div {
        font-size: 0.85rem;
    }

    /* Chat form tight */
    .chat-form {
        padding: 0.5rem;
    }

    .text-input {
        height: 40px;
        font-size: 0.85rem;
        border-radius: var(--radius-lg);
    }

    .input-icon-btn {
        width: 34px;
        height: 34px;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    /* Toggle grid stacks on very small screens */
    .toggle-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Auth modal full-width */
    .auth-modal {
        padding: 1.5rem;
        border-radius: var(--radius-lg);
    }

    .auth-header h1 {
        font-size: 1.2rem;
    }

    .form-group input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .auth-submit {
        padding: 0.85rem;
        font-size: 0.9rem;
    }

    /* Photos modal compact */
    .photos-container {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }
}

/* =========================================
   RESPONSIVE — Very small screens (≤ 360px)
   ========================================= */

@media (max-width: 360px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .product-image-carousel {
        height: 200px;
    }

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

    .hero-chips {
        flex-direction: column;
        align-items: center;
    }

    .hero-chip {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* =========================================
   iOS / Safe Area support
   ========================================= */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .chat-form {
        padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
    }

    .sidebar-footer {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }

    .toast {
        bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* =========================================
   SIDEBAR COLLAPSE (DESKTOP)
   ========================================= */

@media (min-width: 769px) {

    .app-wrapper {
        position: relative;
    }

    .main-content {
        flex: 1 1 auto;
        width: 100%;
        margin-left: 0;
        min-width: 0;
    }

    .chat-container {
        width: 100%;
        max-width: 100%;
        padding-left: 260px;
        padding-right: 260px;
        margin-left: 0 !important;
        transition: none; /* No transition needed because it never moves */
    }

    .chat-header {
        min-height: var(--desktop-header-height);
        position: relative;
        z-index: 1001;
        background: var(--bg-primary);
    }

    /* The desktop drawer overlays the page, so hide/show never reflows content. */
    .sidebar {
        position: fixed;
        left: 0;
        top: var(--desktop-header-height);
        bottom: 0;
        z-index: 999;
        width: 260px;
        min-width: 260px;
        height: calc(100vh - var(--desktop-header-height));
        overflow: hidden;
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.34);
        transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.18s ease,
                    box-shadow 0.26s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }

    /* Collapsed state: slide the drawer away without changing layout width. */
    .app-wrapper.sidebar-collapsed .sidebar {
        width: 260px;
        min-width: 260px;
        height: calc(100vh - var(--desktop-header-height));
        padding-left: 0;
        padding-right: 0;
        border-right: 1px solid var(--border-subtle);
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
        transform: translateX(calc(-100% - 12px));
        box-shadow: none;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.34);
    }

    /* Force all direct children to maintain the exact 260px width so they don't squish during animation! */
    .sidebar > * {
        width: 260px;
        min-width: 260px;
        transition: opacity 0.3s ease;
    }

    /* Hide all children when collapsed so they don't visibly spill out over the main content */
    .app-wrapper.sidebar-collapsed .sidebar > * {
        opacity: 0;
        pointer-events: none;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar > * {
        opacity: 1;
        pointer-events: auto;
    }

    /* -- Text labels: fade out when collapsed -- */
    .sidebar-text,
    #sidebarUsername,
    .badge,
    .logout-icon,
    .chat-item-title,
    .chat-item-delete {
        transition: opacity 0.15s ease;
        white-space: nowrap;
    }

    .app-wrapper.sidebar-collapsed .sidebar-text,
    .app-wrapper.sidebar-collapsed #sidebarUsername,
    .app-wrapper.sidebar-collapsed .badge,
    .app-wrapper.sidebar-collapsed .logout-icon,
    .app-wrapper.sidebar-collapsed .chat-item-title,
    .app-wrapper.sidebar-collapsed .chat-item-delete {
        opacity: 0;
        pointer-events: none;
        position: absolute;
        overflow: hidden;
        width: 0;
        height: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-text,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open #sidebarUsername,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open .badge,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open .logout-icon,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open .chat-item-title,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open .chat-item-delete {
        opacity: 1;
        pointer-events: auto;
        position: relative;
        overflow: visible;
        width: auto;
        height: auto;
    }

    /* -- Top header row -- */
    .sidebar-header-top {
        transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .app-wrapper.sidebar-collapsed .sidebar-header-top {
        justify-content: center;
        padding: 16px 8px 12px 8px;
        position: relative;
        overflow: hidden;
        height: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-header-top {
        justify-content: space-between;
        padding: 16px 16px 12px 16px;
        height: auto;
        overflow: visible;
    }

    .sidebar-logo {
        transition: opacity 0.2s ease;
    }

    .app-wrapper.sidebar-collapsed .sidebar-logo {
        margin: 0 auto;
        cursor: pointer;
        opacity: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-logo {
        margin: 0;
        opacity: 1;
    }

    .desktop-collapse-btn {
        transition: opacity 0.2s ease;
    }

    .app-wrapper.sidebar-collapsed .desktop-collapse-btn {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) scaleX(-1);
        opacity: 0;
        z-index: 10;
        background: var(--bg-hover) !important;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .desktop-collapse-btn {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        opacity: 1;
        background: transparent !important;
        display: flex !important;
    }

    /* -- Sidebar header & footer padding shrink -- */
    .sidebar-header {
        transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar-footer {
        transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .app-wrapper.sidebar-collapsed .sidebar-header,
    .app-wrapper.sidebar-collapsed .sidebar-footer {
        padding-left: 0;
        padding-right: 0;
        overflow: hidden;
        height: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-header {
        padding-left: 1rem;
        padding-right: 1rem;
        height: auto;
        overflow: visible;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-footer {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        height: auto;
        overflow: visible;
    }

    /* -- Buttons & Items collapsed state -- */
    .app-wrapper.sidebar-collapsed .new-chat-btn {
        justify-content: center;
        border-color: transparent;
        padding: 0;
        width: 0;
        height: 0;
        margin: 0 auto;
        overflow: hidden;
    }

    .app-wrapper.sidebar-collapsed .sidebar-btn {
        justify-content: center;
        padding: 0;
        width: 0;
        height: 0;
        margin: 0 auto;
        overflow: hidden;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .new-chat-btn {
        justify-content: flex-start;
        width: 100%;
        height: auto;
        padding: 0.875rem 1rem;
        border-color: var(--border-light);
        margin-bottom: 0;
        overflow: visible;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-btn {
        justify-content: flex-start;
        width: 100%;
        height: auto;
        padding: 0.75rem 1rem;
        margin-bottom: 0.25rem;
        overflow: visible;
    }

    .new-chat-btn svg,
    .sidebar-btn svg,
    .chat-item svg {
        flex-shrink: 0;
    }

    .app-wrapper.sidebar-collapsed .new-chat-btn svg,
    .app-wrapper.sidebar-collapsed .sidebar-btn svg {
        margin: 0;
        display: none;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .new-chat-btn svg,
    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-btn svg {
        margin-right: 0;
        display: block;
    }

    .app-wrapper.sidebar-collapsed .sidebar-user {
        justify-content: center;
        padding: 0;
        background: transparent;
        border: none;
        overflow: hidden;
        height: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .sidebar-user {
        justify-content: space-between;
        padding: 0.75rem 1rem;
        background: rgba(232, 249, 124, 0.06);
        border: 1px solid rgba(232, 249, 124, 0.1);
        overflow: visible;
        height: auto;
    }

    .app-wrapper.sidebar-collapsed .chat-item {
        justify-content: center;
        padding: 0;
        overflow: hidden;
        height: 0;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .chat-item {
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        overflow: visible;
        height: auto;
    }

    .app-wrapper.sidebar-collapsed .chat-item svg {
        margin: 0;
        display: none;
    }

    .app-wrapper.sidebar-collapsed.sidebar-hover-open .chat-item svg {
        margin-right: 0;
        display: block;
    }



    /* Keep collapse click-only so hover never resizes the app layout. */
    .app-wrapper.force-collapse .sidebar {
        transform: translateX(calc(-100% - 12px)) !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition-delay: 0s !important;
    }
}

@media (max-width: 768px) {
    .desktop-collapse-btn {
        display: none !important;
    }
}


/* Editorial Next Buttons (TRY NEXT) */
.try-next-heading {
    margin: 0 0 1.35rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.try-next-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    padding-bottom: 1.1rem;
}

.editorial-next-btn {
    min-width: clamp(190px, 18vw, 345px);
    min-height: 48px;
    justify-content: center;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.55rem 1.2rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    font-family: 'Inter', sans-serif;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    text-align: center;
    white-space: normal;
}

.editorial-next-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-subtle);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .try-next-actions {
        gap: 0.75rem;
    }

    .editorial-next-btn {
        width: 100%;
        min-width: 0;
        min-height: 44px;
        font-size: 0.78rem;
        padding: 0.55rem 0.9rem;
    }
}

/* ── Direct Try-On Modal Tabs ─────────────────────────────────────────── */
.dt-tab {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.dt-tab.active {
    background: linear-gradient(135deg, rgba(232, 249, 124,0.15), rgba(212, 230, 92,0.1));
    border-color: rgba(232, 249, 124,0.4);
    color: var(--text-primary);
}
.dt-tab:hover:not(.active) {
    border-color: var(--text-tertiary);
}
#directTryonBtn {
    background: linear-gradient(135deg, rgba(232, 249, 124,0.15), rgba(212, 230, 92,0.1));
    border: 1px solid rgba(232, 249, 124,0.3);
}
#directTryonBtn:hover {
    border-color: rgba(232, 249, 124,0.6);
    background: linear-gradient(135deg, rgba(232, 249, 124,0.25), rgba(212, 230, 92,0.18));
}

/* ===== SEARCH SESSION GROUPS (FEED UI) ===== */
.search-session-group {
    display: flex;
    flex-direction: column;
    margin: 0 0 0.85rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, margin-bottom 0.2s ease;
    list-style: none;
}

.search-session-group.collapsed {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(232, 249, 124, 0.12);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.search-session-group.active {
    border: 1px solid rgba(232, 249, 124, 0.18);
    border-radius: 12px;
    background: rgba(232, 249, 124, 0.025);
    overflow: hidden;
}

.search-session-group.collapsed .session-content {
    display: none !important;
}

.session-header {
    width: 100%;
    border: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px;
    align-items: center;
    column-gap: 0.65rem;
    row-gap: 0.45rem;
    padding: 11px 13px;
    cursor: pointer;
    background: transparent;
    color: inherit;
    text-align: left;
    font: inherit;
    transition: background 0.2s ease;
}

.session-header:hover {
    background: var(--bg-tertiary);
}

.session-header-main {
    grid-column: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.session-label {
    flex-shrink: 0;
    border: 1px solid rgba(232, 249, 124, 0.32);
    border-radius: 999px;
    padding: 2px 7px;
    color: var(--accent-primary);
    background: rgba(232, 249, 124, 0.08);
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.session-tag {
    min-width: 0;
    font-size: 0.86rem;
    font-weight: 650;
    color: var(--phone-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    color: var(--phone-text-3);
    font-size: 0.68rem;
    font-weight: 700;
}

.session-meta span {
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.035);
}

.session-status {
    color: var(--accent-primary);
}

.session-header .chevron {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.search-session-group:not(.collapsed) .session-header {
    border-bottom: 1px solid var(--phone-border);
}

.search-session-group:not(.collapsed) .session-header .chevron {
    transform: rotate(180deg);
}

ul.session-content {
    list-style: none;
    padding: 0 0 0.7rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

@media (max-width: 640px) {
    .session-header {
        padding: 10px 11px;
    }

    .session-meta {
        max-width: none;
        justify-content: flex-start;
    }

    .session-sources {
        display: none;
    }
}
