/* 容器样式 */
.acc-window {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* 适配移动端动态视口 */
    background-color: #1e1e1e !important;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    z-index: 99999 !important; /* 确保在最上层，超过 SillyTavern 的层级 */
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

/* 顶部栏 */
.acc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #252526;
    border-bottom: 1px solid #333;
    height: 50px;
    box-sizing: border-box;
}

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

.acc-logo {
    color: #ffc107;
    font-size: 18px;
}

.acc-title {
    font-size: 16px;
    font-weight: bold;
}

.acc-status-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background-color: #333;
}

.status-idle { color: #888; }
.status-working { color: #4CAF50; background-color: rgba(76, 175, 80, 0.1); }
.status-error { color: #f44336; background-color: rgba(244, 67, 54, 0.1); }

.acc-control-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 8px;
    font-size: 14px;
    transition: color 0.2s;
}

.acc-control-btn:hover {
    color: #fff;
}

/* 主体内容 */
.acc-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.acc-column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
}

.acc-column:last-child {
    border-right: none;
}

/* 左栏：设置 */
.acc-left-panel {
    width: 250px;
    background-color: #252526;
    min-width: 200px;
}

/* 中栏：交互 */
.acc-center-panel {
    flex: 1;
    background-color: #1e1e1e;
    min-width: 300px;
}

/* 右栏：预览 */
.acc-right-panel {
    width: 40%;
    background-color: #1e1e1e;
    min-width: 300px;
}

/* 面板通用样式 */
.acc-panel-header {
    padding: 10px 15px;
    background-color: #2d2d2d;
    border-bottom: 1px solid #333;
    font-size: 13px;
    font-weight: bold;
    color: #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* overflow: hidden; Removed to allow dropdowns to show fully if custom, though native selects are fine. */
}

.acc-panel-header i.fa-chevron-down,
.acc-panel-header i.fa-chevron-up {
    margin-left: auto; /* Use flexbox alignment instead of float */
}

.acc-panel-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

/* 表单元素 */
.acc-form-group {
    margin-bottom: 15px;
}

.acc-form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: #888;
}

.acc-select {
    width: 100%;
    padding: 8px;
    background-color: #3c3c3c;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
}

.acc-input {
    width: 100%;
    padding: 8px;
    background-color: #3c3c3c;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
    box-sizing: border-box; /* Ensure padding doesn't affect width */
}

.acc-input:focus {
    outline: none;
    border-color: #0e639c;
}

.acc-btn-primary {
    background-color: #0e639c;
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.acc-btn-primary:hover {
    background-color: #1177bb;
}

.acc-btn-secondary {
    background-color: #3c3c3c;
    color: #ccc;
    border: 1px solid #555;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.acc-btn-secondary:hover {
    background-color: #444;
    color: #fff;
    border-color: #666;
}

.acc-divider {
    height: 1px;
    background-color: #333;
    margin: 20px 0;
}

/* 任务列表 */
.acc-section-title {
    font-size: 12px;
    color: #888;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.acc-task-item {
    padding: 8px;
    margin-bottom: 5px;
    background-color: #333;
    border-radius: 4px;
    font-size: 13px;
}

.acc-task-item.active {
    border-left: 3px solid #ffc107;
    background-color: rgba(255, 193, 7, 0.1);
}

/* 聊天区域 (Cline Style) */
.acc-chat-stream {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background-color: #1e1e1e;
}

.acc-message {
    display: flex;
    gap: 16px;
    max-width: 100%;
    padding: 0 10px;
}

.acc-avatar {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    background-color: #2d2d2d;
}

.acc-message-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: #d4d4d4;
    overflow-wrap: break-word;
}

/* User Message */
.acc-message.user {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 16px;
    margin-left: 10px;
    margin-right: 10px;
    width: auto;
}

.acc-message.user .acc-avatar {
    display: flex; /* Show avatar for user */
    background-color: #0e639c;
    color: #fff;
}

.acc-message.user .acc-message-content {
    color: #ffffff;
    font-weight: 500;
}

