:root {
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary-color: #ec4899;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Lock the base */
}

body {
    font-family: 'Inter', sans-serif;
    background: #0f172a;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
}

/* Main Chat Area - Robust Full Screen */
.chat-main {
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top left, #1e293b, #0f172a);
    position: fixed; /* Use fixed for maximum stability */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile gadgets */
    overflow: hidden;
}

.chat-header {
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(15px);
    z-index: 10;
}

.bot-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.bot-info h2 {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.online-status {
    font-size: 0.7rem;
    color: #10b981;
    display: block;
}

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

.action-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.action-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.menu-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

/* Messages Area - With scrolling */
.messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Momentum scrolling for iOS */
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    scroll-behavior: smooth;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    min-height: 0; /* Essential for flex-box scrolling */
}

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

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

.message.user {
    align-self: flex-end;
}

.message.bot {
    align-self: flex-start;
}

.msg-content {
    padding: 0.8rem 1.1rem;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .msg-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .msg-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

/* Auth Overlay */
.auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(25px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.auth-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
    animation: fadeIn 0.8s ease-out;
}

.auth-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-content p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--text-main);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

#user-id-input, #user-pass-input {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    outline: none;
    text-align: center;
    transition: var(--transition-smooth);
}

#user-id-input:focus, #user-pass-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

#start-chat-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1.1rem;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

#start-chat-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.app-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.2rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    z-index: 5;
    animation: fadeIn 1s ease-out;
}

.app-footer i {
    font-size: 0.8rem;
    margin: 0 4px;
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    padding: 0.4rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#user-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-main);
    padding: 0.6rem;
    resize: none;
    outline: none;
    font-size: 1rem;
    max-height: 120px;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* Responsive Media Queries */

/* Tablet & Smaller Desktop (below 1024px) */
@media (max-width: 1024px) {
    .messages-container, .input-wrapper {
        max-width: 90%;
    }
}

/* Large Mobile / Small Tablet (below 768px) */
@media (max-width: 768px) {
    .bot-info h2 { font-size: 1rem; }
    .action-btn span { display: none; }
    .action-btn { padding: 0.5rem; }
    
    .msg-content {
        font-size: 0.95rem;
        padding: 0.7rem 1rem;
    }
    
    .auth-content {
        width: 90%;
        padding: 1.5rem;
    }
    
    .auth-icon { font-size: 3rem; }
}

/* Small Mobile (below 480px) */
@media (max-width: 480px) {
    .chat-header { padding: 0.75rem 1rem; }
    
    .messages-container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .message { max-width: 90%; }
    
    .input-area { padding: 0.75rem 1rem; }
    
    .input-wrapper {
        border-radius: 20px;
        gap: 0.5rem;
    }
    
    #user-input { font-size: 0.9rem; }
    
    .app-footer {
        font-size: 0.75rem;
        padding: 1rem;
    }
}

/* Animation for typing dots */
@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}
