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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #5b6cc5 100%);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Background Canvas for Particle Animation */
#backgroundCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Page Load Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in-down {
    animation: fadeInDown 1s ease-out forwards;
    opacity: 0;
}

.slide-up {
    animation: slideUp 1.2s ease-out forwards;
    opacity: 0;
    animation-delay: 0.3s;
}

/* Stagger animation delays */
.time-greeting {
    animation-delay: 0.2s;
}

#mainHeading {
    animation-delay: 0.4s;
}

/* Sidebar Toggle Button - RIGHT SIDE */
.sidebar-toggle-btn {
    position: fixed;
    right: 20px;
    bottom: 60px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    transition: all 0.3s ease;
    color: #4a5bcc;
}

.sidebar-toggle-btn:hover {
    background: white;
    transform: scale(1.1);
}

.sidebar-toggle-btn.rotated svg {
    transform: rotate(180deg);
}

.sidebar-toggle-btn svg {
    transition: transform 0.3s ease;
}

/* Superman Animation */
.superman {
    position: fixed;
    right: 20px;
    bottom: 60px;
    width: 60px;
    height: 60px;
    z-index: 1002;
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.superman.flying-to-sidebar {
    animation: flyToSidebar 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.superman.flying-back {
    animation: flyBack 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes flyToSidebar {
    0% {
        right: 20px;
        bottom: 60px;
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
    50% {
        right: 50%;
        bottom: 50%;
        opacity: 1;
        transform: rotate(-45deg) scale(1.2);
    }
    100% {
        right: calc(100% - 40px);
        bottom: calc(100% - 40px);
        opacity: 0;
        transform: rotate(-45deg) scale(0.5);
    }
}

@keyframes flyBack {
    0% {
        right: calc(100% - 40px);
        bottom: calc(100% - 40px);
        opacity: 1;
        transform: rotate(-45deg) scale(0.5);
    }
    50% {
        right: 50%;
        bottom: 50%;
        opacity: 1;
        transform: rotate(135deg) scale(1.2);
    }
    100% {
        right: 20px;
        bottom: 60px;
        opacity: 0;
        transform: rotate(180deg) scale(1);
    }
}

/* Time Display */
.time-display {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    color: #4a5bcc;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    margin-left: 0;
    z-index: 999;
}

.sidebar.collapsed {
    margin-left: -260px;
}

.sidebar-header {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f5f5f5;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #555;
}

.icon-btn:hover {
    background: #e8e8e8;
    color: #333;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    background: #f8f8f8;
    border-color: #ff8c42;
}

.new-chat-btn svg {
    color: #555;
}

.shortcut {
    margin-left: auto;
    font-size: 12px;
    color: #999;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 4px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: all 0.3s ease;
}

.menu-item:hover {
    background: #f5f5f5;
    color: #333;
}

.menu-item svg {
    color: #666;
}

/* Main Content - FIXED FOR SCROLLING */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    padding: 40px 40px 0 40px;
}

.greeting-container {
    text-align: center;
    color: white;
    padding: 40px 0;
    flex-shrink: 0;
}

.time-greeting {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 15px;
    color: #ffd89b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.main-heading {
    font-size: 42px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    line-height: 1.3;
}

/* Messages wrapper - SCROLLABLE AREA */
.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-right: 10px;
    margin-bottom: 20px;
}

/* Custom scrollbar for messages */
.messages-wrapper::-webkit-scrollbar {
    width: 8px;
}

.messages-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.messages-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.messages-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Input Container - ALWAYS AT BOTTOM */
.input-container {
    width: 100%;
    flex-shrink: 0;
    padding-bottom: 40px;
}

.input-wrapper {
    position: relative;
    background: white;
    border-radius: 30px;
    padding: 8px 8px 8px 24px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    min-height: 60px;
}

.input-wrapper:focus-within {
    box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #4a90e2;
    background: transparent;
    padding: 12px 0;
    resize: none;
    overflow-y: auto;
    max-height: 200px;
    min-height: 44px;
    line-height: 1.5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.chat-input::placeholder {
    color: #4a90e2;
    opacity: 0.7;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.chat-input::-webkit-scrollbar {
    width: 6px;
}

.chat-input::-webkit-scrollbar-track {
    background: transparent;
}

.chat-input::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 10px;
}

.chat-input::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.attach-btn,
.mic-btn,
.submit-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #666;
    position: relative;
    flex-shrink: 0;
}

.attach-btn:hover,
.mic-btn:hover {
    background: #f5f5f5;
    color: #333;
}

.mic-btn.recording {
    background: #ff4444;
    color: white;
    animation: pulse 1.5s infinite;
}

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

.submit-btn {
    background: linear-gradient(135deg, #4a5bcc 0%, #667eea 100%);
    color: white;
}

.submit-btn:hover {
    background: linear-gradient(135deg, #3d4db8 0%, #5568d3 100%);
    transform: scale(1.05);
}

/* Chat Messages Styling */
.message {
    max-width: 80%;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

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

.user-message {
    align-self: flex-end;
    margin-left: auto;
}

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

.message-content {
    padding: 15px 20px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Markdown formatting in messages */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

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

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

/* Typing Indicator */
.typing-indicator {
    padding: 15px 20px;
    background: white;
    border-radius: 20px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: fit-content;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 999;
    }
    
    .sidebar.collapsed {
        margin-left: -260px;
    }
    
    .sidebar-toggle-btn {
        right: 10px;
        bottom: 50px;
    }
    
    .superman {
        right: 10px;
        bottom: 50px;
        width: 50px;
        height: 50px;
    }
    
    .chat-container {
        padding: 20px 20px 0 20px;
    }
    
    .main-heading {
        font-size: 32px;
    }
    
    .time-greeting {
        font-size: 18px;
    }
    
    .time-display {
        top: 10px;
        right: 10px;
        padding: 8px 16px;
        font-size: 14px;
    }

    .input-container {
        padding-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .main-heading {
        font-size: 26px;
    }
    
    .time-greeting {
        font-size: 16px;
    }
    
    .chat-input {
        font-size: 14px;
    }

    .greeting-container {
        padding: 20px 0;
    }
}

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

.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================ */
/* CHAT HISTORY POPUP */
/* ============================================ */
.chat-history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-history-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.chat-history-popup {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.chat-history-overlay.active .chat-history-popup {
    transform: scale(1);
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid #e0e0e0;
}

.popup-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.close-popup-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #666;
}

.close-popup-btn:hover {
    background: #e8e8e8;
    color: #333;
    transform: rotate(90deg);
}

.popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-item {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.chat-item:hover {
    background: #e8eaf0;
    border-color: #667eea;
    transform: translateX(5px);
}

.chat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.chat-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-item-icon {
    width: 20px;
    height: 20px;
    color: #667eea;
}

.chat-item-date {
    font-size: 12px;
    color: #999;
}

.chat-item-preview {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.chat-item-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.load-chat-btn {
    background: #667eea;
    color: white;
}

.load-chat-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.delete-chat-btn {
    background: #f5f5f5;
    color: #ff4444;
}

.delete-chat-btn:hover {
    background: #ff4444;
    color: white;
}

.empty-chat-list {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-chat-list svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-chat-list h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #666;
}

.empty-chat-list p {
    font-size: 14px;
    line-height: 1.6;
}

/* Scrollbar for popup content */
.popup-content::-webkit-scrollbar {
    width: 8px;
}

.popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive for popup */
@media (max-width: 768px) {
    .chat-history-popup {
        width: 95%;
        max-height: 90vh;
    }

    .popup-header {
        padding: 20px;
    }

    .popup-header h2 {
        font-size: 20px;
    }

    .popup-content {
        padding: 16px 20px;
    }
}