/* 
 * 会话模式样式 - 支持新的交互模式
 */

/* 会话页签区域 */
.session-tab-bar {
    height: 48px;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
}

.session-tabs {
    display: flex;
    align-items: center;
    height: 100%;
    min-width: 100%;
    gap: 4px;
    padding: 0 16px;
}

/* 会话页签 */
.session-tab {
    display: flex;
    align-items: center;
    height: 36px;
    min-width: 120px;
    max-width: 250px;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: 6px 6px 0 0;
    overflow: hidden;
    cursor: pointer;
    transition: all 200ms ease-in-out;
    user-select: none;
}

.session-tab:hover {
    background: hsl(var(--accent));
}

.session-tab.active {
    background: hsl(var(--background));
    border: 2px solid hsl(var(--primary)); /* 更明显的边框 */
    border-bottom: 2px solid hsl(var(--background));
    margin-bottom: -2px; /* 调整以适配更粗的边框 */
    z-index: 1;
    box-shadow: 0 -4px 12px hsl(var(--primary) / 0.15); /* 顶部阴影 */
    transform: translateY(-1px); /* 微妙上移效果 */
}

.session-tab.active .session-tab-title {
    color: hsl(var(--primary)); /* 活跃标签的文字颜色 */
    font-weight: 600; /* 加粗字体 */
}

.session-tab-content {
    flex: 1;
    padding: 0 12px;
    display: flex;
    align-items: center;
    min-width: 0;
}

.session-tab-title {
    font-size: 13px;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-tab-close {
    width: 20px;
    height: 20px;
    margin-right: 6px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    color: hsl(var(--muted-foreground));
    transition: all 200ms ease-in-out;
    flex-shrink: 0;
}

.session-tab-close:hover {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

/* 主会话内容区域 */
.session-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px); /* 减去会话页签栏高度 */
    background: hsl(var(--background));
}

.current-session {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* 确保flexbox子元素可以收缩 */
}

.session-terminal-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.session-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
}

.session-info {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: hsl(var(--foreground));
}

.current-project {
    font-weight: 600;
    font-size: 14px;
}

.current-session-name {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.current-session-name:before {
    content: " - ";
}

.session-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: hsl(var(--muted-foreground));
    transition: all 200ms ease-in-out;
}

.action-btn:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.action-btn.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

/* Session header button container */
.session-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.session-terminal-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.session-terminal-instance {
    width: 100%;
    height: 100%;
    display: none;
}

.session-terminal-instance.active {
    display: block;
}

.empty-terminal-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: hsl(var(--muted-foreground));
    font-size: 14px;
}

/* 文件抽屉 */
.files-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 420px;
    height: 100vh;
    background: hsl(var(--background));
    border-left: 1px solid hsl(var(--border));
    transform: translateX(100%);
    transition: transform 300ms ease-in-out;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 8px rgba(0, 0, 0, 0.1);
}

.files-drawer.open {
    transform: translateX(0);
}

.files-drawer-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
}

.files-drawer-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.project-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.project-name {
    font-size: 14px;
    font-weight: 600;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.project-path {
    font-size: 11px;
    font-weight: 400;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.files-drawer-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: hsl(var(--muted-foreground));
    transition: all 200ms ease-in-out;
}

.files-drawer-close:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.files-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* 文件树样式 */
.files-tree {
    padding: 8px 0;
}

.file-item {
    display: flex;
    align-items: center;
    min-height: 28px;
    cursor: pointer;
    transition: background-color 200ms ease-in-out;
}

.file-item:hover {
    background: hsl(var(--accent));
}

.file-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    min-width: 0;
}

.file-icon {
    flex-shrink: 0;
    color: hsl(var(--muted-foreground));
}

.file-name {
    flex: 1;
    font-size: 13px;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: hsl(var(--muted-foreground));
    margin-left: auto;
}

.is-directory .file-name {
    font-weight: 500;
}

/* 空状态和错误状态 */
.empty-files, .error-files, .message-files, .loading-files {
    padding: 32px 16px;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.loading-files .spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
    margin: 0 auto 12px;
}

/* 项目连接对话框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms ease-in-out;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    transform: scale(0.95);
    transition: transform 200ms ease-in-out;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.modal-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: hsl(var(--muted-foreground));
    transition: all 200ms ease-in-out;
}

.modal-close:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.modal-body {
    padding: 20px;
}

.project-info {
    margin-bottom: 16px;
}

.project-name {
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 4px;
}

.project-path {
    font-size: 13px;
    color: hsl(var(--muted-foreground));
    font-family: 'Courier New', monospace;
}

.session-config {
    margin-top: 16px;
}

.session-config label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 6px;
}

.session-name-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 14px;
    transition: border-color 200ms ease-in-out;
}

.session-name-input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: hsl(var(--muted));
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 200ms ease-in-out;
    text-decoration: none;
    user-select: none;
}

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

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-color: hsl(var(--border));
}

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

.btn-sm {
    height: 28px;
    padding: 0 12px;
    font-size: 12px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .session-main-content {
        height: calc(100vh - var(--mobile-header-height) - 48px);
    }
    
    .files-drawer {
        width: 90%;
        max-width: 350px;
    }
    
    .modal-content {
        width: 95%;
        margin: 0 16px;
    }
    
    .session-tab {
        min-width: 100px;
        max-width: 180px;
    }
    
    .session-tab-title {
        font-size: 12px;
    }
}

/* 大文件提示对话框样式 */
.large-file-dialog-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.large-file-dialog-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.large-file-dialog-container {
    position: relative;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 8px;
    padding: 0;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    animation: dialogFadeIn 200ms ease-out;
}

.large-file-dialog-header {
    padding: 16px 20px;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: hsl(var(--muted));
    border-radius: 8px 8px 0 0;
}

.large-file-dialog-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.large-file-dialog-close {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: hsl(var(--muted-foreground));
    transition: all 200ms ease;
}

.large-file-dialog-close:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.large-file-dialog-content {
    padding: 20px;
}

.large-file-dialog-content p {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: hsl(var(--foreground));
}

.large-file-dialog-content p:last-of-type {
    margin-bottom: 0;
}

.warning-message {
    margin-top: 16px;
    padding: 12px;
    background: hsl(var(--destructive) / 0.1);
    border: 1px solid hsl(var(--destructive) / 0.2);
    border-radius: 6px;
    color: hsl(var(--destructive));
    font-size: 13px;
}

.large-file-dialog-actions {
    padding: 16px 20px;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: hsl(var(--muted) / 0.3);
    border-radius: 0 0 8px 8px;
}

.btn-warning {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    border-color: hsl(var(--destructive));
}

.btn-warning:hover:not(:disabled) {
    background: hsl(var(--destructive) / 0.9);
}

/* 文件加载覆盖层样式 */
.file-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: hsl(var(--background) / 0.8);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.file-loading-content {
    text-align: center;
    color: hsl(var(--foreground));
}

.file-loading-content .spinner {
    width: 24px;
    height: 24px;
    margin: 0 auto 12px;
    border: 2px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.file-loading-content p {
    margin: 0;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

/* 成功消息提示样式 */
.success-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 3000;
    animation: toastSlideIn 300ms ease-out;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.toast-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* 动画定义 */
@keyframes dialogFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 移动端大文件对话框适配 */
@media (max-width: 768px) {
    .large-file-dialog-container {
        min-width: 320px;
        max-width: 90%;
        margin: 0 16px;
    }
    
    .large-file-dialog-actions {
        flex-direction: column;
    }
    
    .success-toast {
        top: auto;
        bottom: 20px;
        right: 16px;
        left: 16px;
        max-width: none;
    }
}