/* Base styles */
:root {
    /* Dark theme (default) */
    --bg-color: #121212;
    --sidebar-bg: #1e1e1e;
    --card-bg: #2a2a2a;
    --input-bg: #2a2a2a;
    --modal-bg: #2a2a2a;
    --border-color: #444;
    --text-color: #fff;
    --text-secondary: #aaa;
    --accent-color: #D4000B;
    --accent-color-rgb: 212, 0, 11;
    --accent-hover: #F5222D;
    --danger-color: #ff5252;
    --success-color: #4caf50;
    --user-msg-bg: #2a2a2a;
    --bot-msg-bg: #3a3a3a;
    --scrollbar-thumb: #666;
    --scrollbar-track: #333;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --sidebar-width: 300px;
    --header-height: 60px;
    --primary-color: #5469FF;
    --secondary-color: #F5F5F5;
    --light-text: #888;
    --background-color: #fff;
    --chat-bubble-user: #E6F7FF;
    --chat-bubble-assistant: #F5F5F5;
    --hover-color: #F0F0F0;
    --container-border-radius: 10px;
    --button-border-radius: 4px;
    --status-connecting: #FFA500;
    --status-connected: #00A67E;
    --status-error: #FF5252;
    --font-size: 16px;
}

/* Light theme */
[data-theme="light"] {
    --bg-color: #f5f5f5;
    --sidebar-bg: #e5e5e5;
    --card-bg: #fff;
    --input-bg: #fff;
    --modal-bg: #fff;
    --border-color: #ddd;
    --text-color: #333;
    --text-secondary: #666;
    --accent-color: #D4000B;
    --accent-color-rgb: 212, 0, 11;
    --accent-hover: #F5222D;
    --danger-color: #f44336;
    --success-color: #4caf50;
    --user-msg-bg: #e3f2fd;
    --bot-msg-bg: #f5f5f5;
    --scrollbar-thumb: #ccc;
    --scrollbar-track: #eee;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: var(--font-size);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 0.5rem;
}

button {
    cursor: pointer;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: var(--accent-color);
    color: white;
    font-weight: 500;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--accent-hover);
}

button.danger-btn {
    background-color: var(--danger-color);
}

button.secondary-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

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

input, select, textarea {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-color);
    width: 100%;
    font-size: 1rem;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-color);
}

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

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

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

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

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1000;
    box-shadow: 2px 0 5px var(--shadow-color);
    transition: transform 0.3s ease-in-out;
    transform: translateX(0); /* By default visible on desktop */
}

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

.sidebar-header h1 {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

#help-btn {
    width: 24px;
    height: 24px;
    font-size: 16px;
    font-weight: bold;
    padding: 0;
    border-radius: 4px;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
}

.character-list-container, .conversation-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.character-list-header, .conversation-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.character-list, .conversation-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}

.empty-list {
    padding: 1rem;
    color: var(--text-secondary);
    text-align: center;
    background-color: rgba(var(--accent-color-rgb), 0.05);
    border-radius: 4px;
    margin: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
    border-left: 3px solid var(--accent-color);
}

.default-empty-message {
    display: block;
}

.character-import {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.character-import button {
    width: 100%;
}

.character-card, .conversation-card {
    background-color: var(--card-bg);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: box-shadow 0.2s;
    display: flex;
    align-items: center;
    position: relative;
}

.character-card:hover, .conversation-card:hover {
    box-shadow: 0 2px 8px var(--shadow-color);
}

.character-card.active, .conversation-card.active {
    border-left: 3px solid var(--accent-color);
}

.character-card img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.5rem;
    object-fit: cover;
}

.character-info, .conversation-info {
    flex: 1;
    overflow: hidden;
}

.character-name, .conversation-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.character-description, .conversation-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-btn {
    opacity: 0;
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background-color: var(--danger-color);
    color: white;
    width: 22px;
    height: 22px;
    font-size: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: opacity 0.2s;
}

.character-card:hover .delete-btn, 
.conversation-card:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background-color: var(--danger-color);
    opacity: 1;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer button {
    width: 100%;
}

/* Chat area */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease-in-out;
    background-color: var(--bg-color);
}

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

.chat-header-left {
    display: flex;
    align-items: center;
    max-width: 75%;
    overflow: hidden;
}

.chat-character-info {
    display: flex;
    align-items: center;
    margin-left: 5px;
    overflow: hidden;
}

.chat-character-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 0.5rem;
    object-fit: cover;
    flex-shrink: 0;
}

#character-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.2rem;
    margin: 0;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    align-items: center;
}

.chat-actions button {
    margin-left: 0;
    white-space: nowrap;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
}

.welcome-message {
    margin: auto;
    text-align: center;
    max-width: 500px;
}

.welcome-message h3 {
    margin-bottom: 1rem;
}

.message {
    max-width: 80%;
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    position: relative;
}

.message-user {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    border-bottom-right-radius: 0;
}

.message-bot {
    align-self: flex-start;
    background-color: var(--bot-msg-bg);
    border-bottom-left-radius: 0;
}

