* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #3b82f6 100%);
    background-attachment: fixed;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="10" cy="10" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="20" r="1.5" fill="rgba(255,255,255,0.08)"/><circle cx="30" cy="70" r="1" fill="rgba(255,255,255,0.12)"/><circle cx="90" cy="80" r="1" fill="rgba(255,255,255,0.06)"/></svg>') repeat;
    pointer-events: none;
}

.chat-container {
    width: 100%;
    max-width: 1000px;
    height: 88vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 
        0 32px 64px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-header {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #3b82f6 100%);
    color: white;
    padding: 5px 30px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(30, 60, 114, 0.3);
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.chat-header * {
    position: relative;
    z-index: 1;
}

.chat-header h1 {
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header p {
    font-size: 1.05em;
    opacity: 0.95;
    font-weight: 400;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(30, 60, 114, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.8);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.message {
    display: flex;
    margin-bottom: 18px;
    animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 5px 24px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 15px;
    word-wrap: break-word;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    position: relative;
}

.message.bot .message-bubble {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.95) 100%);
    color: #1e293b;
    border-bottom-left-radius: 8px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    backdrop-filter: blur(10px);
}

.message.bot .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.02) 0%, rgba(30, 60, 114, 0.02) 100%);
    border-radius: 20px;
    pointer-events: none;
}

.message.bot .message-bubble > * {
    position: relative;
    z-index: 1;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 8px;
    box-shadow: 
        0 6px 16px rgba(30, 60, 114, 0.25),
        0 2px 6px rgba(30, 60, 114, 0.15);
}

/* Markdown styling for bot messages */
.message.bot .message-bubble h1,
.message.bot .message-bubble h2,
.message.bot .message-bubble h3,
.message.bot .message-bubble h4 {
    margin: 18px 0 14px 0;
    color: #1e293b;
    font-weight: 700;
}

.message.bot .message-bubble h1 {
    font-size: 1.5em;
    border-bottom: 3px solid #3b82f6;
    padding-bottom: 10px;
    color: #1e3c72;
}

.message.bot .message-bubble h2 {
    font-size: 1.35em;
    color: #2a5298;
}

.message.bot .message-bubble h3 {
    font-size: 1.25em;
    color: #475569;
}

.message.bot .message-bubble h4 {
    font-size: 1.15em;
    color: #64748b;
}

.message.bot .message-bubble p {
    margin: 12px 0;
    line-height: 1.6;
}

.message.bot .message-bubble ul,
.message.bot .message-bubble ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message.bot .message-bubble li {
    margin: 8px 0;
    line-height: 1.5;
}

.message.bot .message-bubble strong,
.message.bot .message-bubble b {
    color: #1e3c72;
    font-weight: 700;
}

.message.bot .message-bubble em,
.message.bot .message-bubble i {
    font-style: italic;
    color: #475569;
}

.message.bot .message-bubble code {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    color: #1e3c72;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
    border: 1px solid rgba(30, 60, 114, 0.1);
}

.message.bot .message-bubble pre {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px;
    margin: 14px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message.bot .message-bubble pre code {
    background: none;
    padding: 0;
    color: #1e293b;
    border: none;
}

.message.bot .message-bubble blockquote {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(30, 60, 114, 0.05));
    padding: 16px 20px;
    margin: 14px 0;
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: #475569;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.message.bot .message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

.message.bot .message-bubble table th,
.message.bot .message-bubble table td {
    border: 1px solid #e2e8f0;
    padding: 12px 16px;
    text-align: left;
}

.message.bot .message-bubble table th {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    font-weight: 700;
    color: #1e3c72;
    border-bottom: 2px solid #3b82f6;
}

.message.bot .message-bubble table tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

.message.bot .message-bubble hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 24px 0;
    opacity: 0.7;
}

.message.bot .message-bubble a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.message.bot .message-bubble a:hover {
    color: #1e3c72;
    text-decoration: underline;
    text-decoration-color: #3b82f6;
}

.chat-input-container {
    padding: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    gap: 16px;
    align-items: center;
    position: relative;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.8) 0%, rgba(241, 245, 249, 0.8) 100%);
    pointer-events: none;
}

.chat-input-container > * {
    position: relative;
    z-index: 1;
}

.chat-input {
    flex: 1;
    padding: 16px 22px;
    border: 2px solid #e2e8f0;
    border-radius: 28px;
    font-size: 15px;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    color: #1e293b;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-input:focus {
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 1);
    box-shadow: 
        0 0 0 4px rgba(59, 130, 246, 0.1),
        0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.chat-input:disabled {
    background: rgba(226, 232, 240, 0.5);
    cursor: not-allowed;
    color: #94a3b8;
}

.send-button {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #3b82f6 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 6px 16px rgba(30, 60, 114, 0.25),
        0 2px 6px rgba(30, 60, 114, 0.15);
    position: relative;
    overflow: hidden;
}

.send-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.send-button:hover::before {
    opacity: 1;
}

.send-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 24px rgba(30, 60, 114, 0.35),
        0 4px 12px rgba(30, 60, 114, 0.25);
}

.send-button:active {
    transform: translateY(-1px) scale(1.02);
}

.send-button:disabled {
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.send-button svg {
    position: relative;
    z-index: 1;
}

.typing-indicator {
    display: none;
    animation: messageSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1e3c72);
    animation: typing 1.6s infinite ease-in-out;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.3s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-12px) scale(1.2);
        opacity: 1;
    }
}

.error-message {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3) !important;
}

.error-message::before {
    content: "⚠️ ";
    margin-right: 8px;
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .chat-container {
        height: 92vh;
        border-radius: 20px;
        max-width: 100%;
    }
    
    .chat-header {
        padding: 5px 25px;
    }
    
    .chat-header h1 {
        font-size: 1.8em;
    }
    
    .chat-messages {
        padding: 20px;
        gap: 16px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 14px;
        padding: 16px 20px;
    }
    
    .chat-input-container {
        padding: 20px;
        gap: 14px;
    }
    
    .chat-input {
        padding: 14px 20px;
        font-size: 14px;
        border-radius: 25px;
    }
    
    .send-button {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .chat-container {
        height: 95vh;
        border-radius: 16px;
    }
    
    .message-bubble {
        max-width: 90%;
        padding: 14px 18px;
        font-size: 13px;
    }
    
    .chat-header {
        padding: 5px 20px;
    }
    
    .chat-header h1 {
        font-size: 1.6em;
    }
    
    .chat-header p {
        font-size: 0.95em;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input-container {
        padding: 16px;
        gap: 12px;
    }
    
    .chat-input {
        padding: 12px 18px;
        font-size: 13px;
    }
    
    .send-button {
        width: 46px;
        height: 46px;
    }
}
