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

:root {
    --bg-primary: #343541;
    --bg-secondary: #40414f;
    --bg-tertiary: #565869;
    --bg-hover: #4e4f5c;
    --text-primary: #ececf1;
    --text-secondary: #8e8ea0;
    --border-color: #565869;
    --accent-color: #10a37f;
    --accent-hover: #0d8f6e;
    --message-user-bg: #343541;
    --message-ai-bg: #444654;
    --sidebar-width: 260px;
    --input-height: 56px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

/* Settings Button */
.settings-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

/* Chat Container */
.chat-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

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

.sidebar-content {
    padding: 20px;
    flex: 1;
}

.persona-section {
    margin-bottom: 20px;
}

.persona-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.label-icon {
    font-size: 16px;
}

.persona-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.persona-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.persona-description {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

.description-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sidebar-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
}

.info-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-icon {
    font-size: 14px;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

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

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

.welcome-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 20px;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

.message-user {
    background: var(--message-user-bg);
}

.message-ai {
    background: var(--message-ai-bg);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--accent-color);
}

.message-ai .message-avatar {
    background: var(--bg-tertiary);
}

.message-content {
    flex: 1;
    min-width: 0;
}

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

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

.message-text {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.streaming-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    margin-left: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.message.streaming {
    border-left: 3px solid var(--accent-color);
}

.gradient-link {
    color: #10a37f;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.gradient-link:hover {
    color: #0d8f6e;
    text-decoration: underline;
}

/* Sessions List */
.sessions-section {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}

.sessions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.new-session-btn {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.new-session-btn:hover {
    background: #0d8f6e;
    transform: scale(1.1);
}

.sessions-list {
    max-height: 300px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.session-item:hover {
    background: var(--bg-tertiary);
}

.session-item.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.session-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

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

.session-info {
    flex: 1;
    min-width: 0;
}

.session-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.session-delete {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
}

.session-item:hover .session-delete {
    opacity: 1;
}

.session-delete:hover {
    background: var(--error-color);
    color: white;
}

.no-sessions {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Reply Styles with Copy Buttons */
.reply-styles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.reply-card {
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px;
    background: var(--bg-secondary);
}

.reply-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.reply-copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    opacity: 0.7;
}

.reply-copy-btn:hover {
    opacity: 1;
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.reply-content {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn-small {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn-small:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Reply Styles Display */
.reply-styles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.reply-card {
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.reply-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

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

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.6;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.send-btn {
    width: 32px;
    height: 32px;
    background: var(--accent-color);
    border: none;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.1);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    padding: 12px 24px;
    background: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.config-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}

.config-status.success {
    display: block;
    background: rgba(16, 163, 127, 0.1);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.config-status.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid #ef4444;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loading-overlay p {
    color: var(--text-primary);
    font-size: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        z-index: 1500;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .chat-main {
        width: 100%;
    }

    .settings-btn {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
}