.message-header {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.message-timestamp {
    font-size: 0.7rem;
    color: var(--text-secondary);
    position: absolute;
    bottom: 0.25rem;
    right: 0.5rem;
}

.chat-input-container {
    display: flex;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input-container textarea {
    flex: 1;
    resize: none;
    height: 60px;
    margin-right: 0.5rem;
}

/* Settings panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background-color: var(--modal-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 10px var(--shadow-color);
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.settings-panel.hidden {
    transform: translateX(100%);
}

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

.settings-header button {
    background: none;
    color: var(--text-color);
    font-size: 1.5rem;
    padding: 0;
}

.settings-content {
    padding: 1rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
}

.destructive-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.destructive-actions h4 {
    color: var(--danger-color);
    margin-bottom: 1rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
}

.warning-text {
    color: var(--danger-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--modal-bg);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px var(--shadow-color);
}

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

.modal-header button {
    background: none;
    color: var(--text-color);
    font-size: 1.5rem;
    padding: 0;
}

.modal-body {
    padding: 1rem;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.modal-footer button {
    margin-left: 0.5rem;
}

.avatar-upload {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
}

.avatar-upload img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin-right: 1rem;
    object-fit: cover;
}

/* Responsive design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .chat-container {
        margin-left: 0;
    }
    
    .hamburger-btn {
        display: block;
    }
    
    .settings-panel {
        width: 100%;
    }
    
    /* Make chat input take the full width */
    .chat-input-container {
        padding: 10px;
    }
    
    #chat-input {
        min-height: 44px;
        max-height: 120px;
    }
    
    /* Improve chat message spacing */
    .chat-messages {
        padding: 10px;
    }
    
    .message {
        max-width: 85%;
        margin-bottom: 12px;
    }
    
    /* Redesign header layout on mobile */
    .chat-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 10px;
    }
    
    .chat-header-left {
        max-width: 100%;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .chat-actions {
        align-self: flex-start;
        margin-left: 50px; /* Align with the character name */
    }
    
    .chat-actions button {
        padding: 5px 8px;
        font-size: 14px;
    }
    
    /* Ensure sidebar is properly sized on mobile */
    .sidebar {
        width: 280px;
    }
    
    /* Make sure main UI elements stay visible */
    .chat-character-info {
        max-width: calc(100% - 100px);
        overflow: hidden;
    }
    
    #character-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Adjust the overlay for settings panel */
    .settings-panel {
        width: 90%;
        max-width: 400px;
    }
    
    :root {
        --font-size: 14px;
    }
}

@media (max-width: 480px) {
    :root {
        --font-size: 13px;
    }
    
    /* Adjust the overlay for settings panel */
    .settings-panel {
        width: 90%;
        max-width: 400px;
    }
    
    .chat-header-left {
        max-width: 100%;
    }
    
    .chat-actions {
        margin-left: 45px; /* Slightly adjust alignment on smaller screens */
    }
    
    .chat-actions button {
        padding: 4px 6px;
        font-size: 12px;
    }
}

/* Notifications */
.notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    max-width: 80%;
}

.notification {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    align-items: center;
    animation: notification-fade-in 0.3s ease-out;
    min-width: 200px;
    max-width: 100%;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s, transform 0.3s;
}

.notification.removing {
    opacity: 0;
    transform: translateY(-20px);
}

.notification.info {
    border-left: 4px solid #4dabf7;
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.warning {
    border-left: 4px solid #ffc107;
}

.notification-content {
    flex: 1;
    margin: 0;
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes notification-fade-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Status message (legacy - to be removed) */
.status-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Import tabs */
.import-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    margin-right: 0.5rem;
    color: var(--text-color);
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.tab-btn:hover {
    background-color: var(--card-bg);
}

.tab-btn.active {
    border-bottom: 2px solid var(--accent-color);
    font-weight: 600;
}

.tab-content {
    padding: 0.5rem 0;
}

.tab-content.hidden {
    display: none;
}

.info-box {
    background-color: rgba(var(--accent-color-rgb), 0.1);
    border-left: 3px solid var(--accent-color);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.info-box p {
    margin: 0;
    font-size: 0.9rem;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

/* File upload control */
.file-upload {
    margin: 1rem 0;
}

.file-upload label {
    display: block;
    margin-bottom: 0.5rem;
}

.file-upload-control {
    display: flex;
    align-items: center;
}

.file-upload-control input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.file-upload-control button {
    margin-right: 0.5rem;
}

#json-file-name {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Message formatting */
.accent-text {
    color: var(--accent-color);
}

.message-content em {
    font-style: italic;
}

.message-content strong {
    font-weight: 600;
}

.message-content {
    font-size: var(--font-size);
    line-height: 1.5;
}

/* Typing indicator */
.typing-indicator {
    padding: 0.5rem 1rem;
}

.typing-indicator .dots {
    display: inline-block;
}

.typing-indicator .dots span {
    animation: wave 1.3s linear infinite;
    display: inline-block;
    font-size: 20px;
    line-height: 1;
}

.typing-indicator .dots span:nth-child(2) {
    animation-delay: -1.1s;
}

.typing-indicator .dots span:nth-child(3) {
    animation-delay: -0.9s;
}

@keyframes wave {
    0%, 60%, 100% {
        transform: initial;
    }
    30% {
        transform: translateY(-5px);
    }
}

/* Utility classes */
.hamburger-btn {
    background: none;
    color: var(--text-color);
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
    display: block;
}

.hamburger-btn:hover {
    background-color: rgba(var(--accent-color-rgb), 0.1);
}

.character-actions {
    display: flex;
    gap: 8px;
}

/* Animation */
.sidebar.active {
    transform: translateX(0);
} 