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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Helvetica, Arial, sans-serif;
    background: #f8f9fa;
    height: 100vh;
    overflow: hidden;
}

/* 导航栏 */
.navbar {
    background: white;
    border-bottom: 1px solid #e1e5e9;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 24px;
    font-weight: 600;
    color: #2d3748;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.api-selector {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    outline: none;
}

.mode-toggle {
    display: flex;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    overflow: hidden;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    background: white;
    color: #4a5568;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.mode-btn:hover:not(.active) {
    background: #f7fafc;
}

/* 模式容器 */
.mode-container {
    display: none;
    height: calc(100vh - 60px);
    margin-top: 60px;
}

.mode-container.active {
    display: block;
}

/* 聊天模式 */
.chat-wrapper {
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    scroll-behavior: smooth;
}

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 200px;
}

.welcome-content {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 16px;
    border: 1px solid #e1e5e9;
    max-width: 400px;
}

.welcome-content h2 {
    color: #2d3748;
    margin-bottom: 12px;
    font-size: 24px;
}

.welcome-content p {
    color: #4a5568;
    line-height: 1.6;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message.assistant .message-avatar {
    background: #e2e8f0;
    color: #4a5568;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message.user .message-content {
    background: #667eea;
    color: white;
}

.message.assistant .message-content {
    background: white;
    color: #2d3748;
    border: 1px solid #e1e5e9;
}

.chat-input-container {
    padding: 20px 0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 16px;
    padding: 12px 16px;
}

#chat-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
}

.send-btn {
    padding: 8px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #5a67d8;
}

.send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* 修改模式 */
.edit-wrapper {
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.edit-panels {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    height: 100%;
}

.input-panel, .middle-panel, .output-panel {
    background: white;
    border-radius: 12px;
    border: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
}

.edit-controls {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex-direction: column;
}

.plugin-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.plugin-selector {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    background: white;
    cursor: pointer;
    min-width: 180px;
    font-weight: 500;
}

.plugin-selector:hover {
    border-color: #cbd5e0;
}

.plugin-selector:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.plugin-description {
    font-size: 12px;
    color: #718096;
    font-style: italic;
    flex: 1;
}

.instruction-input {
    padding: 8px 12px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    width: 100%;
    transition: border-color 0.2s ease;
}

.instruction-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modify-btn, .copy-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modify-btn {
    background: #667eea;
    color: white;
}

.modify-btn:hover {
    background: #5a67d8;
}

.copy-btn {
    background: #48bb78;
    color: white;
}

.copy-btn:hover {
    background: #38a169;
}

.copy-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.edit-textarea {
    flex: 1;
    border: none;
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.edit-output {
    flex: 1;
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
    overflow-y: auto;
    outline: none;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    white-space: pre-wrap;
    color: #2d3748;
    background: #f8f9fa;
}

.edit-output:empty::before {
    content: "修改结果将显示在这里...";
    color: #a0aec0;
}

/* 差异视图样式 */
.diff-view {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.diff-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.diff-line {
    display: flex;
    align-items: center;
    padding: 2px 0;
    border-left: 3px solid transparent;
}

.diff-line.unchanged {
    background: #f8f9fa;
}

.diff-line.added {
    background: #e6ffed;
    border-left-color: #28a745;
}

.diff-line.removed {
    background: #ffebee;
    border-left-color: #dc3545;
}

.line-number {
    display: inline-block;
    width: 50px;
    padding: 0 8px;
    color: #6c757d;
    font-size: 12px;
    text-align: right;
    flex-shrink: 0;
    background: rgba(0,0,0,0.05);
}

.line-content {
    padding: 0 12px;
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 版本控制样式 */
.diff-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    padding: 4px 8px;
    border: 1px solid #e1e5e9;
    border-radius: 4px;
    background: white;
    color: #4a5568;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover:not(:disabled) {
    background: #f7fafc;
    border-color: #cbd5e0;
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#version-info {
    font-size: 12px;
    color: #6c757d;
    padding: 0 8px;
    text-align: center;
    line-height: 1.3;
}

#version-info small {
    font-size: 10px;
    color: #718096;
    font-weight: normal;
    display: block;
}

/* 加载指示器 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e1e5e9;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-container {
        padding: 0 10px;
    }
    
    .nav-controls {
        gap: 10px;
    }
    
    .mode-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .chat-wrapper, .edit-wrapper {
        padding: 10px;
    }
    
    .edit-panels {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .diff-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .nav-btn {
        width: 100%;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .edit-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .instruction-input {
        width: 150px;
    }
}

/* 错误消息样式 */
.message.error {
    background: #fed7d7;
    border-left: 4px solid #e53e3e;
}

.message.error .message-avatar.error {
    background: #e53e3e;
    color: white;
}

.message.error .message-content.error {
    color: #742a2a;
}

.error-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.error-details {
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.error-help {
    font-size: 12px;
    color: #4a5568;
    background: rgba(255, 255, 255, 0.7);
    padding: 8px;
    border-radius: 6px;
}

.error-help ul {
    margin: 4px 0 0 16px;
}

.error-help li {
    margin: 2px 0;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fed7d7;
    border-radius: 8px;
    border: 1px solid #feb2b2;
}

.error-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.error-text {
    flex: 1;
    color: #742a2a;
    line-height: 1.4;
}

.retry-btn {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #c53030;
}

/* 通知样式 */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    max-width: 400px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification.error {
    border-left: 4px solid #e53e3e;
}

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

.notification.success {
    border-left: 4px solid #38a169;
}

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

.notification-content {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
}

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

.notification-text {
    flex: 1;
    font-size: 14px;
    color: #2d3748;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #a0aec0;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.notification-close:hover {
    background: #edf2f7;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
