@font-face {
    font-family: 'Newsreader';
    src: url('Newsreader/Newsreader-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 200 800;
    font-style: normal;
}

@font-face {
    font-family: 'Newsreader';
    src: url('Newsreader/Newsreader-Italic-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 200 800;
    font-style: italic;
}

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

:root {
    --primary-bg: #1B211A;
    --secondary-bg: rgba(27, 33, 26, 0.8);
    --sidebar-bg: #1B211A;
    --message-user-bg: rgba(139, 174, 102, 0.1);
    --message-ai-bg: rgba(139, 174, 102, 0.05);
    --text-primary: #EBD5AB;
    --text-secondary: rgba(235, 213, 171, 0.7);
    --text-light: #EBD5AB;
    --border-color: rgba(139, 174, 102, 0.2);
    --accent-color: #8BAE66;
    --accent-secondary: #628141;
    --hover-color: rgba(139, 174, 102, 0.1);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Newsreader', 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, #1B211A 0%, #2a3328 100%);
    color: var(--text-primary);
    overflow-x: hidden;
}

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

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(139, 174, 102, 0.2);
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, #628141 0%, #8BAE66 100%);
    border: none;
    border-radius: 8px;
    color: #1B211A;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.new-chat-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(139, 174, 102, 0.4);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    color: rgba(235, 213, 171, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: rgba(139, 174, 102, 0.1);
    color: #EBD5AB;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(139, 174, 102, 0.2);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.model-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-selector label {
    color: rgba(235, 213, 171, 0.8);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.model-selector select {
    padding: 8px 12px;
    background: rgba(139, 174, 102, 0.1);
    border: 1px solid rgba(139, 174, 102, 0.3);
    border-radius: 6px;
    color: #EBD5AB;
    font-family: 'Newsreader', 'Georgia', serif;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.model-selector select option {
    background: #1B211A;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 20px 24px;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.chat-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 400px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #628141 0%, #8BAE66 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    color: #1B211A;
    box-shadow: 0 8px 24px rgba(139, 174, 102, 0.3);
}

.welcome-screen h2 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

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

.example-prompts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    max-width: 900px;
    width: 100%;
    margin-top: 32px;
}

.example-prompt {
    padding: 20px;
    background: rgba(139, 174, 102, 0.05);
    border: 1px solid rgba(139, 174, 102, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
    backdrop-filter: blur(10px);
}

.example-prompt:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 174, 102, 0.2);
    border-color: #8BAE66;
    background: rgba(139, 174, 102, 0.1);
}

.example-prompt h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.example-prompt p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Messages */
.messages {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    background: #000;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-avatar {
    background: linear-gradient(135deg, #628141 0%, #8BAE66 100%);
    color: #1B211A;
    font-weight: 700;
}

.ai-avatar {
    background: linear-gradient(135deg, #8BAE66 0%, #628141 100%);
    color: #1B211A;
    font-weight: 700;
}

.message-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-content {
    padding: 16px;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 15px;
}

.user-message .message-content {
    background: var(--message-user-bg);
    margin-left: 44px;
}

.ai-message .message-content {
    background: var(--message-ai-bg);
    margin-left: 44px;
}

.message-content p {
    margin-bottom: 12px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* Loading Animation */
.loading {
    display: flex;
    gap: 4px;
    margin-left: 44px;
    padding: 16px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8BAE66;
    animation: pulse 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Input Container */
.input-container {
    padding: 24px;
    background: var(--primary-bg);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(27, 33, 26, 0.95);
    backdrop-filter: blur(40px);
    border: 1px solid rgba(139, 174, 102, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.input-wrapper:focus-within {
    border-color: #8BAE66;
    box-shadow: 0 0 0 3px rgba(139, 174, 102, 0.2);
}

#userInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    color: var(--text-primary);
    background: transparent;
}

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

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #628141 0%, #8BAE66 100%);
    color: #1B211A;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(139, 174, 102, 0.4);
}

.send-btn:disabled {
    background: rgba(139, 174, 102, 0.3);
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

.input-footer {
    text-align: center;
    margin-top: 12px;
}

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

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(139, 174, 102, 0.3);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 174, 102, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .example-prompts {
        grid-template-columns: 1fr;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .messages {
        padding: 16px;
    }

    .input-container {
        padding: 16px;
    }
}

/* Enhanced Error Message */
.error-message {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 12px;
    border-radius: 6px;
    margin: 12px 44px;
    font-size: 14px;
}

.error-message.enhanced {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 16px;
    border-radius: 8px;
    margin: 12px 44px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.error-text {
    flex: 1;
    line-height: 1.5;
}

.error-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.error-btn {
    padding: 6px 12px;
    border: 1px solid #dc2626;
    background: transparent;
    color: #dc2626;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.error-btn:hover {
    background: #dc2626;
    color: white;
}

.error-btn.retry-btn {
    background: #dc2626;
    color: white;
}

.error-btn.retry-btn:hover {
    background: #b91c1c;
}

/* Loading Spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* Copy button for messages */
.message-content {
    position: relative;
}

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

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-secondary);
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
}

/* Enhanced sidebar with export functionality */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-btn {
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(139, 174, 102, 0.3);
    border-radius: 6px;
    color: rgba(235, 213, 171, 0.8);
    font-size: 12px;
    font-family: 'Newsreader', 'Georgia', serif;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: rgba(139, 174, 102, 0.1);
    color: #EBD5AB;
    border-color: #8BAE66;
}

/* Keyboard shortcuts indicator */
.shortcuts-hint {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 8px;
}

.shortcuts-hint kbd {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 10px;
}

/* Improved responsive design */
@media (max-width: 768px) {
    .error-message,
    .error-message.enhanced {
        margin: 12px 16px;
    }
    
    .error-actions {
        justify-content: center;
    }
    
    .shortcuts-hint {
        display: none;
    }
    
    .copy-btn {
        opacity: 1;
        position: static;
        display: block;
        margin-top: 8px;
        width: 100%;
    }
}
