:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --background-color: #f8fafc;
    --sidebar-color: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --message-bg-user: #e0f2fe;
    --message-bg-bot: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --welcome-bg: #f1f5f9;
    --code-bg: #f3f4f6;
    --code-border: #e5e7eb;
    --blockquote-border: #d1d5db;
    --success-color: #10b981;
    --error-color: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: 300px;
    background: linear-gradient(135deg, #f8fafc 60%, #e0e7ef 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.new-chat-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

.new-chat-button i {
    font-size: 0.75rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.document-input {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #fafbfc;
}

.document-input h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
    background-color: white;
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-history {
    padding: 1.5rem;
}

.chat-history h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 0.5rem;
}

.chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0.75rem;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 2px 8px var(--shadow-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: box-shadow 0.2s, background 0.2s, border 0.2s;
    position: relative;
}

.chat-item:hover {
    background: var(--background-color);
    box-shadow: 0 4px 16px var(--shadow-color);
    border-color: var(--primary-color);
}

/* Hide action buttons by default, show on hover */
.chat-item .download-chat-btn,
.chat-item .delete-chat-btn {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.chat-item:hover .download-chat-btn,
.chat-item:hover .delete-chat-btn {
    opacity: 1;
    pointer-events: auto;
}

/* Modern Icon Buttons */
.download-chat-btn,
.delete-chat-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(37,99,235,0.04);
    position: relative;
}

.download-chat-btn:hover {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 8px var(--primary-color);
}

.delete-chat-btn {
    color: var(--error-color);
}
.delete-chat-btn:hover {
    background: var(--error-color);
    color: #fff;
    box-shadow: 0 2px 8px var(--error-color);
}

/* Tooltip for icon buttons */
.download-chat-btn[title]:hover:after,
.delete-chat-btn[title]:hover:after {
    content: attr(title);
    position: absolute;
    left: 50%;
    top: -2.2rem;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 0.25rem 0.7rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0.95;
    pointer-events: none;
    z-index: 10;
}

.chat-item-preview {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.chat-item-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.empty-chat-history,
.error-message {
    text-align: center;
    padding: 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
    font-style: italic;
}

.error-message {
    color: var(--error-color);
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--background-color);
}

.chat-header {
    padding: 1.2rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(90deg, #fff 80%, #e0e7ef 100%);
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header h2:before {
    content: '\f086'; /* fa-comments icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1.1em;
    color: var(--primary-color);
    margin-right: 0.4em;
    display: inline-block;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
    background-color: var(--welcome-bg);
    border-radius: 1rem;
    margin: 2rem auto;
    max-width: 600px;
    border: 1px solid var(--border-color);
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.welcome-message p {
    color: var(--text-light);
    font-size: 1rem;
}

.message {
    max-width: 85%;
    padding: 1.25rem;
    border-radius: 1rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    animation: messageAppear 0.3s ease-out;
    position: relative;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--message-bg-user), #bae6fd);
    border: 1px solid #7dd3fc;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--message-bg-bot);
    border: 1px solid var(--border-color);
}

.message-content {
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: right;
    margin-top: 0.5rem;
    opacity: 0.8;
}

/* Enhanced Markdown Styles */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-color);
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.2em; }
.message-content h4 { font-size: 1.1em; }

.message-content p {
    margin: 0.75em 0;
    line-height: 1.7;
}

.message-content ul,
.message-content ol {
    margin: 0.75em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
    line-height: 1.6;
}

.message-content ul ul,
.message-content ol ol,
.message-content ul ol,
.message-content ol ul {
    margin: 0.25em 0;
}

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

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

.message-content code {
    background: var(--code-bg);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', Consolas, 'Courier New', monospace;
    border: 1px solid var(--code-border);
}

.message-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1em 0;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

.message-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.message-content blockquote {
    border-left: 4px solid var(--blockquote-border);
    padding-left: 1rem;
    margin: 1em 0;
    color: var(--text-light);
    font-style: italic;
    background: rgba(0, 0, 0, 0.02);
    padding: 0.75rem 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    font-size: 0.9em;
}

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

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

.message-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

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

.message-content hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2em 0;
}

/* Chat Input Styles */
.chat-input-container {
    padding: 1.5rem;
    background: linear-gradient(90deg, #fff 80%, #e0e7ef 100%);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.chat-form {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: border 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-color);
    outline: none;
    max-height: 200px;
    line-height: 1.5;
}

textarea::placeholder {
    color: var(--text-light);
}

.send-button {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px var(--primary-color);
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    margin-left: 0.5rem;
}

.send-button:hover:not(:disabled) {
    background: var(--secondary-color);
    box-shadow: 0 4px 16px var(--secondary-color);
    transform: translateY(-2px) scale(1.07);
}

.send-button:disabled {
    background: var(--text-light);
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Enhanced Loading Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: var(--message-bg-bot);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    max-width: 85%;
    align-self: flex-start;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.typing-dots-container {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Streaming cursor for simple solution */
/* .streaming-cursor {
    animation: none;
    
} */

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Enhanced message content for better streaming */
.message-content {
    margin-bottom: 0.75rem;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Smooth transitions for content updates */
/* .message-content * {
    animation: fadeIn 0.2s ease-in;
} */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        order: 2;
    }

    .main-content {
        height: 50vh;
        order: 1;
    }

    .message {
        max-width: 95%;
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
        gap: 1rem;
    }

    .chat-input-container {
        padding: 1rem;
    }

    .input-wrapper {
        padding: 0.5rem;
    }

    .send-button {
        width: 40px;
        height: 40px;
    }

    .welcome-message {
        padding: 2rem 1rem;
        margin: 1rem auto;
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 1rem;
    }

    .document-input,
    .chat-history {
        padding: 1rem;
    }

    .message {
        padding: 0.75rem;
    }

    .welcome-message h2 {
        font-size: 1.25rem;
    }
}

/* .streaming-cursor {
  display: inline-block;
  animation: blink 0s step-end infinite;
  optional styling to match your theme */
/* } */

@keyframes blink {
  50%, 100% { opacity: 0; }
  50%      { opacity: 0; }
}

.delete-chat-btn {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: color 0.2s;
    padding: 0.3rem 0.5rem;
    border-radius: 0.3rem;
}



/* Download chat button styles */
.download-chat-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: color 0.2s;
    padding: 0.3rem 0.5rem;
    border-radius: 0.3rem;
}


:root {
    /* Add these two new variables to existing :root */
    --toggle-bg: #e2e8f0;
    --toggle-active: #22c55e;
}

/* Modify the existing .input-wrapper rule */
.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.75rem;
    transition: all 0.2s ease;
}

/* Add these new rules */
.input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Influencer Toggle Styles */
.influencer-toggle-container {
    display: flex;
    align-items: center;
}

.influencer-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
}

.influencer-toggle-input {
    display: none;
}

.influencer-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--toggle-bg);
    border-radius: 24px;
    transition: all 0.3s ease;
    border: 2px solid var(--border-color);
}

.influencer-toggle-slider:before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.influencer-toggle-input:checked + .influencer-toggle-slider {
    background-color: var(--toggle-active);
    border-color: var(--toggle-active);
}

.influencer-toggle-input:checked + .influencer-toggle-slider:before {
    transform: translateX(20px);
}

.influencer-toggle-text {
    font-size: 0.875rem;
    color: var(--text-color);
    white-space: nowrap;
}

/* Update mobile responsive styles */
@media (max-width: 768px) {
    .input-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .influencer-toggle-container {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .influencer-toggle-text {
        font-size: 0.8rem;
    }
}