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

/* Hide all scrollbars globally */
* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

*::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* CSS Variables for Light Theme (Default) */
:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --container-bg: rgba(255, 255, 255, 0.95);
    --panel-bg: rgba(255, 255, 255, 0.35);
    --panel-border: rgba(255, 255, 255, 0.45);
    --text-primary: #333;
    --text-secondary: #666;
    --text-inverse: white;
    --message-bg: white;
    --message-user-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --message-text: #333;
    --message-user-text: white;
    --input-bg: white;
    --input-border: #eee;
    --input-focus-border: #667eea;
    --input-text: #333;
    --action-button-bg: #f5f5f5;
    --action-button-hover: #e0e0e0;
    --modal-bg: white;
    --modal-border: #eee;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
}

/* CSS Variables for Dark Theme */
[data-theme="dark"] {
    --bg-gradient-start: #1a1a2e;
    --bg-gradient-end: #16213e;
    --container-bg: rgba(26, 26, 46, 0.95);
    --panel-bg: rgba(10, 10, 25, 0.8);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-inverse: #1a1a2e;
    --message-bg: #2a2a3e;
    --message-user-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --message-text: #e0e0e0;
    --message-user-text: white;
    --input-bg: #2a2a3e;
    --input-border: #3a3a4e;
    --input-focus-border: #667eea;
    --input-text: #e0e0e0;
    --action-button-bg: #3a3a4e;
    --action-button-hover: #4a4a5e;
    --modal-bg: #2a2a3e;
    --modal-border: #3a3a4e;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    overflow-y: auto;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.background-grid {
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.08) 0, transparent 50%),
        radial-gradient(circle at 75% 0%, rgba(255, 255, 255, 0.05) 0, transparent 45%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0.5px, transparent 0.5px),
        linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0.5px, transparent 0.5px);
    background-size: 100% 100%, 100% 100%, 80px 80px, 80px 80px;
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

.background-orb {
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.7;
    z-index: 0;
}

.orb-1 {
    background: #8f7eff;
    top: -80px;
    right: 5%;
}

.orb-2 {
    background: #ff7ecb;
    bottom: -120px;
    left: 10%;
}

.orb-3 {
    background: #4dd0e1;
    top: 30%;
    left: -120px;
}

.container {
    width: min(100%, 900px);
    height: min(900px, calc(100vh - 2rem));
    display: flex;
    flex-direction: column;
    background: var(--container-bg);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px var(--shadow-strong);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    padding: 1.5rem 1.5rem 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-inverse);
    padding: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
    transition: background 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-inverse);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--text-inverse);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 600;
}

.logo-text p {
    font-size: 0.85rem;
    opacity: 0.8;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    margin: 1.5rem;
    backdrop-filter: blur(12px);
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Messages */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 90%;
    animation: slideIn 0.3s ease-out;
}

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

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

.bot-message {
    align-self: flex-start;
}

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

.user-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.message-content {
    background: var(--message-bg);
    color: var(--message-text);
    padding: 1rem;
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(15, 15, 45, 0.25);
    position: relative;
    transition: background 0.3s ease, color 0.3s ease, border 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.user-message .message-content {
    background: var(--message-user-bg);
    color: var(--message-user-text);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.35);
    border: none;
}

.message-text {
    line-height: 1.7;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-text strong {
    font-weight: 600;
    color: var(--message-text);
}

.message-text em {
    font-style: italic;
    opacity: 0.8;
}

.message-text a {
    color: #667eea;
    text-decoration: underline;
    word-break: break-all;
}

.message-text a:hover {
    color: #5a6fd8;
}

.user-message .message-text a {
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-text a:hover {
    color: white;
}

.message-text h3,
.message-text h4,
.message-text h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.message-text h3 + *,
.message-text h4 + *,
.message-text h5 + * {
    margin-top: 0.3rem;
}

.message-text p {
    margin: 0;
}

.message-text p + p {
    margin-top: 0.4rem;
}

.message-text ul,
.message-text ol {
    margin: 0;
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.message-text code {
    background: rgba(102, 126, 234, 0.15);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
    word-break: break-word;
    overflow-wrap: anywhere;
}

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

.message-text pre {
    background: rgba(15, 15, 45, 0.85);
    color: #f8f8f2;
    padding: 0.8rem;
    border-radius: 12px;
    overflow-x: auto;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

[data-theme="dark"] .message-text pre {
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f5;
    border-color: rgba(255, 255, 255, 0.05);
}

.message-text ul, .message-text ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-text li {
    margin: 0.25rem 0;
    line-height: 1.4;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 0.75rem;
    text-align: right;
}

.user-message .message-time {
    text-align: left;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
}

.typing-indicator.show {
    display: block;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 1rem 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    padding: 1rem;
    background: var(--input-bg);
    border-top: 1px solid var(--input-border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    border: 2px solid var(--input-border);
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    max-height: 120px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--input-text);
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

#messageInput:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.send-button {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.input-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.input-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

.char-count {
    opacity: 0.7;
}

.input-actions {
    display: flex;
    gap: 0.5rem;
}

.action-button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--action-button-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-button:hover {
    background: var(--action-button-hover);
    transform: scale(1.1);
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--modal-bg);
    color: var(--text-primary);
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px var(--shadow-strong);
    animation: modalSlideIn 0.3s ease-out;
    transition: background 0.3s ease, color 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--modal-border);
}

.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #e74c3c;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--modal-border);
    text-align: right;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .container {
        height: auto;
        min-height: calc(100vh - 1rem);
        margin: 0;
    }
    
    .message {
        max-width: 90%;
    }
    
    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .logo-text h1 {
        font-size: 1.2rem;
    }
}

/* Hide Scrollbar */
.chat-container::-webkit-scrollbar {
    display: none;
}

.chat-container {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
