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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #1a1a1a;
    color: #e1e5e9;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: linear-gradient(180deg, #1a1a1a, #171717);
    border-right: 1px solid #2f2f2f;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid #2f2f2f;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}

.new-chat-btn {
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.new-chat-btn::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.6s ease;
}

.new-chat-btn:hover::before {
    left: 100%;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #7c3aed, #a855f7);
}

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

.new-chat-btn i {
    font-size: 16px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    background: linear-gradient(180deg, #1a1a1a, #171717);
}

.chat-item {
    padding: 14px 18px;
    margin: 6px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
}

.chat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.6s ease;
}

.chat-item:hover::before {
    left: 100%;
}

.chat-item:hover {
    background: linear-gradient(135deg, #2a2a2a, #1f1f23);
    border-color: #6366f1;
    transform: translateX(4px);
}

.chat-item.active {
    background: linear-gradient(135deg, #374151, #4b5563);
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.chat-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: #e1e5e9;
}

.chat-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chat-item:hover .chat-actions {
    opacity: 1;
}

.chat-action-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
}

.chat-action-btn:hover {
    color: #e1e5e9;
    background-color: #4a4a4a;
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid #2f2f2f;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #2a2a2a, #1f1f23);
    border-radius: 12px;
    border: 1px solid #3f3f46;
}

.user-info i {
    font-size: 16px;
    color: #6366f1;
}

.user-info span {
    font-weight: 500;
    color: #e1e5e9;
}

.logout-btn {
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: 1px solid #4a4a4a;
    color: #9ca3af;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    border-color: #dc2626;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #1a1a1a;
}

/* Header */
.header {
    padding: 20px 24px;
    border-bottom: 1px solid #2f2f2f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mobile-menu-btn, .mobile-logout-btn {
    display: none;
    background: none;
    border: none;
    color: #e1e5e9;
    font-size: 20px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mobile-menu-btn:hover, .mobile-logout-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #6366f1;
}

.mobile-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 40px;
}

.header-title {
    text-align: center;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: 0.5px;
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.notice-banner {
    margin: 12px 24px 0;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #3f3f46;
    background: linear-gradient(135deg, rgba(42, 42, 42, 0.95), rgba(31, 31, 35, 0.95));
    color: #d1d5db;
    font-size: 13px;
    line-height: 1.4;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px 20px;
}

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

.welcome-icon {
    font-size: 64px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 32px;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));
}

.welcome-content h2 {
    font-size: 32px;
    margin-bottom: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, #e1e5e9, #f9fafb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content p {
    font-size: 18px;
    color: #9ca3af;
    margin-bottom: 40px;
    line-height: 1.6;
}

.example-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.example-prompt {
    padding: 20px 24px;
    background: linear-gradient(135deg, #2a2a2a, #1f1f23);
    border: 1px solid #3f3f46;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 16px;
    color: #e1e5e9;
    position: relative;
    overflow: hidden;
}

.example-prompt::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.6s ease;
}

.example-prompt:hover::before {
    left: 100%;
}

.example-prompt:hover {
    background: linear-gradient(135deg, #374151, #4b5563);
    border-color: #6366f1;
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.2);
}

.example-prompt i {
    font-size: 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 20px;
}

/* Messages */
.messages {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.message.assistant .message-avatar {
    background-color: #2a2a2a;
    color: #9ca3af;
}

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

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    padding: 16px 20px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
    display: inline-block;
    max-width: 85%;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    margin-left: auto;
}

.message.assistant .message-bubble {
    background-color: #2a2a2a;
    border: 1px solid #3f3f46;
}

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message.user .message-actions {
    justify-content: flex-end;
}

