/* --- 0. FORCE LOAD FONTS & ICONS --- */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* --- 1. CSS VARIABLES (GEMINI PALETTE) --- */
:root {
    --jem-primary: #1d4ed8; 
    --jem-primary-grad: linear-gradient(135deg, #4285f4 0%, #9b72cb 50%, #d96570 100%);
    --jem-user-bubble: #eef2ff;
    --jem-ai-bubble: #ffffff;
    --jem-bg-app: #f0f4f9;
    --jem-border: #e2e8f0;
    --jem-text-main: #1f2937;
    --jem-text-soft: #6b7280;
    --jem-radius-lg: 24px;
    --jem-radius-md: 16px;
    --jem-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    --jem-font: 'Inter', system-ui, -apple-system, sans-serif;
    --jem-z-index: 2147483647;
}

/* --- 2. WIDGET ISOLATION & RESET --- */
#jem-widget-root {
    font-family: var(--jem-font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--jem-text-main);
    text-align: left;
    -webkit-font-smoothing: antialiased;
}
#jem-widget-root * { box-sizing: border-box !important; outline: none; }
#jem-widget-root p, #jem-widget-root h1, #jem-widget-root h2, #jem-widget-root h3 {
    margin: 0; padding: 0; font-weight: normal;
}
#jem-widget-root .material-symbols-rounded {
    font-family: 'Material Symbols Rounded' !important;
    font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
    display: inline-block; white-space: nowrap; direction: ltr;
    text-transform: none !important; letter-spacing: normal !important;
    color: inherit;
}

/* --- NEW: Markdown Lists Support --- */
#jem-widget-root ul {
    margin: 8px 0 8px 10px;
    padding-left: 0;
    list-style: none;
}
#jem-widget-root li {
    position: relative;
    padding-left: 15px;
    margin-bottom: 4px;
}
#jem-widget-root li::before {
    content: "•";
    position: absolute; left: 0; color: var(--jem-primary);
    font-weight: bold;
}

