:root {
    /* Primary dark teal palette */
    --primary-dark: #0d3b4c;     /* Deep dark teal */
    --primary: #14566c;          /* Rich teal */
    --primary-light: #1a758f;    /* Brighter teal for highlights */
    --accent: #1fa7b9;           /* Vibrant cyan-teal accent */
    --accent-light: #42c3d5;     /* Lighter accent for hover states */

    /* Text and background colors */
    --text: #e0f7fa;             /* Soft cyan-white text */
    --text-secondary: #b2ebf2;   /* Lighter secondary text */
    --bg: #0a1e29;               /* Background base (deep dark teal) */
    --bg-elevated: rgba(255, 255, 255, 0.05); /* Subtle elevation layer */
    --bg-hover: rgba(255, 255, 255, 0.1);     /* Hover state overlay */

    /* Status colors (keep vibrant for contrast) */
    --success: #43c694;          /* Emerald teal-green */
    --error: #ff4b5c;            /* Strong red for errors */
    --warning: #f5a623;          /* Warm orange for warnings */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--text);
    min-height: 100vh;
    padding: 16px;
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 32px);
    gap: 12px;
}

header {
    text-align: center;
    padding: 12px 0;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
    background: linear-gradient(to right, var(--accent), #9b59b6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 0.5px;
}

h2 {
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--text-secondary);
    opacity: 0.9;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-elevated);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: var(--accent);
    border-radius: 4px;
    border: 2px solid var(--bg-elevated);
}

.message {
    max-width: 88%;
    padding: 14px 18px;
    border-radius: 14px;
    animation: fadeIn 0.3s ease-out;
    line-height: 1.6;
    font-size: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.ai-message {
    align-self: flex-start;
    background-color: var(--bg-elevated);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-bottom-left-radius: 4px;
}

.user-message {
    align-self: flex-end;
    background-color: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
    border-radius: 14px 4px 14px 14px;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 4px;
    text-align: left;
}

.ai-message .message-time {
    text-align: left;
}

.user-message .message-time {
    text-align: right;
}

.streaming-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.typing::after {
    content: '.';
    display: inline-block;
    width: 6px;
    height: 6px;
    vertical-align: middle;
    animation: typingDots 1.2s infinite step-end;
}

@keyframes typingDots {
    from { content: '.'; }
    to { content: '...'; }
}

/* Input Area */
.input-area {
    padding: 14px;
    background-color: var(--bg-elevated);
    display: flex;
    gap: 10px;
    align-items: flex-end;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

textarea {
    flex: 1;
    padding: 14px 18px;
    border-radius: 24px;
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
    outline: none;
    font-size: 1rem;
    min-height: 50px;
    max-height: 150px;
    resize: none;
    transition: all 0.2s ease-in-out;
}

textarea:focus {
    background-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.4);
}

button {
    padding: 12px 22px;
    border-radius: 24px;
    background-color: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease-in-out;
    height: 50px;
    flex-shrink: 0;
}

button:hover {
    background-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

button:disabled {
    background-color: var(--primary-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Settings Panel */
.settings-panel {
    background-color: var(--bg-elevated);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.settings-title {
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-title:hover {
    background-color: var(--bg-hover);
}

.close-icon {
    transition: transform 0.3s ease, color 0.2s ease;
    font-size: 1.1rem;
}

.close-icon.rotate {
    transform: rotate(90deg);
    color: var(--accent);
}

.settings-content {
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-content:not(.hidden) {
    padding: 18px;
    max-height: 600px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
input[type="password"],
input[type="file"] {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text);
    outline: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    background-color: rgba(255, 255, 255, 0.12);
}

.api-key-container {
    position: relative;
    display: flex;
    align-items: center;
}

.api-key-container input {
    padding-right: 36px;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 10px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
}

.toggle-password:hover {
    opacity: 1;
    color: var(--text);
}

/* File Upload Styles */
.file-info {
    font-size: 0.85rem; /* Unified font size */
    margin-top: 6px;
    padding: 6px 0;
    font-style: italic;
}
.file-info.success {
    color: var(--success);
    font-weight: 500;
}
.file-info.error {
    color: var(--error);
    font-weight: 500;
}
.file-info.processing {
    color: var(--warning);
    font-weight: 500;
}

.reference-info {
    font-size: 0.85rem;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.18);
    border-radius: 10px;
    margin-top: 10px;
    border-left: 3px solid var(--accent);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 8px;
    text-transform: uppercase;
}

.status-success {
    background-color: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.status-error {
    background-color: rgba(231, 76, 60, 0.15);
    color: var(--error);
}

.status-partial {
    background-color: rgba(243, 156, 18, 0.15);
    color: var(--warning);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .container {
        height: calc(100vh - 20px);
        padding: 10px;
    }
    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1rem;
    }
    .message {
        max-width: 92%;
        font-size: 0.95rem;
    }
    textarea {
        font-size: 0.9rem;
        padding: 12px 16px;
    }
    .input-area {
        padding: 10px;
    }
    button {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}