.message-action-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.message-action-btn:hover {
    color: #e1e5e9;
    background-color: #3f3f46;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
    background-color: #2a2a2a;
    border-radius: 18px;
    margin-left: 48px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.input-area {
    padding: 24px;
    border-top: 1px solid #2f2f2f;
    background-color: #1a1a1a;
}

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

/* Upload Section */
.upload-section {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.upload-file-btn {
    background: linear-gradient(135deg, #374151, #4b5563);
    border: 1px solid #6b7280;
    color: #e1e5e9;
    cursor: pointer;
    padding: 12px 20px;
    border-radius: 25px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.upload-file-btn.loading {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    cursor: not-allowed;
    pointer-events: none;
}

.upload-file-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid #e1e5e9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.upload-file-btn.loading span,
.upload-file-btn.loading i {
    opacity: 0.3;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.upload-file-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.15), transparent);
    transition: left 0.6s ease;
}

.upload-file-btn:hover::before {
    left: 100%;
}

.upload-file-btn:hover {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: #8b5cf6;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.upload-file-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.upload-file-btn i {
    font-size: 16px;
}

.file-preview {
    background: linear-gradient(135deg, #2a2a2a, #1f1f23);
    border: 1px solid #6366f1;
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
    animation: fileSlideIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.file-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #6366f1);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

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

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-info i {
    color: #6366f1;
    font-size: 16px;
}

.remove-file {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    margin-left: auto;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-file:hover {
    color: #dc2626;
    background-color: rgba(220, 38, 38, 0.1);
    transform: scale(1.1);
}

.message-input-container {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background-color: #2a2a2a;
    border: 1px solid #3f3f46;
    border-radius: 24px;
    padding: 12px 16px;
    transition: border-color 0.2s ease;
}

.message-input-container:focus-within {
    border-color: #6366f1;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #e1e5e9;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}

#messageInput::placeholder {
    color: #9ca3af;
}

.send-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: white;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:disabled {
    background: #4a4a4a;
    cursor: not-allowed;
    opacity: 0.6;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.input-footer {
    text-align: center;
    margin-top: 12px;
}

.disclaimer {
    font-size: 12px;
    color: #6b7280;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 24px;
    width: 400px;
    max-width: 90vw;
}

.modal-header h2 {
    margin-bottom: 24px;
    text-align: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background-color: #1a1a1a;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    color: #e1e5e9;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    border-color: #6366f1;
}

.login-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.login-submit-btn:hover {
    transform: translateY(-1px);
}

.login-note {
    font-size: 14px;
    color: #9ca3af;
    margin-bottom: 20px;
    text-align: center;
    font-style: italic;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(26, 26, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #3f3f46;
    border-top: 4px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -300px;
        z-index: 100;
        height: 100vh;
    }
    
    .sidebar.open {
        transform: translateX(300px);
    }
    
    .main-content {
        width: 100vw;
    }
    
    .header {
        padding: 16px;
        position: sticky;
        top: 0;
        z-index: 50;
        backdrop-filter: blur(10px);
    }
    
    .header-title {
        flex: 1;
        text-align: center;
    }
    
    .header-title h1 {
        font-size: 20px;
    }
    
    .mobile-menu-btn, .mobile-logout-btn {
        display: block;
    }
    
    .mobile-actions {
        min-width: 40px;
    }

    .notice-banner {
        margin: 10px 16px 0;
        padding: 9px 12px;
        font-size: 12px;
    }
    
    .upload-file-btn {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 20px;
    }
    
    .upload-file-btn span {
        display: none;
    }
    
    .chat-container {
        padding: 16px;
    }
    
    .input-area {
        padding: 16px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 20;
        background: linear-gradient(135deg, #1a1a1a, #171717);
        border-top: 2px solid #2f2f2f;
    }
    
    .chat-container {
        padding-bottom: 180px; /* Space for fixed input area */
    }
    
    .example-prompts {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .example-prompt {
        padding: 16px 20px;
        font-size: 14px;
    }
    
    .message.user .message-bubble,
    .message.assistant .message-bubble {
        max-width: 95%;
    }
    
    .file-preview {
        margin: 8px 0;
        padding: 10px 12px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-content p {
        font-size: 16px;
    }
    
    .welcome-icon {
        font-size: 48px;
    }
    
    /* Mobile overlay for sidebar */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 99;
        display: none;
    }
    
    .mobile-overlay.show {
        display: block;
    }
}


@media (max-width: 480px) {
    .header {
        padding: 12px;
    }
    
    .header-title h1 {
        font-size: 18px;
    }

    .notice-banner {
        margin: 8px 12px 0;
        padding: 8px 10px;
    }
    
    .upload-file-btn {
        padding: 8px 14px;
        min-width: 50px;
        font-size: 12px;
    }
    
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    .sidebar.open {
        transform: translateX(280px);
    }
    
    .chat-container {
        padding: 12px;
        padding-bottom: 160px; /* Adjust for smaller input area */
    }
    
    .input-area {
        padding: 12px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 20;
    }
    
    .example-prompt {
        padding: 14px 18px;
        font-size: 13px;
    }
    
    .file-preview {
        border-radius: 12px;
        padding: 8px 12px;
    }
    
    .welcome-content h2 {
        font-size: 20px;
    }
    
    .welcome-content p {
        font-size: 14px;
    }
    
    .welcome-icon {
        font-size: 40px;
    }
}

@media (min-width: 1200px) {
    .header-title h1 {
        font-size: 28px;
    }
    
    .upload-file-btn {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    .chat-container {
        padding: 32px;
    }
    
    .input-area {
        padding: 32px;
    }
    
    .welcome-content h2 {
        font-size: 36px;
    }
    
    .welcome-content p {
        font-size: 20px;
    }
    
    .welcome-icon {
        font-size: 72px;
    }
}

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

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Code Highlighting */
pre {
    background-color: #1e1e1e;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

code {
    background-color: #2a2a2a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
}

/* Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    background-color: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #3f3f46;
}

th {
    background-color: #374151;
    font-weight: 600;
}

/* Blockquote */
blockquote {
    border-left: 4px solid #6366f1;
    padding-left: 16px;
    margin: 12px 0;
    color: #9ca3af;
    font-style: italic;
}

/* Links */
a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #93c5fd;
    text-decoration: underline;
}