/* --- 3. HERO WIDGET --- */
.jem-hero-wrapper {
    width: 100%; max-width: 800px; margin: 40px auto; padding: 0 20px;
    font-family: var(--jem-font); text-align: center;
}
.jem-hero-container { display: flex; flex-direction: column; gap: 20px; }
.jem-hero-input-group {
    position: relative; width: 100%;
    background: white; border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex; align-items: center; padding: 8px 12px;
    border: 1px solid transparent; transition: all 0.2s;
}
.jem-hero-input-group:focus-within {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12); border-color: #dbeafe;
}
.jem-hero-icon { color: #9ca3af; margin-left: 12px; user-select: none; }
.jem-hero-input {
    flex: 1; border: none; background: transparent; padding: 12px 16px;
    font-size: 18px; color: var(--jem-text-main); outline: none;
}
.jem-hero-btn {
    width: 48px; height: 48px; border-radius: 50%; border: none;
    background: var(--jem-primary-grad); color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
.jem-hero-btn:hover { transform: scale(1.05); }

/* Chips */
.jem-hero-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.jem-chip {
    background: white; border: 1px solid var(--jem-border);
    padding: 10px 16px; border-radius: 999px;
    font-size: 14px; color: var(--jem-text-main);
    cursor: pointer; transition: all 0.2s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 0 0 auto; 
}
@media (min-width: 768px) {
    .jem-chip { flex: 0 0 calc(25% - 12px); text-align: center; }
}
@media (max-width: 767px) {
    .jem-chip { flex: 1 1 auto; }
}
.jem-chip:hover {
    background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.1);
}

/* --- 4. LAUNCHER (FAB) --- */
.jem-launcher {
    position: fixed; bottom: 24px; right: 24px;
    width: 60px; height: 60px; border-radius: 50%;
    background: var(--jem-primary-grad); border: none; cursor: pointer;
    box-shadow: 0 4px 20px rgba(66, 133, 244, 0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: var(--jem-z-index); transition: transform 0.3s;
}
.jem-launcher:hover { transform: scale(1.1) rotate(10deg); }
#jem-widget-root button.jem-launcher .material-symbols-rounded {
    font-size: 32px !important; color: white !important; visibility: visible !important;
}

/* --- 5. MAIN WINDOW --- */
.jem-window {
    position: fixed; bottom: 100px; right: 24px;
    width: 400px; height: 650px;
    max-width: calc(100vw - 48px); max-height: calc(100vh - 140px);
    background: var(--jem-bg-app); border-radius: var(--jem-radius-lg);
    box-shadow: var(--jem-shadow); border: 1px solid rgba(255,255,255,0.8);
    display: flex; flex-direction: column; overflow: hidden;
    z-index: var(--jem-z-index);
    opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.jem-window.active { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.jem-window.no-transition { transition: none !important; }

/* --- NEW: Fullscreen Mode --- */
.jem-window.jem-fullscreen {
    width: 96vw;
    height: 94vh;
    right: 2vw;
    bottom: 3vh;
    max-width: none;
    max-height: none;
    border-radius: 12px;
}
@media (max-width: 768px) {
    .jem-window.jem-fullscreen {
        width: 100%; height: 100%; right: 0; bottom: 0; border-radius: 0;
    }
}

/* --- 6. HEADER --- */
.jem-header {
    height: 64px; padding: 0 20px; background: rgba(255,255,255,0.9);
    backdrop-filter: blur(8px); display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--jem-border); flex-shrink: 0;
}
.jem-brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 16px;
    background: var(--jem-primary-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.jem-header-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--jem-text-soft); padding: 6px;
    border-radius: 50%; transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.jem-header-btn:hover { background: rgba(0,0,0,0.05); color: var(--jem-text-main); }


/* --- 7. CHAT BODY --- */
.jem-chat-body {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 20px;
    background: var(--jem-bg-app); scroll-behavior: smooth;
}
.jem-chat-body::-webkit-scrollbar { width: 6px; }
.jem-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.jem-msg {
    max-width: 85%; padding: 14px 18px; font-size: 16px; /* Slightly bigger text */
    line-height: 1.5;
    position: relative; word-wrap: break-word; animation: jemFadeUp 0.3s ease-out forwards;
}
@keyframes jemFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.jem-msg.ai {
    align-self: flex-start; background: var(--jem-ai-bubble); color: var(--jem-text-main);
    border-radius: 4px var(--jem-radius-lg) var(--jem-radius-lg) var(--jem-radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.jem-msg.user {
    align-self: flex-end; background: var(--jem-user-bubble); color: #1a1a1a;
    border-radius: var(--jem-radius-lg) var(--jem-radius-lg) 4px var(--jem-radius-lg);
}

/* --- 8. PRODUCT CARDS --- */
.jem-products-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px; margin-top: 10px; width: 100%;
}
.jem-product-card {
    background: white; border-radius: var(--jem-radius-md); overflow: hidden;
    border: 1px solid var(--jem-border); transition: transform 0.2s;
    display: flex; flex-direction: column; text-decoration: none !important;
}
.jem-product-card:hover { transform: translateY(-4px); box-shadow: 0 8px 16px rgba(0,0,0,0.08); }
.jem-card-img {
    width: 100%; height: 120px; object-fit: contain; padding: 12px;
    background: #fff; border-bottom: 1px solid #f3f4f6;
}
.jem-card-info { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.jem-card-title {
    font-size: 13px; font-weight: 600; color: var(--jem-text-main);
    margin-bottom: 4px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.jem-card-price { margin-top: auto; font-size: 13px; font-weight: 700; color: #16a34a; }

/* --- 9. INPUT AREA (UPDATED) --- */
.jem-footer { padding: 16px 20px; background: var(--jem-bg-app); }
.jem-input-box {
    background: white; border-radius: 9999px; 
    padding: 8px 12px 8px 24px; /* Increased padding */
    display: flex; align-items: center; /* Center Vertically */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid transparent; transition: all 0.2s;
}
.jem-input-box:focus-within { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: #dbeafe; }
.jem-input {
    flex: 1; 
    max-height: 120px; 
    border: none; background: transparent;
    font-size: 18px; /* HERO SIZE */
    font-family: var(--jem-font); /* Inter */
    padding: 6px 0; /* Adjustment */
    resize: none; 
    color: var(--jem-text-main);
    line-height: 1.4;
}
.jem-input::placeholder { color: #9ca3af; }
.jem-send-btn {
    width: 42px; height: 42px; border-radius: 50%; background: transparent;
    border: none; cursor: pointer; color: var(--jem-text-main);
    display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.jem-send-btn:hover { background: #f3f4f6; color: var(--jem-primary); }

/* --- 10. TYPING INDICATOR --- */
.jem-typing { display: flex; gap: 4px; align-items: center; padding: 0 4px; }
.jem-dot { width: 6px; height: 6px; background: #9ca3af; border-radius: 50%; animation: jemBounce 1.4s infinite; }
.jem-dot:nth-child(1) { animation-delay: -0.32s; }
.jem-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes jemBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- 11. MOBILE --- */
@media (max-width: 480px) {
    .jem-window { bottom: 0; right: 0; width: 100%; height: 100%; border-radius: 0; }
    .jem-launcher { bottom: 20px; right: 20px; }
}

/* Mobile Scroll Lock */
body.jem-noscroll {
    overflow: hidden !important;
    height: 100vh;
}