/* Reset và Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8f9fa;
    color: #333;
    line-height: 1.5;
    overflow-x: hidden;
    font-size: 14px;
}

/* Header */
.header {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Navigation Menu */
.navbar {
    padding: 1rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav-menu {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.nav-link:hover::before {
    left: 100%;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    width: 70%;
    height: 3px;
    background: #fbbf24;
    transform: translateX(-50%);
    border-radius: 2px;
}

.nav-auth-container {
    display: flex;
    align-items: center;
}

.nav-auth {
    display: flex;
    gap: 1rem;
}

.auth-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.auth-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.login-btn {
    background: #facc15;
    color: #b91c1c;
    font-weight: 600;
    border-color: #facc15;
}

.login-btn:hover {
    background: #f59e0b;
    border-color: #f59e0b;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.profile-menu {
    position: relative;
}

.profile-toggle {
    background: none;
    border: none;
    cursor: pointer;
}

.profile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    object-fit: cover;
    display: block;
}

.profile-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
    width: 200px;
    overflow: hidden;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    display: none;
}

.profile-dropdown.show {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

.mobile-auth {
    display: none;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 74px);
    max-width: 1600px;
    margin: 0 auto;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    height: 100%;
    position: relative;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.toggle-sidebar {
    display: none;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.toggle-sidebar:hover {
    background: #e5e7eb;
    color: #374151;
}

.chat-actions {
    padding: 1rem;
}

.new-chat-btn-sidebar {
    width: 100%;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.new-chat-btn-sidebar:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
}

.separator {
    border: none;
    height: 1px;
    background: #e5e7eb;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid #e5e7eb;
}

.collapse-btn {
    width: 100%;
    background: none;
    border: none;
    color: #6b7280;
    padding: 0.75rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collapse-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.chat-item {
    margin-top: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.chat-item:hover {
    background: #f3f4f6;
}

.chat-item.active {
    background: #ffffff;
    border: 1px solid #dc2626;
}

.chat-preview {
    padding: 0.75rem 1rem;
}

.chat-preview h4 {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    height: 100%;
    overflow: hidden;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.welcome-content {
    max-width: 600px;
}

.ai-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: white;
    font-size: 2.5rem;
}

.welcome-title-simple {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.sample-questions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sample-question-box {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.sample-question-box:hover {
    border-color: #dc2626;
    color: #b91c1c;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
    color: white;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

.message.ai .message-avatar {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.message-content {
    padding: 1rem 1.25rem;
    border-radius: 18px;
}

.message.user .message-content {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.message.ai .message-content {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

.message-text {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.message-text p {
    margin: 0.5rem 0;
}

.message-text p:first-child {
    margin-top: 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

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

.message.ai .message-text code {
    background: rgba(0, 0, 0, 0.1);
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.message-time {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.5rem;
    text-align: right;
}

.message.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 0.25rem;
    padding: 1rem 0;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #dc2626;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    max-height: 120px;
    padding: 0.5rem 0;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    cursor: pointer;
}

.send-btn:disabled {
    background: #e5e7eb;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .new-chat-btn-sidebar span,
.sidebar.collapsed .chat-history,
.sidebar.collapsed .collapse-btn span {
    display: none;
}

.sidebar.collapsed .new-chat-btn-sidebar {
    padding: 0.75rem;
    justify-content: center;
}

.sidebar.collapsed .collapse-btn {
    justify-content: center;
}

.sidebar.collapsed .collapse-btn i {
    transform: rotate(180deg);
}

/* Mobile Sidebar Toggle Button */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1002;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.mobile-sidebar-toggle:hover {
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    transform: translateY(-50%) scale(1.1);
}

/* Mobile Sidebar Overlay */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
        z-index: 1001;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .nav-menu.mobile-open {
        display: flex;
    }
    
    .nav-link {
        padding: 1rem 1.5rem;
    }
    
    .desktop-auth {
        display: none !important;
    }
    
    .profile-menu {
        display: none !important;
    }
    
    .mobile-auth {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1rem;
        padding: 1rem 1.5rem 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .main-container {
        height: calc(100vh - 66px);
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 66px;
        left: -100%;
        width: 280px;
        height: calc(100vh - 66px);
        background: #f9fafb;
        border-right: 1px solid #e5e7eb;
        z-index: 1001;
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-header {
        cursor: default;
        position: sticky;
        top: 0;
        background: #f9fafb;
        z-index: 1;
    }

    .toggle-sidebar {
        display: block;
        background: none;
        border: none;
        color: #6b7280;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: 4px;
        transition: all 0.2s ease;
    }

    .toggle-sidebar:hover {
        background: #e5e7eb;
        color: #374151;
    }

    .chat-area {
        width: 100%;
        height: 100%;
    }

    .mobile-sidebar-toggle {
        display: block;
    }

    /* Input area adjustments for mobile */
    .input-area {
        padding: 1rem;
    }

    .input-wrapper {
        border-radius: 12px;
    }

    .input-footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .disclaimer {
        font-size: 0.7rem;
    }

    /* Welcome screen mobile adjustments */
    .welcome-content {
        padding: 1rem;
    }

    .sample-questions-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .sample-question-box {
        padding: 1rem;
        font-size: 0.9rem;
    }

    /* Chat messages mobile adjustments */
    .chat-messages {
        padding: 1rem 0.5rem;
    }

    .message {
        margin-bottom: 1rem;
    }

    .message-content {
        max-width: calc(100% - 50px);
    }

    .message-text {
        font-size: 0.9rem;
        line-height: 1.5;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .nav-container {
        padding: 0 15px;
    }

    .input-area {
        padding: 0.75rem;
    }

    .welcome-content {
        padding: 0.75rem;
    }

    .chat-messages {
        padding: 0.75rem 0.25rem;
    }

    .mobile-sidebar-toggle {
        left: 5px;
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.notification-success {
    border-left: 4px solid #10b981;
}

.notification-error {
    border-left: 4px solid #ef4444;
}

.notification-header {
    padding: 16px 20px 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.notification-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-success .notification-icon {
    background-color: #dcfce7;
    color: #16a34a;
}

.notification-error .notification-icon {
    background-color: #fef2f2;
    color: #dc2626;
}

.notification-message {
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.notification-close:hover {
    background-color: #f3f4f6;
    color: #6b7280;
}

.notification-progress {
    height: 3px;
    background-color: #f3f4f6;
    position: relative;
    overflow: hidden;
}

.notification-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    width: 100%;
    transform-origin: left;
    animation: progressShrink 5s linear forwards;
}

.notification-error .notification-progress-bar {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

@keyframes progressShrink {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}
