:root {
    --bg-color: #ffffff !important;
    --sidebar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 250, 0.98) 100%) !important;
    --chat-bg: transparent !important;
    --input-bg: rgba(255, 255, 255, 0.95) !important;
    --text-primary: #1a1a1a !important;
    --text-secondary: #6b7280 !important;
    --border-color: rgba(0, 0, 0, 0.1) !important;
    --user-msg-bg: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(168, 85, 247, 0.08) 100%) !important;
    --ai-msg-bg: rgba(255, 255, 255, 0.9) !important;
    --accent-color: #6366f1 !important;
    --accent-secondary: #a855f7 !important;
    --success-color: #10b981 !important;
    --hover-color: rgba(99, 102, 241, 0.1) !important;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
    --glow: 0 0 20px rgba(99, 102, 241, 0.15) !important;
}

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

body {
    background: #ffffff !important;
    background-image: 
        radial-gradient(ellipse at top, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%) !important;
    color: #1a1a1a !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, rgba(99, 102, 241, 0.02) 1px, transparent 1px),
        linear-gradient(rgba(99, 102, 241, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

/* Language Switcher */
.language-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 99999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    padding: 8px;
    border-radius: 14px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 0 24px rgba(99, 102, 241, 0.1);
}

.lang-btn {
    padding: 10px 20px;
    background: transparent;
    color: #6b7280;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.lang-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: #1a1a1a;
    transform: translateY(-2px);
}

.lang-btn.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white !important;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.5);
}
    opacity: 0.3;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    backdrop-filter: blur(2px);
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    display: none;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: radial-gradient(ellipse at top, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-bottom: 32px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.08) 100%);
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    position: relative;
    overflow: hidden;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    to { left: 100%; }
}

.logo-icon {
    font-size: 1.8rem;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
}

.sidebar-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #f5f5f7 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.new-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4), 0 0 32px rgba(99, 102, 241, 0.2);
}

.new-chat-btn:hover::before {
    opacity: 1;
}

.new-chat-btn:active {
    transform: translateY(0);
}

.admin-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.15) 100%);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9rem;
    font-weight: 600;
    color: #fbbf24;
    margin-bottom: 20px;
}

.admin-link:hover {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25) 0%, rgba(245, 158, 11, 0.25) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.3);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.history-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 12px 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.history-item i {
    transition: transform 0.2s;
}

.history-item:hover {
    background: var(--hover-color);
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.2);
    transform: translateX(4px);
}

.history-item:hover i {
    transform: scale(1.1);
}

.history-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.1) 100%);
    color: var(--accent-color);
    border-color: rgba(99, 102, 241, 0.3);
    font-weight: 500;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    margin-top: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-profile:hover {
    background-color: var(--hover-color);
}

.avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info .name {
    font-size: 0.95rem;
    font-weight: 600;
}

.user-info .status {
    font-size: 0.75rem;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.user-info .status::before {
    content: '';
    width: 7px;
    height: 7px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse 2s infinite;
}

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

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    margin-top: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ef4444;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Main Chat Interface */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent; 
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

.chat-header {
    width: 100%;
    max-width: 1400px;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    margin-bottom: 0;
}

.header-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

#mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
}

.model-selector {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
}

.model-selector:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
}

.model-selector select {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-weight: 600;
    outline: none;
    cursor: pointer;
    margin-left: 5px;
}

.model-selector select option {
    background-color: #ffffff;
    color: var(--text-primary);
}

.backend-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
}

.backend-status i {
    color: var(--success-color);
    font-size: 1rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse 2s infinite;
}

.status-text {
    color: var(--success-color);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Chat Wrapper - The Floating Window */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 80px);
    background: transparent;
    backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    margin-top: 0;
}

.chat-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), transparent);
}

/* Chat Area */
#chat-container {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 20px 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

#welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-primary);
    text-align: center;
}

.welcome-icon {
    font-size: 5rem;
    margin-bottom: 32px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 32px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

.welcome-logo {
    width: 200px;
    height: auto;
    max-width: 80%;
    margin-bottom: 32px;
    filter: drop-shadow(0 10px 30px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

.auth-logo {
    width: 120px;
    height: auto;
    margin-bottom: 24px;
    filter: drop-shadow(0 8px 24px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

.admin-logo {
    width: 100px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.3));
}

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

#welcome-screen h2 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f5f5f7 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

#welcome-screen p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

#chat {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0 20px;
}

.message-row {
    display: flex;
    padding: 24px;
    gap: 20px;
    width: 100%;
    border-radius: 16px;
    margin-bottom: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.message-row:hover {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(99, 102, 241, 0.1);
    transform: translateX(4px);
}

.message-row.user-message {
    background: var(--user-msg-bg);
    border-color: rgba(99, 102, 241, 0.15);
}

.message-row.ai-message {
    background: var(--ai-msg-bg);
    border-color: rgba(255, 255, 255, 0.05);
}

.message-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.message-row:hover .message-avatar {
    transform: scale(1.05);
}

.user-avatar {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.ai-avatar {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
    color: var(--accent-color);
    border: 2px solid rgba(99, 102, 241, 0.3);
}

.message-content {
    flex: 1;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-wrap: break-word;
}

/* Markdown Styles */
.message-content p { margin-bottom: 1em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content code {
    background: rgba(99, 102, 241, 0.12);
    color: #a78bfa;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.9em;
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.message-content pre {
    background: rgba(10, 11, 15, 0.8) !important;
    padding: 24px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
}
.message-content pre code {
    background: transparent;
    padding: 0;
    color: #e0e0e0;
    border: none;
}
.message-content ul, .message-content ol {
    margin-left: 25px;
    margin-bottom: 1em;
}

/* Input Area */
.input-area {
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    width: 100%;
    background: var(--input-bg);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.input-wrapper:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.1),
        0 0 32px rgba(99, 102, 241, 0.2);
    background: rgba(255, 255, 255, 1);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 1.05rem;
    resize: none;
    outline: none;
    max-height: 250px;
    padding: 0;
    margin: 0;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder {
    color: #9ca3af;
}

#send-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    color: white;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    position: relative;
    overflow: hidden;
}

#send-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

#send-btn:hover::before {
    left: 100%;
}

#send-btn:active {
    transform: translateY(0);
}

.disclaimer {
    font-size: 0.8rem;
    color: #6e7080;
    margin-top: 15px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.4) 0%, rgba(168, 85, 247, 0.4) 100%);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.6) 0%, rgba(168, 85, 247, 0.6) 100%);
    background-clip: padding-box;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        height: 100%;
        box-shadow: 5px 0 30px rgba(0,0,0,0.5);
    }
    
    .sidebar.open {
        transform: translateX(300px);
    }
    
    #mobile-menu-btn {
        display: block;
    }
    
    .message-row {
        padding: 20px;
        flex-direction: column;
        gap: 10px;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    
    .input-wrapper {
        border-radius: 12px;
        padding: 12px;
    }

    #chat-container {
        padding-top: 60px;
    }
}
