:root {
    --primary-color: #014A60;
    --accent-color: #0BE56D;
    --background-light: #F1F5F9;
    --text-dark: #1E293B;
    --text-light: #64748B;
    --border-color: #E2E8F0;
    --sidebar-width: 260px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --background-light: #0F172A;
    --text-dark: #F1F5F9;
    --text-light: #94A3B8;
    --border-color: #334155;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--background-light);
    color: var(--text-dark);
    transition: all 0.3s ease;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.logo-icon {
    background: var(--accent-color);
    width: 35px;
    height: 35px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Add this to contain the image */
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: none;
}

.new-chat-btn {
    background: var(--accent-color);
    color: var(--primary-color);
    border: none;
    padding: 12px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(11, 229, 109, 0.3);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Ensure conversation items have proper spacing */
.conversation-item {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s ease;
    min-height: 50px;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.conversation-item.active {
    background: rgba(11, 229, 109, 0.2);
}

.conversation-item i {
    font-size: 16px;
    opacity: 0.8;
}

.conversation-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
    line-height: 1.2;
}

.conversation-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.conversation-preview {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}


.delete-conversation-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.conversation-item:hover .delete-conversation-btn {
    opacity: 1;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background-light);
}

.chat-header {
    height: var(--header-height);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    position: sticky; /* ← ADD THIS */
    top: 0; /* ← ADD THIS */
    z-index: 10; /* ← ADD THIS to ensure it stays above content */
    background: var(--background-light); /* ← ADD THIS to cover content underneath */
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 18px;
    display: none;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 18px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 40px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.welcome-avatar {
    width: 64px;
    height: 64px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Add this to contain the image */
    border: 2px solid var(--accent-color);
}

.welcome-text {
    font-size: 20px;
    color: var(--text-dark);
    text-align: center;
}

/* logo Image styling */

.logo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.welcome-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Messages */
.message-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    width: 100%;
}

.message-wrapper {
    display: flex;
    gap: 16px;
    max-width: 768px;
    width: 100%;
}

.message.user .message-wrapper {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--accent-color);
    color: var(--primary-color);
}

.message.ai .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message-content {
    background: var(--border-color);
    padding: 16px;
    border-radius: 18px;
    line-height: 1.5;
    max-width: 100%;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
}

.message.ai .message-content {
    background: var(--border-color);
    color: var(--text-dark);
}

/* Chat Input */
.chat-input-container {
    padding: 50px;
    bottom: 0;
    position: sticky;
    border-top: 1px solid var(#0BE56D);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 668px;
    margin: 0 auto 12px;
    background: var(--background-light);
    border: 1px solid #64748b69;
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    padding: 8px 0;
    font-size: 16px;
    background: transparent;
    color: var(--text-dark);
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: var(--text-light);
}

.voice-btn, .send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.voice-btn:hover, .send-btn:hover {
    background: #01394d;
}

.send-btn {
    background: var(--accent-color);
    color: var(--primary-color);
}

.send-btn:hover {
    background: #08c75a;
}

.voice-btn.listening {
    background: var(--accent-color);
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.chat-footer {
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
    max-width: 768px;
    margin: 0 auto;
}

/* Link colors */
.message-link {
    color: #059669;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s ease;
}

.message-link:hover {
    color: #047857;
    text-decoration: none;
}

.message.user .message-link {
    color: #059669;
    text-decoration: underline;
}

.message.user .message-link:hover {
    color: #047857;
    text-decoration: none;
}

/* Ensure links are visible in dark mode */
[data-theme="dark"] .message-link {
    color: #059669;
}

[data-theme="dark"] .message-link:hover {
    color: #10b981;
}

[data-theme="dark"] .message.user .message-link {
    color: #059669;
}

[data-theme="dark"] .message.user .message-link:hover {
    color: #10b981;
}

/* Add styles for formatted lists */
.message-list {
    margin: 10px 0;
    padding-left: 20px;
}

.message-list li {
    margin: 5px 0;
    line-height: 1.5;
}

.message-list .message-link {
    color: #059669;
}

.message-list .message-link:hover {
    color: #047857;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--border-color);
    border-radius: 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingAnimation {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: block;
    }

    .close-sidebar-btn {
        display: block;
    }
}


@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        max-width: 320px;
    }

    .message-container {
        padding: 16px;
    }

    .message-wrapper {
        gap: 12px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .message-content {
        padding: 12px;
        font-size: 14px;
    }
    .message.user .message-content {
        font-size: 16px; 
    }
    .message.ai .message-content {
    font-size: 15px; 
}

    .chat-input-container {
        padding: 16px;
    }

    .input-wrapper {
        margin: 0 auto 8px;
    }
}

/* Always show delete button on mobile devices */
@media (max-width: 768px) {
    .delete-conversation-btn {
        opacity: 1 !important;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }
    
    .delete-conversation-btn:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }
}

/* Keep hover effect for desktop only */
@media (min-width: 769px) {
    .delete-conversation-btn {
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .conversation-item:hover .delete-conversation-btn {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .message-container {
        padding: 12px;
    }

    .welcome-text {
        font-size: 18px;
    }

    .chat-input-container {
        padding: 12px;
    }

    .input-wrapper {
        padding: 10px 12px;
    }
}

/* Reply logo handling */
.message-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Update the message avatar styles to handle images properly */
.message-avatar {
    overflow: hidden; /* Add this to contain the image */
}
