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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    height: 100vh;
    min-width: 275px;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 工具栏样式 */
.toolbar {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

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

.title h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.btn-return {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    min-width: 50px;
    box-sizing: border-box;
    gap: 2px;
    padding: 0 10px;
    background: #f0f0f0;
    border-radius: 6px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}
.btn-moble {
    display: none;
}

.btn-return:hover {
    background: #e0e0e0;
    color: #333;
}

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

.layout-controls {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: #007acc;
    background: #f0f8ff;
}

.btn-icon.active {
    border-color: #007acc;
    background: #007acc;
    color: #fff;
}

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

/* 工具栏AI列表样式 */
.ai-list-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    margin: 0 10px;
    overflow-x: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

/* WebKit browsers (Chrome, Safari) */
.ai-list-toolbar::-webkit-scrollbar {
    display: none;
    height: 0;
    width: 0;
}

.ai-toolbar-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    box-sizing: border-box;
    padding: 0 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.2s;
}

.ai-toolbar-item:hover {
    border-color: #007acc;
    background: #f0f8ff;
}

.ai-toolbar-item.active {
    border-color: #007acc;
    background: #007acc;
    color: #fff;
}

/* 弹出菜单样式 */
.ai-popup-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 96%;
    max-width: 1000px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 15px;
}

.ai-popup-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.ai-popup-menu h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    text-align: center;
    font-weight: 600;
    position: relative;
}

/* 关闭按钮样式 */
.popup-close-btn {
    position: absolute;
    z-index: 1000;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.popup-close-btn:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

.popup-close-btn svg {
    width: 16px;
    height: 16px;
    fill: #666;
}

/* 自定义工具管理弹窗样式 */
.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.custom-modal.show {
    display: flex;
}

.custom-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.custom-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.custom-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.custom-close-btn svg {
    width: 16px;
    height: 16px;
    fill: #666;
}

.custom-modal-body {
    padding: 15px;
    max-height: calc(80vh - 120px);
    overflow-y: auto;
}

/* 自定义工具列表样式 */

.custom-tool-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 15px;
    background: #fafafa;
}

.custom-tool-info {
    flex: 1;
}

.custom-tool-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.custom-tool-url {
    font-size: 12px;
    color: #666;
    word-break: break-all;
}

.custom-tool-actions {
    display: flex;
    gap: 8px;
}

.btn-edit,
.btn-delete {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit:hover {
    border-color: #007acc;
    color: #007acc;
}

.btn-delete:hover {
    border-color: #dc3545;
    color: #dc3545;
}

.no-custom-tools {
    text-align: center;
    color: #999;
    background: #f1f2f3;
    margin-bottom: 15px;
    padding: 20px;
    border-radius: 6px;
    font-style: italic;
}

/* 表单样式 */

.custom-form h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #333;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007acc;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 15px;
}

.btn-secondary {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    color: #333;
    cursor: pointer;
}

.btn-primary {
    padding: 8px 16px;
    border: 1px solid #007acc;
    background: #007acc;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
}

.ai-popup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.ai-popup-item {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-size: 14px;
}

.ai-popup-item:hover {
    border-color: #007acc;
    background: #f0f8ff;
}

.ai-popup-item.active {
    border-color: #007acc;
    background: #007acc;
    color: #fff;
}

/* 主内容区域 */
.main-content {
    flex: 1;
    height: calc(100vh - 53px);
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-header {
    padding: 0 16px 16px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 16px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.search-box {
    margin-top: 12px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #007acc;
}

.ai-list {
    padding: 0 8px;
}

.ai-item {
    display: flex;
    align-items: center;
    padding: 12px 8px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.ai-item:hover {
    background: #f8f9fa;
}

.ai-item.active {
    background: #e3f2fd;
    border-color: #007acc;
}

.ai-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    margin-right: 12px;
    object-fit: cover;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #666;
}

.ai-info {
    flex: 1;
}

.ai-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 2px;
}

/* 窗口容器样式 */
.windows-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 8px;
    gap: 8px;
}

