/* ai chat page */

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

/* html */
html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* body */
body {
    font-family: "Vazirmatn", sans-serif;
    background: #060816;
    color: #fff;
}

:root {
    --primary: #7c5cff;
    --secondary: #00d4ff;
    --glass: rgba(255, 255, 255, .05);
    --glass-border: rgba(255, 255, 255, .08);
}

/* app */
.app {
    display: flex;
    width: 100%;
    /* app-h tracks the visual viewport, keyboard included */
    height: var(--app-h, 100%);
    max-height: var(--app-h, 100%);
    position: relative;
    z-index: 5;
}

/* bg container */
.bg-container {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

/* aurora */
.aurora {
    position: absolute;
    width: 700px;
    height: 700px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: .35;
    animation: float 18s ease-in-out infinite;
}

.aurora-1 { background: #7c5cff; top: -200px; right: -150px; }
.aurora-2 { background: #00d4ff; bottom: -250px; left: -150px; animation-delay: 4s; }
.aurora-3 { background: #5bffbc; top: 40%; left: 40%; animation-delay: 8s; }

/* grid overlay */
.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* chat wrapper */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* topbar */
.topbar {
    height: 65px;
    backdrop-filter: blur(20px);
    background: rgba(6, 8, 22, .7);
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

/* topbar left */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* logo mini */
.logo-mini {
    display: flex;
    align-items: center;
}

/* model info */
.model-info h2 {
    font-size: 15px;
    font-weight: 600;
}

.model-info span {
    font-size: 10px;
    color: #68ff95;
}

/* new chat */
.new-chat-btn {
    border: none;
    cursor: pointer;
    height: 38px;
    padding: 0 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(124, 92, 255, .35);
    font-family: "Vazirmatn";
    font-size: 12px;
}

.new-chat-btn span {
    display: inline-block;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124, 92, 255, .5);
}

/* chat messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    height: 100%;
}

/* scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--primary), var(--secondary));
    border-radius: 10px;
}

/* welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    min-height: 300px;
}

/* hero icon */
.hero-icon {
    width: 100px;
    height: 100px;
    margin-bottom: 16px;
    animation: pulse 4s infinite;
}

.hero-icon svg {
    width: 100%;
    height: 100%;
}

/* welcome screen */
.welcome-screen h1 {
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.welcome-screen p {
    color: #9ca3af;
    max-width: 500px;
    line-height: 1.7;
    font-size: 13px;
    margin-bottom: 16px;
}

/* badges */
.badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* badge */
.badge {
    padding: 5px 12px;
    border-radius: 30px;
    background: rgba(124, 92, 255, .15);
    border: 1px solid rgba(124, 92, 255, .3);
    font-size: 11px;
    color: #b8a8ff;
}

/* message */
.message {
    display: flex;
    width: 100%;
    /* no shrink: the list scrolls instead of squashing */
    flex-shrink: 0;
    animation: messageAppear .3s ease;
}

.message.user { 
    justify-content: flex-end;
}

.message.ai { 
    justify-content: flex-start;
}

/* message content */
.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.65;
    font-size: 13px;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    backdrop-filter: blur(20px);
    transition: .2s;
}

/* message */
.message.user .message-content {
    background: linear-gradient(135deg, rgba(124, 92, 255, .25), rgba(124, 92, 255, .08));
    border: 1px solid rgba(124, 92, 255, .25);
    border-radius: 18px 18px 4px 18px;
}

.message.ai .message-content {
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 18px 18px 18px 4px;
}

/* user text keeps its line breaks */
.message.user .message-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* message time */
.message-time {
    margin-top: 6px;
    font-size: 9px;
    color: #8d93a5;
    text-align: left;
}

/* copy btn */
.copy-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 26px;
    height: 26px;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
    color: white;
    opacity: 0;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-content:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .18); transform: scale(1.05); }

/* typing container */
.typing-container {
    display: none;
    padding: 0 16px 12px;
}

.typing-container.active { display: block; }

/* inline while it sits in the message list */
.chat-messages > .typing-container { padding: 0; flex-shrink: 0; }

/* typing bubble */
.typing-bubble {
    width: 70px;
    height: 38px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
}

.typing-bubble span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: typingBounce 1s infinite;
}

.typing-bubble span:nth-child(2) { animation-delay: .15s; }
.typing-bubble span:nth-child(3) { animation-delay: .3s; }

/* input area */
.input-area {
    padding: 12px 16px;
    background: linear-gradient(to top, rgba(6, 8, 22, .95), rgba(6, 8, 22, .8));
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, .05);
    flex-shrink: 0;
}

