:root {
    --bg-dark: #0f0f13;
    --bg-panel: rgba(255, 255, 255, 0.03);
    --bg-message-ai: rgba(255, 255, 255, 0.05);
    --bg-message-user: #3a86ff;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #3a86ff;
    --accent-glow: rgba(58, 134, 255, 0.4);
    --danger-color: #ff3d00;
    --danger-glow: rgba(255, 61, 0, 0.3);
    --border-glass: rgba(255, 255, 255, 0.08);
    --font-main: 'Outfit', sans-serif;
    --font-ui: 'Plus Jakarta Sans', sans-serif;
    --status-ready: #00c853;
    --status-thinking: #ffd600;
    --status-error: #ff3d00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.background-fx {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, #3a86ff 0%, transparent 70%);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, #7b2cbf 0%, transparent 70%);
    animation-delay: -10s;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    mask-image: radial-gradient(circle at center, black 40%, transparent 100%);
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

.layout-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    position: relative;
    min-width: 0;
}

/*                                            */
/*                   SIDEBAR                  */
/*                                            */

.sidebar {
    width: 260px;
    background: rgba(15, 15, 19, 0.8);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .sidebar-header {
    padding: 1rem 0;
}

.sidebar-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    justify-content: flex-start;
}

.sidebar.collapsed .sidebar-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed #new-chat-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
}

.sidebar.collapsed #new-chat-btn i {
    font-size: 1.2rem;
}

.sidebar.collapsed #new-chat-btn .btn-text {
    display: none;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.sidebar-btn i {
    font-size: 1.1rem;
    min-width: 20px;
    text-align: center;
}

.btn-text {
    opacity: 1;
    transition: opacity 0.2s;
}

.sidebar.collapsed .btn-text {
    opacity: 0;
    display: none;
}

.chat-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.chat-list-container::-webkit-scrollbar {
    width: 4px;
}
.chat-list-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.chat-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-item {
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    border: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.chat-item-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    overflow: hidden;
}

.sidebar.collapsed .chat-item {
    padding: 0.8rem 0;
    justify-content: center;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.chat-item.active {
    background: rgba(58, 134, 255, 0.1);
    border-color: rgba(58, 134, 255, 0.3);
    color: var(--accent-color);
}

.chat-item i {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
}

.chat-title {
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 0.9rem;
    flex: 1;
}

.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all 0.2s;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.chat-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    color: var(--danger-color);
    background: rgba(255, 61, 0, 0.1);
}

.delete-chat-btn {
    opacity: 1;
}

.sidebar.collapsed .chat-title,
.sidebar.collapsed .delete-chat-btn {
    display: none;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn i {
    display: block;
    font-size: 1.4rem;
}

.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding: 1rem 0;
}

.icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

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

/*                                            */
/*                    HEADER                  */
/*                                            */

.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 1.5rem;
    background: rgba(15, 15, 19, 0.6);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 10;
    margin: 1rem;
    border-radius: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container {
    position: relative;
    width: 42px;
    height: 42px;
}

.logo-container img {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.status-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--bg-dark);
    border-radius: 50%;
    padding: 3px;
}

.status-indicator {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--status-ready);
    box-shadow: 0 0 8px rgba(0, 200, 83, 0.4);
    transition: all 0.3s ease;
}

.status-indicator.thinking {
    background-color: var(--status-thinking);
    box-shadow: 0 0 8px rgba(255, 214, 0, 0.4);
    animation: pulse 1.5s infinite;
}

.status-indicator.error {
    background-color: var(--status-error);
    box-shadow: 0 0 8px rgba(255, 61, 0, 0.4);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 214, 0, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 214, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 214, 0, 0); }
}

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

.brand-info h1 {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-info .subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--danger-color);
    border-color: rgba(255, 61, 0, 0.2);
    box-shadow: 0 0 15px var(--danger-glow);
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

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

.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 1rem;
}

/*                                            */
/*                  MESSAGES                  */
/*                                            */

.message {
    display: flex;
    align-items: flex-start;
    max-width: 85%;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.message-content {
    padding: 1rem 1.2rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
}

.ai-message .message-content {
    background: var(--bg-message-ai);
    border: 1px solid var(--border-glass);
    border-top-left-radius: 4px;
    color: #e0e0e0;
}

.user-message .message-content {
    background: var(--bg-message-user);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border-glass);
}

.message-content code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}

.message-content a {
    color: var(--accent-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.message-content a:hover {
    border-bottom-color: var(--accent-color);
}

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

.scroll-to-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 36px;
    height: 36px;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 5;
    color: var(--text-secondary);
}

.scroll-to-bottom.visible {
    transform: translateX(-50%) scale(1);
}

.scroll-to-bottom:hover {
    background: var(--accent-color);
    color: white;
}

.input-area {
    padding: 1.5rem;
    background: linear-gradient(to top, rgba(15,15,19,0.95) 0%, rgba(15,15,19,0) 100%);
    z-index: 10;
}

.input-glass-wrapper {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.input-glass-wrapper:focus-within {
    border-color: rgba(58, 134, 255, 0.3);
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

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

#user-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

#send-button {
    background: var(--accent-color);
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

#send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/*                                            */
/*                    FOOTER                  */
/*                                            */

.mini-footer {
    text-align: center;
    padding-top: 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.2);
}

.mini-footer a {
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    transition: color 0.2s;
}

.mini-footer a:hover {
    color: var(--accent-color);
}

.highlight {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
}

/*                                            */
/*                  MODAL                     */
/*                                            */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #1a1a20;
    border: 1px solid var(--border-glass);
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.9);
}

.modal-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--danger-color);
}

.modal-header i {
    font-size: 2rem;
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-secondary, .btn-danger {
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-main);
    border: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(255, 61, 0, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(255, 61, 0, 0.2);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 0 15px var(--danger-glow);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0.8rem !important;
    align-items: center;
    min-height: 24px;
}

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

.typing-dots span {
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

/*                                            */
/*               MOBILE RESPONSIVE            */
/*                                            */

@media (max-width: 768px) {
    .layout-container {
        position: relative;
    }
    
    .sidebar {
        position: absolute;
        height: 100%;
        left: 0;
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 260px;
    }

    .sidebar.collapsed .sidebar-header {
        padding: 1rem;
    }

    .sidebar.collapsed .sidebar-btn {
        width: 100%;
        height: auto;
        padding: 0.8rem;
        justify-content: flex-start;
    }

    .sidebar.collapsed #new-chat-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-glass);
    }

    .sidebar.collapsed #new-chat-btn i {
        font-size: 1.1rem;
    }

    .sidebar.collapsed .btn-text {
        display: inline-block !important;
        opacity: 1 !important;
    }

    .sidebar.collapsed .chat-item {
        padding: 0.8rem;
        justify-content: flex-start;
    }
    
    .sidebar.collapsed .chat-title,
    .sidebar.collapsed .delete-chat-btn {
        display: block;
    }

    .mobile-menu-btn {
        display: block;
    }

    .glass-header {
        margin: 0.5rem;
        padding: 1rem;
        border-radius: 16px;
    }
    
    .chat-container {
        padding: 0 1rem 1rem;
    }
    
    .input-area {
        padding: 1rem;
    }
    
    .message {
        max-width: 90%;
    }

    #toggle-sidebar {
        display: none !important;
    }
}