/* 窗口基础样式 */
.window {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.window.active {
    display: flex;
}

.window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.window-header span {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

/* 窗口操作按钮样式 */
.window-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-original {
    width: 28px;
    height: 24px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-original:hover {
    border-color: #007acc;
    background: #f0f8ff;
}

.btn-original svg {
    fill: #666;
}

.btn-original:hover svg {
    fill: #007acc;
}

/* 下拉选择框样式 */
.window-dropdown {
    position: relative;
}

.dropdown-btn {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-btn:hover {
    border-color: #007acc;
    background: #f0f8ff;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f0f8ff;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.window-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.window-iframe {
    width: 100%;
    flex: 1;
    border: none;
    position: relative;
}

.window-iframe.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    border: 4px solid rgba(0, 122, 204, 0.2);
    border-top: 4px solid #007acc;
    border-right: 4px solid #007acc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10;
    box-shadow: 0 0 20px rgba(0, 122, 204, 0.3);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
        border-top-color: #007acc;
        border-right-color: #007acc;
    }

    50% {
        border-top-color: #ff6b6b;
        border-right-color: #ff6b6b;
    }

    100% {
        transform: rotate(360deg);
        border-top-color: #007acc;
        border-right-color: #007acc;
    }
}

.window-iframe.loading::after {
    content: '加载中，请稍候...';
    position: absolute;
    top: calc(50% + 45px);
    left: 50%;
    transform: translateX(-50%);
    color: #007acc;
    font-size: 16px;
    font-weight: 600;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.window-iframe.loading {
    background: rgba(248, 249, 250, 0.8);
}

/* 布局模式样式 */
.layout-single {
    padding: 0 !important;
}

.layout-single .window-1 {
    display: flex;
    height: calc(100vh - 53px);
    border: none !important;
    border-radius: 0 !important;
}

.layout-single .window-1 .window-header {
    display: none !important;
}

.layout-single .window-1 .window-body {
    height: 100% !important;
}

.layout-double {
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: calc(100vh - 53px);
}

.layout-double .window-1,
.layout-double .window-2 {
    display: flex;
    flex: 1;
    height: 100%;
}

.layout-triple {
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: calc(100vh - 53px);
}

.layout-triple .window-1,
.layout-triple .window-2,
.layout-triple .window-3 {
    display: flex;
    flex: 1;
    height: 100%;
}

.layout-quad {
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: calc(100vh - 53px);
}

.layout-quad .window-1,
.layout-quad .window-2,
.layout-quad .window-3,
.layout-quad .window-4 {
    display: flex;
    flex: 1;
    height: 100%;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    height: calc(100vh - 53px);
}

.layout-grid .window {
    display: flex;
    height: 100%;
    margin: 0;
}

/* 焦点模式样式 */
.window.focused {
    position: fixed;
    top: 60px;
    left: 280px;
    right: 0;
    bottom: 0;
    z-index: 1000;
    height: auto !important;
}

.window.focused::after {
    content: '点击任意位置恢复布局';
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1001;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .layout-controls {
        display: none;
    }

    .ai-list-toolbar {
        margin: 0 12px;
        gap: 6px;
    }

    .ai-toolbar-item {
        height: 26px;
        padding: 0 8px;
        font-size: 12px;
    }

    .title h1 {
        font-size: 16px;
    }

    .btn-return {
        height: 26px;
        min-width: 44px;
        font-size: 12px;
        padding: 0 10px;
    }
    .btn-moble{
        display: flex;
    }

    .layout-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .toolbar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
     .btn-return {
        min-width: 36px;
        padding: 0 6px;
    }

    .title {
        flex: 1;
        min-width: 100px;
    }

    .ai-list-toolbar {
        order: 3;
        flex: 1 0 100%;
        margin: 8px 0 0 0;
        overflow-x: auto;
    }

    .ai-toolbar-item {
        height: 24px;
        padding: 0 6px;
        font-size: 11px;
    }

    .title h1 {
        font-size: 14px;
    }
}