/* Assistant Message */
.acc-message.assistant {
    padding: 16px;
    background-color: #252526;
    border-radius: 8px;
    border: 1px solid #333;
    margin-left: 10px;
    margin-right: 10px;
    width: auto;
}

.acc-message.assistant .acc-avatar {
    background-color: transparent;
    color: #4caf50; /* Green robot */
    font-size: 20px;
}

/* Markdown Styles */
.acc-message-content code {
    background-color: rgba(110, 118, 129, 0.4); /* VSCode style inline code bg */
    color: #e0e0e0;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.9em;
}

.acc-message-content pre {
    background-color: #1e1e1e;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid #333;
    margin: 12px 0;
}

.acc-message-content pre code {
    background-color: transparent;
    padding: 0;
    border: none;
    color: #9cdcfe;
}

.acc-message-content p {
    margin: 0 0 10px 0;
}

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

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

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

/* Tool Request Styles */
.acc-tool-request {
    background-color: #252526;
    border: 1px solid #333;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.acc-tool-header {
    background-color: #2d2d2d;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #e0e0e0;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.acc-tool-header:hover {
    background-color: #333;
}

.acc-tool-header i {
    color: #e5c07b; /* Gold icon */
}

.acc-tool-content {
    padding: 14px;
    margin: 0;
    background-color: #1e1e1e;
    color: #9cdcfe;
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    line-height: 1.5;
}

/* System/Thought Message */
.acc-message.system, .acc-message.thought {
    padding: 0 10px;
    opacity: 0.9;
}

.acc-message.thought .acc-avatar {
    color: #9c27b0;
    background-color: transparent;
}

.acc-message.thought .acc-message-content {
    color: #8b949e;
    font-style: italic;
    background-color: rgba(156, 39, 176, 0.05);
    padding: 10px 14px;
    border-radius: 6px;
    border-left: 3px solid #9c27b0;
}

/* 输入区域 */
.acc-input-area {
    padding: 15px;
    background-color: #252526;
    border-top: 1px solid #333;
}

.acc-input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#acc-user-input {
    flex: 1;
    background-color: #3c3c3c;
    border: 1px solid #555;
    color: #fff;
    padding: 10px;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
}

#acc-user-input:focus {
    outline: none;
    border-color: #0e639c;
}

.acc-send-btn {
    background-color: #0e639c;
    color: #fff;
    border: none;
    border-radius: 4px;
    width: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.acc-send-btn:hover {
    background-color: #1177bb;
}

.acc-btn-success {
    background-color: #4caf50 !important;
}

.acc-btn-success:hover {
    background-color: #45a049 !important;
}

.acc-btn-danger {
    background-color: #d32f2f;
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* 预览区域 (Editor Tabs) */
.acc-preview-tabs {
    display: flex;
    background-color: #252526;
    border-bottom: 1px solid #2b2b2b;
    overflow-x: auto;
}

.acc-tab-btn {
    background: #2d2d2d;
    border: none;
    border-right: 1px solid #252526;
    color: #969696;
    cursor: pointer;
    padding: 8px 15px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
}

.acc-tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.acc-tab-btn:hover {
    background-color: #2a2d2e;
    color: #cccccc;
}

.acc-tab-btn.active {
    background-color: #1e1e1e;
    color: #ffffff;
    border-top: 2px solid #0e639c; /* Active tab indicator */
}

.acc-tab-btn i {
    font-size: 14px;
    color: #e7c05e; /* JS/File icon color */
    flex-shrink: 0;
}

.acc-tab-close {
    flex-shrink: 0;
    margin-left: 5px;
    cursor: pointer;
    opacity: 0.7;
}

.acc-tab-close:hover {
    opacity: 1;
    color: #fff;
}

.acc-editor-content {
    flex: 1;
    overflow-y: auto;
    background-color: #1e1e1e;
    padding: 0; /* Remove padding to let editor fill space */
}

/* Hide scrollbar for tabs but allow scrolling */
.acc-preview-tabs::-webkit-scrollbar {
    height: 3px;
}
.acc-preview-tabs::-webkit-scrollbar-thumb {
    background: #444;
}

.acc-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #555;
}

.acc-empty-state i {
    font-size: 48px;
    margin-bottom: 10px;
}

/* 最小化图标 */
.acc-minimized-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background-color: #0e639c;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 2001;
    color: #fff;
    font-size: 24px;
    transition: transform 0.2s;
}

