/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

ul, ol, li {
    list-style: none;
    list-style-type: none;
}

.sidebar-section,
.chat-history {
    list-style: none;
}

.sidebar-section::before,
.chat-history::before,
.sidebar-section::after,
.chat-history::after {
    display: none;
}

:root {
    --bg-primary: #343541;
    --bg-secondary: #2b2c31;
    --bg-tertiary: #40414f;
    --bg-hover: #4a4b57;
    --text-primary: #ececf1;
    --text-secondary: #c5c5d2;
    --text-muted: #8e8ea0;
    --text-error: #ef4444;
    --border-color: #4d4d4f;
    --accent-color: #10a37f;
    --accent-hover: #1a7f64;
    --user-msg-bg: #444654;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

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

/* App container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    flex-shrink: 0;
}

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

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background-color var(--transition);
    position: relative;
}

.new-chat-btn::before,
.new-chat-btn::after {
    display: none !important;
}

.new-chat-btn:hover {
    background-color: var(--bg-hover);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.sidebar-section-title {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color var(--transition);
    font-size: 14px;
    color: var(--text-secondary);
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.chat-history-item::before {
    display: none !important;
}

.chat-history-item > svg.chat-icon {
    flex-shrink: 0;
    opacity: 0.7;
}

.chat-history-item > span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item > .delete-btn {
    flex-shrink: 0;
    opacity: 0;
    padding: 6px;
    border-radius: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
}

.chat-history-item:hover > .delete-btn {
    opacity: 1;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.itts-link,
.settings-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition);
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.itts-link:hover,
.settings-btn:hover {
    background-color: var(--bg-hover);
}

/* Mobile sidebar toggle */
.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    padding: 8px;
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color var(--transition);
}

.mobile-sidebar-toggle:hover {
    background-color: var(--bg-hover);
}

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

.main-header {
    padding: 16px 24px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.header-title h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.header-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

/* Chat container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 120px;
}

.chat-messages {
    max-width: 768px;
    margin: 0 auto;
    padding: 24px;
}

/* Welcome section */
.welcome-section {
    text-align: center;
    padding: 48px 24px;
}

.welcome-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background-color: var(--bg-tertiary);
    border-radius: 50%;
    margin-bottom: 24px;
    color: var(--accent-color);
}

.welcome-section h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.welcome-section p {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* Suggestion cards */
.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.suggestion-card:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.suggestion-card svg {
    color: var(--accent-color);
    flex-shrink: 0;
}

/* Message styles */
.message {
    display: flex;
    gap: 16px;
    padding: 24px 0;
    border-bottom: 1px solid transparent;
}

.message:last-child {
    border-bottom: none;
}

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

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

.message.assistant .message-avatar {
    background-color: #7c4dff;
}

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

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

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

.message-content code {
    background-color: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.message-content pre {
    background-color: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
}

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

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}

.message-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

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

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

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

/* Input area */
.input-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, var(--bg-primary) 20%);
    padding: 24px;
}

.input-container {
    max-width: 768px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.input-container:focus-within {
    border-color: var(--accent-color);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    outline: none;
    font-family: inherit;
    align-self: center;
    min-height: 24px;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: background-color var(--transition);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.send-btn:disabled {
    background-color: var(--bg-hover);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-footer {
    text-align: center;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background-color: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition);
}

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

.modal-body {
    padding: 24px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

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

.setting-select {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    font-family: inherit;
}

.setting-select:focus {
    border-color: var(--accent-color);
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
}

.setting-group input[type="range"] {
    width: 100%;
    margin-right: 12px;
    accent-color: var(--accent-color);
}

.range-value {
    font-size: 14px;
    color: var(--text-secondary);
}

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

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

    .mobile-sidebar-toggle {
        display: flex;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .chat-messages {
        padding: 16px;
    }

    .message {
        gap: 12px;
    }

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

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

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

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

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

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

.sidebar-overlay.active {
    display: block;
}

/* Empty history state */
.empty-history {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 14px;
}
