/* Custom premium styling for DeepSeek + Doubao combined layout */

:root {
    --bg-dark: #0b0f19;
    --bg-sidebar: #111827;
    --bg-card: #1f2937;
    --bg-bubble-ai: #1f2937;
    --bg-bubble-user: rgba(242, 123, 33, 0.15);
    --border-color: #374151;
    --text-light: #f3f4f6;
    --text-gray: #9ca3af;
    --text-dim: #6b7280;
    --primary: #f27b21;
    --primary-hover: #e06010;
    --primary-rgb: 242, 123, 33;
    --accent-red: #ef4444;
    --font-family: 'Outfit', 'Noto Sans SC', sans-serif;
    --sidebar-width: 260px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-family);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

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

/* ───── Left Sidebar (DeepSeek Style) ───── */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.search-section {
    padding: 12px 16px;
}

.search-wrapper {
    position: relative;
    width: 100%;
}

.search-input {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px 8px 32px;
    color: var(--text-light);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    fill: var(--text-dim);
}

/* Session List */
.session-list-section {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-list-section::-webkit-scrollbar {
    width: 4px;
}

.session-list-section::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-gray);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    group: relative;
    border: 1px solid transparent;
}

.session-item:hover, .session-item.active {
    background-color: var(--bg-card);
    color: var(--text-light);
}

.session-item.active {
    border-color: rgba(var(--primary-rgb), 0.3);
}

.session-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.session-item-delete {
    opacity: 0.3;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

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

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

.session-item-delete svg {
    width: 14px;
    height: 14px;
    fill: var(--accent-red);
    pointer-events: none;
}

/* Two-step delete confirm styles */
.session-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-item-confirm,
.session-item-cancel {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.session-item-confirm:hover,
.session-item-cancel:hover {
    opacity: 1;
}

.session-item-confirm svg {
    width: 14px;
    height: 14px;
    fill: #22c55e;
    pointer-events: none;
}

.session-item-cancel svg {
    width: 14px;
    height: 14px;
    fill: #94a3b8;
    pointer-events: none;
}

.session-item.confirm-delete {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.session-item.confirm-delete .session-item-title {
    color: #ef4444 !important;
}

.session-item.confirm-delete .session-item-delete {
    display: none !important;
}

.session-item.confirm-delete .session-item-confirm,
.session-item.confirm-delete .session-item-cancel {
    display: flex;
}


/* Sidebar Footer (Profile) */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0, 0, 0, 0.15);
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
}

.profile-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-more-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.profile-more-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.profile-more-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Profile Dropdown Menu */
.profile-menu {
    position: absolute;
    bottom: 60px;
    left: 16px;
    width: 228px;
    background-color: #1f2937;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 20;
    padding: 6px 0;
    display: none;
}

.profile-menu.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-gray);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.profile-menu-item.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
}

.profile-menu-item svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.profile-menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 6px 0;
}

/* ───── Middle Chat Container (Doubao Style) ───── */
.chat-container {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    position: relative;
}

/* Header */
.chat-header {
    height: 64px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(10px);
    z-index: 5;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-toggle-btn:hover {
    background-color: var(--bg-card);
    color: var(--text-light);
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-light);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* TTS Switch / Button */
.tts-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.tts-toggle-btn:hover {
    background-color: var(--bg-card);
    color: var(--text-light);
    border-color: var(--primary);
}

.tts-toggle-btn.active {
    color: var(--primary);
    border-color: var(--primary);
    background-color: rgba(var(--primary-rgb), 0.1);
}

.tts-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.login-header-btn {
    background-color: rgba(var(--primary-rgb), 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.login-header-btn:hover {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 12px rgba(var(--primary-rgb), 0.3);
}

/* Chat Messages Panel */
.messages-panel {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.messages-panel::-webkit-scrollbar {
    width: 6px;
}

.messages-panel::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.message-wrapper {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    max-width: 85%;
}

.message-wrapper.user {
    align-items: flex-end;
}

.message-wrapper.user .message-bubble {
    background-color: var(--bg-bubble-user);
    color: var(--text-light);
    border-bottom-right-radius: 2px;
    border: 1px solid rgba(var(--primary-rgb), 0.3);
}

.message-wrapper.ai {
    align-items: flex-start;
}

.message-wrapper.ai .message-bubble {
    background-color: var(--bg-bubble-ai);
    color: var(--text-light);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

.message-meta {
    font-size: 11px;
    color: var(--text-dim);
    margin: 0 4px;
}

/* Empty State (Doubao Style) */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 20px;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
}

.greeting-text {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 32px;
    text-align: center;
    background: linear-gradient(135deg, #ffffff, #e2e8f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

@media (max-width: 600px) {
    .suggestions-grid {
        grid-template-columns: 1fr;
    }
}

.suggestion-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.suggestion-card:hover {
    border-color: rgba(var(--primary-rgb), 0.5);
    transform: translateY(-2px);
    background-color: rgba(255, 255, 255, 0.02);
}

.suggestion-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.suggestion-desc {
    font-size: 12px;
    color: var(--text-gray);
    line-height: 1.4;
}

/* Bottom Input Area */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(11, 15, 25, 0.9);
}

.input-box-wrapper {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    align-items: flex-end;
    padding: 8px 12px;
    gap: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-box-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.15);
}

.input-mode-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-gray);
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.input-mode-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.input-mode-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.text-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-light);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    padding: 8px 4px;
    line-height: 1.5;
}

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

.voice-hold-btn {
    flex: 1;
    height: 38px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-gray);
    font-size: 13px;
    font-weight: 600;
    display: none; /* Controlled by JS toggle */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.voice-hold-btn:active, .voice-hold-btn.recording {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.input-send-btn {
    background-color: var(--primary);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-bottom: 2px;
}

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

.input-send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* WeChat holding Voice Overlay HUD */
.voice-hud-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.voice-hud-overlay.show {
    display: flex;
}

.voice-hud-card {
    background-color: rgba(31, 41, 55, 0.85);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    backdrop-filter: blur(10px);
    width: 220px;
    height: 220px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.voice-hud-mic-icon {
    width: 60px;
    height: 60px;
    fill: var(--primary);
    animation: pulseGlow 1.5s infinite;
}

.voice-hud-text {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    text-align: center;
}

.voice-hud-hint {
    font-size: 12px;
    color: var(--accent-red);
    text-align: center;
}

/* Modals & Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 450px;
    max-width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

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

.modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-light);
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-gray);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close-btn:hover {
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-gray);
}

.form-input {
    width: 100%;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text-light);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    border-color: var(--primary);
}

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

.btn {
    padding: 8px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-gray);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
}

.btn-primary {
    background-color: var(--primary);
    border: none;
    color: #fff;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Markdown Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
}
.markdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}
.markdown-table th, .markdown-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}
.markdown-table th {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    font-weight: 600;
}
.markdown-table tr:last-child td {
    border-bottom: none;
}
.markdown-table tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}
.markdown-code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

