@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --text-color: #f8fafc;
    /* GTA V Vibe uses some neon greens and striking colors */
    --accent-color: #10b981; 
    --accent-hover: #059669;
    --glass-bg: rgba(15, 15, 20, 0.45); 
    --glass-border: rgba(255, 255, 255, 0.08);
    --user-msg: rgba(16, 185, 129, 0.15); 
    --bot-msg: rgba(255, 255, 255, 0.06);
}

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

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Modern mobile UI height natively */
    overflow: hidden;
    position: relative;
    background-color: #050505;
}

/* Bokeh background effect mirroring the image */
.bg-bokeh {
    position: absolute;
    top: -20%;
    left: -20%;
    width: 140vw;
    height: 140vh;
    z-index: -2;
    /* Drawing multiple blurred orbs of color */
    background: 
        radial-gradient(circle at 20% 40%, rgba(16, 185, 129, 0.6) 0%, transparent 40%),  /* Green */
        radial-gradient(circle at 75% 25%, rgba(59, 130, 246, 0.6) 0%, transparent 40%),  /* Blue */
        radial-gradient(circle at 60% 70%, rgba(239, 68, 68, 0.5) 0%, transparent 45%),   /* Red */
        radial-gradient(circle at 35% 80%, rgba(245, 158, 11, 0.4) 0%, transparent 40%);  /* Orange */
    filter: blur(60px);
    animation: bokehMove 15s ease-in-out infinite alternate;
}

/* Add rain/noise texture overlay to simulate raindrops on glass */
.bg-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    opacity: 0.25;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
}

@keyframes bokehMove {
    0% { transform: scale(1) translate(0, 0); }
    50% { transform: scale(1.05) translate(2%, 3%); }
    100% { transform: scale(1) translate(-2%, -2%); }
}

#app-wrapper {
    width: 100%;
    max-width: 1000px;
    height: 85vh; /* slightly less to show more background and footer */
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    margin: 0 10px;
    z-index: 10;
}

@media (max-width: 600px) {
    #app-wrapper {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100dvh;
        width: 100%;
        border-radius: 0;
        margin: 0;
        border: none;
    }
    header {
        padding: 16px;
    }
    header h1 {
        font-size: 1.1rem; /* Prevent wide pixel-font overflow on narrow screens */
        letter-spacing: 0px;
    }
    #chat-container {
        padding: 15px;
        gap: 16px;
    }
    .message {
        max-width: 95%; /* Use more available width */
        padding: 12px 16px;
        font-size: 0.95rem;
        border-radius: 18px;
    }
    .input-area {
        /* Support iOS safe area insets to push input above the home bar */
        padding: 12px 12px max(12px, env(safe-area-inset-bottom)) 12px;
        gap: 8px;
    }
    .upload-btn {
        width: 44px;
        height: 44px;
    }
    button#sendBtn {
        height: 48px;
        padding: 0 20px;
        font-size: 0.95rem;
    }
    footer {
        display: none; /* Prevents overlap since wrapper takes full screen */
    }
}

header {
    padding: 22px;
    text-align: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

header h1 {
    font-family: 'Press Start 2P', system-ui, cursive;
    font-weight: 400;
    font-size: 1.8rem;
    color: #10b981;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

#chat-container::-webkit-scrollbar {
    width: 8px;
}
#chat-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
#chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.message {
    max-width: 80%;
    padding: 16px 24px;
    border-radius: 24px;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 1.05rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.user {
    align-self: flex-end;
    background: var(--user-msg);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-bottom-right-radius: 6px;
}

.bot {
    align-self: flex-start;
    background: var(--bot-msg);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(10px);
}

.input-area {
    padding: 24px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.upload-btn {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.upload-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    transform: translateY(-2px);
}

#imagePreviewContainer {
    position: relative;
    display: none;
    margin-bottom: 8px;
}

#imagePreview {
    height: 70px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#removeImageBtn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s;
}

#removeImageBtn:hover {
    transform: scale(1.15);
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 10px;
    transition: border-color 0.3s, background 0.3s;
}

.input-wrapper:focus-within {
    border-color: rgba(16, 185, 129, 0.6);
    background: rgba(0, 0, 0, 0.3);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: white;
    padding: 8px 12px;
    font-size: 1.05rem;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 160px;
    min-height: 24px;
    line-height: 1.5;
    overflow-y: auto;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

textarea::-webkit-scrollbar {
    width: 4px;
}
textarea::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

button#sendBtn {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    border: none;
    height: 50px;
    padding: 0 28px;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    flex-shrink: 0;
    margin-bottom: 2px;
}

button#sendBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5);
}

button#sendBtn:disabled {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    transform: none;
}

.typing {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 25px;
    margin-bottom: 15px;
    display: none;
    align-items: center;
    gap: 8px;
}

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

.dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.message img {
    max-width: 100%;
    border-radius: 16px;
    margin-bottom: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Footer style */
footer {
    position: absolute;
    bottom: 20px;
    text-align: center;
    width: 100%;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    font-weight: 300;
}
footer span {
    font-family: 'Press Start 2P', system-ui, cursive;
    font-weight: 400;
    font-size: 0.75rem;
    color: #10b981;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.bot-action-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.bot-action-btn {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    cursor: pointer;
    margin-top: 16px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.bot-action-btn svg {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bot-action-btn:hover {
    color: #fff;
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16,185,129,0.8), rgba(5,150,105,0.8));
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.bot-action-btn:hover svg {
    transform: scale(1.15) rotate(-5deg);
}

.bot-action-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.bot-action-btn.speaking, .bot-action-btn.copied {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.bot-action-btn.speaking:hover, .bot-action-btn.copied:hover {
    background: linear-gradient(135deg, rgba(239,68,68,0.8), rgba(220,38,38,0.8));
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Markdown Styles */
.markdown-body pre {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.95rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.markdown-body pre::-webkit-scrollbar {
    height: 8px;
}
.markdown-body pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Courier New', monospace;
    color: #38bdf8;
    font-size: 0.9em;
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
}

.markdown-body p {
    margin-bottom: 8px;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}

.markdown-body strong {
    color: #fff;
    font-weight: 600;
}

.markdown-body em {
    color: #e2e8f0;
    font-style: italic;
}

.markdown-body ul, .markdown-body ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

