:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --chat-user: rgba(139, 92, 246, 0.2);
    --chat-ai: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Typography */
h2 {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

p {
    line-height: 1.5;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.active {
    display: flex !important;
}

/* Layout Screens */
.screen {
    width: 100%;
    height: 100vh;
    display: flex;
}

/* ================= LOGIN SCREEN ================= */
#login-screen {
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    z-index: 10;
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px var(--primary));
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 30px;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 20px;
    animation: slideUp 0.3s ease;
}

.tab-content.active {
    display: flex;
}

/* Forms */
.input-group {
    text-align: left;
    margin-bottom: 15px;
    width: 100%;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(0, 0, 0, 0.4);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.primary-btn:active {
    transform: translateY(1px);
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 10px;
}

.text-btn:hover {
    color: white;
}

.telegram-instruction {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border-left: 4px solid #0088cc;
    font-size: 0.9rem;
    color: #e2e8f0;
    text-align: left;
}

.alert-box {
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.3);
    color: #fde047;
    padding: 15px;
    border-radius: 12px;
    font-size: 0.85rem;
    text-align: left;
    margin-bottom: 15px;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.glass-panel-dark {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
}

/* Background Balls Animation */
.floating-balls {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ball {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite alternate ease-in-out;
}

.ball-1 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    top: -100px;
    left: -100px;
}

.ball-2 {
    width: 400px;
    height: 400px;
    background: #ec4899;
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.ball-3 {
    width: 200px;
    height: 200px;
    background: #3b82f6;
    bottom: 20%;
    left: 20%;
    animation-delay: -10s;
}


/* ================= MAIN CHAT SCREEN ================= */
#chat-screen {
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    margin-left: -50px;
}

.sidebar-header .icon-btn {
    display: none;
}

.new-chat-btn {
    padding: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
    margin-bottom: 25px;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.menu-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.history-item {
    padding: 12px;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
    margin-bottom: 5px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
    margin-top: 10px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

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

.user-info span:first-child {
    font-weight: 600;
    font-size: 0.95rem;
}

.quota-badge {
    font-size: 0.75rem;
    color: #34d399;
    /* emerald-400 */
}

.icon-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 5px;
    width: auto;
    height: auto;
}

.icon-btn:hover {
    color: white;
    transform: scale(1.1);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.chat-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--glass-border);
}

.mobile-only {
    display: none;
    position: absolute;
    left: 20px;
}

select {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

select option {
    background: #1e1b4b;
}

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

.welcome-box {
    margin: auto;
    text-align: center;
    animation: slideUp 0.5s ease;
    max-width: 500px;
}

.welcome-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px var(--primary));
}

.welcome-box h2 {
    margin-bottom: 10px;
}

.welcome-box p {
    color: var(--text-muted);
}

/* Chat Bubbles */
.chat-row {
    display: flex;
    margin-bottom: 25px;
    animation: fadeIn 0.3s ease;
}

.chat-row.user-row {
    justify-content: flex-end;
}

.chat-row.ai-row {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.user-row .chat-bubble {
    background: var(--chat-user);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-bottom-right-radius: 4px;
}

.ai-row .chat-bubble {
    background: var(--chat-ai);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

/* Chat Input */
.chat-input-area {
    padding: 20px 40px 30px;
}

form#form-chat {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    padding: 10px 15px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    padding: 10px;
    resize: none;
    max-height: 150px;
    outline: none;
    font-family: inherit;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
}

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

.input-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0) scale(1);
    }

    100% {
        transform: translateY(-50px) scale(1.1);
    }
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Markdown styling inside AI bubble */
.chat-bubble code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.chat-bubble pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -300px;
        background: rgba(15, 23, 42, 0.95);
        /* solid background on mobile */
    }

    .sidebar.open {
        left: 0;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .mobile-only {
        display: block;
    }

    .sidebar-header .icon-btn {
        display: block;
    }

    .chat-bubble {
        max-width: 85%;
    }

    .chat-input-area {
        padding: 15px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.toast {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-size: 0.95rem;
    font-weight: 500;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.error {
    border-left-color: #ef4444;
    /* red-500 */
}

.toast.success {
    border-left-color: #10b981;
    /* emerald-500 */
}