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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: -0.01em;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: all 0.3s ease;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:root {
    /* Light Theme - Standard Bootstrap-like Professional Red Corporate Theme */
    --bg-color: #ffffff;
    --surface-color: #ffffff;
    --text-color: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --primary-color: rgb(185, 28, 28);
    --primary-hover: rgb(150, 22, 22);
    --user-bg: rgb(185, 28, 28 / var(--tw-bg-opacity, 1));
    --user-bg-solid: rgb(185, 28, 28);
    --bot-bg: #f8f9fa;
    --header-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow: rgba(0, 0, 0, 0.125);
    --hover-bg: #e9ecef;
    --message-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --accent-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
}

.dark-theme {
    /* Dark Theme - Standard Bootstrap-like Professional Red Corporate Theme */
    --bg-color: #212529;
    --surface-color: #343a40;
    --text-color: #ffffff;
    --text-secondary: #adb5bd;
    --border-color: #495057;
    --primary-color: rgb(220, 53, 69);
    --primary-hover: rgb(200, 35, 51);
    --user-bg: rgb(220, 53, 69);
    --bot-bg: #495057;
    --header-bg: #343a40;
    --input-bg: #343a40;
    --shadow: rgba(0, 0, 0, 0.375);
    --hover-bg: #495057;
    --message-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.15);
    --accent-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    margin: 0 auto;
    background-color: var(--bg-color);
}

/* Header */
.chat-header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

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

.ai-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.ai-details h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.ai-status {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.theme-toggle, .new-chat-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.theme-toggle:hover, .new-chat-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.05);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--bg-color);
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
}

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

.welcome-icon {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-color);
}

.welcome-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chip {
    padding: 8px 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background: var(--hover-bg);
    border-color: var(--user-bg);
}

/* Messages */
.message {
    margin-bottom: 16px;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 0;
    transform: translateY(24px) scale(0.95);
    animation-fill-mode: forwards;
}

.message:nth-child(odd) {
    animation-delay: 0.05s;
}

.message:nth-child(even) {
    animation-delay: 0.1s;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-content {
    max-width: 85%;
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    border: 1px solid var(--border-color);
    box-shadow: var(--message-shadow);
}

.message-content:hover {
    box-shadow: 0 2px 8px var(--shadow);
}

.user-message {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.user-message .message-content {
    color: var(--text-color);
    border-radius: 18px;
    margin-left: 15%;
    border: 1px solid var(--border-color);
}



.ai-message {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
}

.ai-message .message-content {
    padding-top :30px;
    background: var(--surface-color);
    color: var(--text-color);
    border-radius: 18px;
    margin-right: 15%;
    border: 1px solid var(--border-color);
}

.dark-theme .ai-message .message-content,
.dark-theme .user-message .message-content,
.dark-theme .thinking-container {
    border: 1px solid var(--border-color);
}



/* Message Text */
.message-text {
    margin-bottom: 8px;
}

/* Message Timestamp */
.message-timestamp {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
    text-align: right;
    margin-bottom: 4px;
}

/* Typography Improvements */
.message-content {
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.message-content h1, .message-content h2, .message-content h3,
.message-content h4, .message-content h5, .message-content h6 {
    font-weight: 600;
    line-height: 1.3;
    margin: 16px 0 8px 0;
    color: var(--text-color);
}

.message-content h1 { font-size: 24px; }
.message-content h2 { font-size: 20px; }
.message-content h3 { font-size: 18px; }
.message-content h4 { font-size: 16px; }
.message-content h5 { font-size: 14px; }
.message-content h6 { font-size: 13px; }

.message-content p {
    margin: 8px 0;
    line-height: 1.6;
}

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

.message-content em, .message-content i {
    font-style: italic;
    color: var(--text-secondary);
}

.message-content code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 13px;
    background: var(--hover-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-color);
}

.message-content pre {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.message-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.message-content blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.message-content th, .message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background: var(--hover-bg);
    font-weight: 600;
    color: var(--text-color);
}

.message-content tr:nth-child(even) {
    background: var(--hover-bg);
}

/* URL Links */
.message-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    word-break: break-all;
}

.message-content a:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
    text-decoration: none;
}

/* Internal Links (URLs starting with /) */
.internal-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
}

.internal-link:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
    text-decoration: none;
}

/* External URL styling */
.external-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.external-link:hover {
    color: var(--primary-hover);
    border-bottom-color: var(--primary-hover);
    text-decoration: none;
}

.external-link::after {
    content: " ↗";
    font-size: 12px;
    opacity: 0.7;
    margin-left: 2px;
}

/* Copy Button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    font-size: 12px;
}

.message-content:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.05);
}

/* Copy Notification */
.copy-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--user-bg);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.3);
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 0;
    transform: translateY(24px) scale(0.95);
    animation-fill-mode: forwards;
}

.thinking-container {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    font-style: italic;
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
    padding: 12px 16px;
    width: fit-content;
    max-width: 70%;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
    white-space: nowrap;
    border-radius: 18px;
}

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

.thinking-text {
    font-style: italic;
    color: var(--text-secondary);
    animation: fadeInOut 0.5s ease-in-out;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.typing-animation {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
}

.typing-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--user-bg-solid);
    animation: typingBounce 1.4s ease-in-out infinite both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* Input Area */
.chat-input {
    padding: 16px 20px;
}

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

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#messageInput {
    flex: 1;
    min-height: 44px;
    max-height: 200px;
    padding: 12px 16px;
    padding-right: 60px;
    border: 1px solid var(--border-color);
    border-radius: 22px;
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    overflow-y: auto;
}

/* Modern scrollbar for message input - hidden by default */
#messageInput::-webkit-scrollbar {
    width: 0;
    opacity: 0;
    transition: all 0.2s ease;
}

#messageInput::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

#messageInput::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
    transition: background 0.2s ease;
}

#messageInput::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

#messageInput {
    scrollbar-width: none;
    scrollbar-color: transparent transparent;
}

/* Show scrollbar only when input has scrollable content AND is focused */
#messageInput.scrollable:focus::-webkit-scrollbar {
    width: 6px;
    opacity: 1;
}

#messageInput.scrollable:focus {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

#messageInput:focus {
    /* Removed border focus styling */
    caret-color: var(--text-color);
}

#messageInput:not(:focus) {
    caret-color: transparent;
}

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

.send-button {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
}

.send-button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.disclaimer {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
}

/* Generated Images */
.generated-image-container {
    position: relative;
    max-width: 100%;
    margin: 12px 0;
}

.generated-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    object-fit: contain;
}

.download-btn {
    margin-top: 8px;
    padding: 8px 16px;
    background: var(--user-bg);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(185, 28, 28, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        max-width: 100%;
    }

    .chat-messages {
        padding: 16px;
    }

    .chip {
        width: 100%;
        max-width: 280px;
    }

    .header-content {
        flex-wrap: wrap;
        gap: 12px;
    }

    .ai-details h1 {
        font-size: 14px;
    }

    .generated-image {
        max-height: 300px;
    }

    .copy-notification {
        background: rgb(185, 28, 28) !important;
        box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4);
    }

    .input-modes {
        flex-direction: column;
        gap: 6px;
    }

    .mode-btn {
        width: 100%;
        justify-content: center;
    }
}