/* input box */
.input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 100%;
}

/* messageInput */
#messageInput {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    min-height: 44px;
    max-height: 260px;
    border-radius: 22px;
    padding: 12px 16px;
    font-family: "Vazirmatn";
    font-size: 13px;
    color: white;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .08);
}

#messageInput::placeholder { color: #8b93a5; }
#messageInput:focus {
    border: 1px solid rgba(124, 92, 255, .45);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, .12);
}

/* input footer */
.input-footer {
    text-align: center;
    margin-top: 8px;
    color: #798095;
    font-size: 10px;
}

.message-content h1 { font-size: 20px; margin: 10px 0 6px; color: var(--primary); }
.message-content h2 { font-size: 17px; margin: 8px 0 5px; color: var(--secondary); }
.message-content h3 { font-size: 15px; margin: 6px 0 4px; }
.message-content ul, .message-content ol { margin: 6px 0; padding-right: 20px; }
.message-content li { margin: 3px 0; }
.message-content p { margin: 5px 0; line-height: 1.65; }
.message-content strong, .message-content b { color: #00d4ff; }
/* message content */
.message-content code, .message-content .formula {
    background: rgba(124, 92, 255, 0.15);
    padding: 1px 5px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    direction: ltr;
    display: inline-block;
}
.message-content pre {
    background: #0d1222;
    padding: 8px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 8px 0;
}
.message-content blockquote {
    border-right: 3px solid var(--primary);
    padding-right: 10px;
    margin: 6px 0;
    color: #cfd3dc;
}

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

@keyframes typingBounce {
    0%,80%,100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-6px); opacity: 1; }
}

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

@keyframes pulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* mouse glow */
.mouse-glow {
    position: fixed;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, rgba(124, 92, 255, .1), transparent 70%);
    transform: translate(-50%, -50%);
    z-index: 1;
    transition: left .05s linear, top .05s linear;
}

/* particles */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* particle */
.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    from { transform: translateY(120vh) translateX(0); opacity: 0; }
    10% { opacity: 0.5; }
    90% { opacity: 0.5; }
    to { transform: translateY(-20vh) translateX(40px); opacity: 0; }
}

/* mobile 768px */
@media (max-width: 768px) {
    .topbar { padding: 0 12px; height: 55px; }
    .new-chat-btn span { display: none; }
    .new-chat-btn { padding: 0 12px; }
    .chat-messages { padding: 12px; gap: 12px; }
    .message-content { max-width: 85%; padding: 10px 14px; font-size: 12px; }
    .input-area { padding: 10px 12px; }
    #messageInput { min-height: 40px; font-size: 12px; padding: 10px 14px; }
    .model-info h2 { font-size: 13px; }
    .model-info span { font-size: 9px; }
    .welcome-screen h1 { font-size: 22px; }
    .hero-icon { width: 80px; height: 80px; }
}

/* mobile 480px */
@media (max-width: 480px) {
    .message-content { max-width: 90%; }
    .message-content h1 { font-size: 17px; }
    .message-content h2 { font-size: 15px; }
    .badge { font-size: 9px; padding: 3px 8px; }
    .mouse-glow { display: none; }
}

/* nav buttons */
.nav-buttons {
    display: flex;
    gap: 10px;
    margin-left: 15px;
}

/* nav btn */
.nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-family: "Vazirmatn", sans-serif;
    font-size: 13px;
    font-weight: 500;
}

.nav-btn i,
.nav-btn svg.icon {
    font-size: 14px;
}

.nav-btn span {
    display: inline-block;
}

.nav-btn:hover {
    background: linear-gradient(135deg, rgba(124, 92, 255, 0.3), rgba(0, 212, 255, 0.3));
    border-color: rgba(124, 92, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 92, 255, 0.2);
}

/* mobile 768px */
@media (max-width: 768px) {
    .nav-buttons {
        gap: 8px;
    }
    
    .nav-btn span {
        display: none;
    }
    
    .nav-btn {
        padding: 8px 12px;
    }
    
    .nav-btn i,
    
    .nav-btn svg.icon {
        font-size: 16px;
    }
}