* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: #1e1e1e;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.new-chat-btn {
    flex: 1;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-item {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.chat-item.active {
    background: rgba(102, 126, 234, 0.2);
    color: white;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.chat-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
}

.chat-delete {
    opacity: 0;
    background: transparent;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
}

.chat-item:hover .chat-delete {
    opacity: 1;
}

.chat-delete:hover {
    background: rgba(255, 107, 107, 0.2);
    transform: scale(1.1);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.header {
    padding: 20px;
    text-align: center;
    position: relative;
}

.menu-btn {
    display: none;
    position: absolute;
    left: 20px;
    top: 20px;
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

h1 {
    text-align: center;
    margin-bottom: 15px;
    color: white;
    font-weight: 700;
    font-size: 2.2rem;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.02em;
    animation: titleGlow 3s ease-in-out infinite alternate;
    position: relative;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #fff, transparent);
    animation: underlineGlow 2s ease-in-out infinite;
}

.subtitle {
    text-align: center;
    margin-bottom: 20px;
    margin-top: -5px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    animation: subtitleFade 2s ease-in-out infinite alternate;
}

.chat-container {
    flex: 1;
    background: #2d2d2d;
    border-radius: 20px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.15), 
        0 10px 20px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    animation: containerFloat 6s ease-in-out infinite;
    margin: 0 20px 20px 20px;
}

.chat-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 3s ease-in-out infinite;
}

.chat-history {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    min-height: 400px;
    max-height: 550px;
    background: #2d2d2d;
}

.message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    text-align: right;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.user-message::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    animation: messageAccent 2s ease-in-out infinite;
}

.assistant-message {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    margin-right: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.assistant-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: rgba(102, 126, 234, 0.5);
    animation: messageAccent 2s ease-in-out infinite reverse;
}

.input-section {
    padding: 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: #2d2d2d;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-row {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.input-buttons {
    display: flex;
    gap: 10px;
}

.image-btn {
    padding: 12px 16px;
    background: linear-gradient(135deg, #4a4a4a 0%, #5a5a5a 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.image-btn:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.image-preview-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 15px;
    border: 2px dashed #4a4a4a;
}

.image-preview {
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.remove-image:hover {
    background: #c82333;
    transform: scale(1.1);
}

.message-image {
    max-width: 300px;
    max-height: 300px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid #4a4a4a;
    border-radius: 25px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #1a1a1a;
    color: white;
}

#user-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #1a1a1a;
    color: white;
}

#send-button {
    padding: 14px 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-height: 50px;
    position: relative;
    overflow: hidden;
}

#send-button::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;
}

#send-button:hover::before {
    left: 100%;
}

#send-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#send-button:disabled {
    background: #e9ecef;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    color: #6c757d;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 25px;
    color: #667eea;
    font-weight: 500;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(102, 126, 234, 0.1);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes titleGlow {
    0% {
        text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
    100% {
        text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.3);
    }
}

@keyframes underlineGlow {
    0%, 100% {
        opacity: 0.5;
        transform: translateX(-50%) scaleX(1);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scaleX(1.2);
    }
}

@keyframes containerFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-5px);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes messageAccent {
    0%, 100% {
        opacity: 0.3;
        transform: scaleY(1);
    }
    50% {
        opacity: 0.8;
        transform: scaleY(1.1);
    }
}

@keyframes subtitleFade {
    0% {
        opacity: 0.6;
    }
    100% {
        opacity: 1;
    }
}

.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #b91c1c;
    padding: 16px 20px;
    border-radius: 18px;
    margin-bottom: 20px;
    border: 1px solid #fca5a5;
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.1);
    animation: fadeIn 0.3s ease-out;
}

@media (max-width: 768px) {
    /* Mobile sidebar behavior */
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-btn {
        display: block;
    }
    
    .chat-container {
        margin: 0 10px 10px 10px;
        border-radius: 15px;
    }
    
    .header {
        padding: 15px;
    }
    
    .input-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .input-buttons {
        justify-content: stretch;
    }
    
    .input-buttons button {
        flex: 1;
    }
    
    .message {
        max-width: 95%;
    }
    
    .image-preview-container {
        padding: 10px;
    }
    
    .message-image {
        max-width: 250px;
        max-height: 250px;
    }
}

/* Sidebar closed state for desktop */
.sidebar.closed {
    transform: translateX(-100%);
}

.main-content.sidebar-closed {
    margin-left: 0;
}