.acc-minimized-icon:hover {
    transform: scale(1.1);
}

.acc-notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background-color: #f44336;
    border-radius: 50%;
    border: 2px solid #1e1e1e;
}

/* Cursor-like Editor Styles */
.cursor-card {
    background-color: #181818; /* Cursor dark background */
    color: #cccccc;
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #2b2b2b;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.cursor-header {
    background-color: #202020;
    padding: 8px 12px;
    border-bottom: 1px solid #2b2b2b;
    font-size: 12px;
    color: #8b949e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.cursor-filename {
    color: #c9d1d9;
    font-weight: 500;
}

.cursor-actions {
    display: flex;
    gap: 6px;
}

.cursor-action-btn {
    background: transparent;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.cursor-action-btn:hover {
    background-color: #30363d;
    border-color: #8b949e;
}

.cursor-content {
    padding: 4px 0;
    overflow-x: auto;
}

.cursor-line {
    display: flex;
    padding: 0;
    min-height: 21px; /* Ensure empty lines have height */
}

.cursor-line-number {
    color: #484f58;
    min-width: 40px;
    text-align: right;
    padding-right: 16px;
    user-select: none;
    font-size: 12px;
    line-height: 1.7; /* Align with content */
    background-color: #181818;
    border-right: 1px solid transparent; /* Optional separator */
}

.cursor-line-content {
    white-space: pre-wrap;
    flex: 1;
    padding-left: 8px;
    padding-right: 8px;
}

/* Syntax Highlighting (Cursor/Dark Modern) */
.syntax-key { color: #ff7b72; } /* Red/Pink */
.syntax-string { color: #a5d6ff; } /* Light Blue */
.syntax-number { color: #79c0ff; } /* Blue */
.syntax-comment { color: #8b949e; font-style: italic; } /* Grey */
.syntax-func { color: #d2a8ff; } /* Purple */

/* Diff Styles (Cursor Style) */
.diff-added {
    background-color: rgba(46, 160, 67, 0.15);
}

.diff-added .cursor-line-number {
    background-color: rgba(46, 160, 67, 0.15); /* Match line bg */
    color: rgba(255, 255, 255, 0.6);
    border-left: 3px solid #2ea043; /* Green marker */
}

.diff-removed {
    background-color: rgba(248, 81, 73, 0.15);
    opacity: 0.8;
}

.diff-removed .cursor-line-number {
    background-color: rgba(248, 81, 73, 0.15);
    color: rgba(255, 255, 255, 0.6);
    border-left: 3px solid #f85149; /* Red marker */
}

.diff-removed .cursor-line-content {
    text-decoration: line-through;
    text-decoration-color: rgba(255, 255, 255, 0.4);
}

/* Mobile Navigation */
.acc-mobile-nav {
    display: none;
    /* Flex item in .acc-window */
    height: 60px;
    background-color: #252526;
    border-top: 1px solid #333;
    z-index: 2002;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
}

.acc-nav-btn {
    background: none;
    border: none;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
    padding: 8px;
    flex: 1;
}

.acc-nav-btn.active {
    color: #0e639c;
}

.acc-nav-btn i {
    font-size: 18px;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .acc-mobile-nav {
        display: flex;
    }

    .acc-body {
        padding-bottom: 0; /* Nav is now a flex item */
    }

    .acc-column {
        width: 100% !important;
        border-right: none;
        display: none; /* Hidden by default on mobile */
        height: 100%;
    }
    
    /* Show center panel by default or via JS class */
    .acc-column.mobile-active {
        display: flex;
    }

    /* Adjust header */
    .acc-title {
        display: none; /* Hide title on small screens */
    }
    
    .acc-header {
        padding: 5px 10px;
    }
    
    /* Adjust panels */
    .acc-left-panel, .acc-right-panel {
        min-width: 100%;
    }
    
    /* Adjust chat input */
    .acc-input-area {
        padding: 10px;
    }
}
