/* HTMLPreview 莫兰迪色系设计 - 保持所有功能不变 */

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS变量定义 - 莫兰迪色系主题 */
:root {
    /* 莫兰迪主色调 */
    --morandi-pink: #C6A9B3;      /* 柔和粉调 */
    --morandi-blue: #A7B9C2;      /* 优雅蓝调 */
    --morandi-green: #C1CFA1;     /* 清新绿调 */
    
    /* 背景色 - 基于莫兰迪色系的延展 */
    --bg-primary: #fafafa;         /* 极浅暖灰 */
    --bg-secondary: #f5f4f3;       /* 暖白 */
    --bg-tertiary: #ede9e6;        /* 浅暖灰 */
    --bg-hover: rgba(198, 169, 179, 0.08);    /* 粉调悬停 */
    --bg-active: rgba(167, 185, 194, 0.12);   /* 蓝调激活 */
    
    /* 边框色 */
    --border-color: rgba(198, 169, 179, 0.2);
    --border-subtle: rgba(167, 185, 194, 0.15);
    --border-focus: var(--morandi-blue);
    
    /* 文字色 */
    --text-primary: #4a4441;       /* 深暖灰 */
    --text-secondary: #6b615c;     /* 中暖灰 */
    --text-muted: #9b9289;         /* 浅暖灰 */
    --text-inverse: #ffffff;
    --text-accent: #6d5d4f;        /* 强调文字 */
    
    /* 主题色 - 莫兰迪色调 */
    --accent-primary: var(--morandi-pink);
    --accent-secondary: var(--morandi-blue);
    --accent-tertiary: var(--morandi-green);
    --accent-light: rgba(198, 169, 179, 0.1);
    
    /* 状态色 - 柔和版本 */
    --success: #8fa082;            /* 柔和绿 */
    --success-light: rgba(193, 207, 161, 0.2);
    --danger: #c49a9a;             /* 柔和红 */
    --danger-light: rgba(196, 154, 154, 0.15);
    --warning: #d4b896;            /* 柔和橙 */
    --warning-light: rgba(212, 184, 150, 0.15);
    
    /* 阴影 - 柔和版本 */
    --shadow-sm: 0 1px 3px rgba(74, 68, 65, 0.08), 0 1px 2px rgba(74, 68, 65, 0.06);
    --shadow-md: 0 2px 4px rgba(74, 68, 65, 0.08), 0 4px 8px rgba(74, 68, 65, 0.06);
    --shadow-lg: 0 4px 8px rgba(74, 68, 65, 0.08), 0 8px 16px rgba(74, 68, 65, 0.06);
    --shadow-xl: 0 8px 16px rgba(74, 68, 65, 0.08), 0 16px 32px rgba(74, 68, 65, 0.06);
    
    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

body, html {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Arial', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.5;
}

/* 应用容器 */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* 头部工具栏 - 莫兰迪风格设计 */
.toolbar {
    height: 68px;
    background: rgba(245, 244, 243, 0.95);
    backdrop-filter: saturate(150%) blur(24px);
    -webkit-backdrop-filter: saturate(150%) blur(24px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 1000;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar h1 {
    font-size: 20px;
    font-weight: 600;
    margin-right: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-right: 32px;
    border-right: 1px solid var(--border-subtle);
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

/* Logo设计 */
.toolbar h1 img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar h1:hover img {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* 按钮分组样式 */
.btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border-right: 1px solid var(--border-subtle);
    margin-right: 12px;
}

.btn-group:last-child {
    border-right: none;
    margin-right: 0;
}

/* 按钮样式 - 莫兰迪风格设计 */
.btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    min-height: 36px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.btn:active {
    transform: translateY(-1px);
    background: var(--bg-active);
}

.btn i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

/* 主要按钮样式 */
.btn-primary {
    background: linear-gradient(135deg, var(--morandi-pink) 0%, rgba(198, 169, 179, 0.9) 100%);
    color: var(--text-inverse);
    border: none;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}


/* 特殊按钮颜色 - 莫兰迪风格 */




/* 文件管理按钮 */
#fileManagerBtn {
    background: linear-gradient(135deg, var(--morandi-green) 0%, rgba(193, 207, 161, 0.9) 100%);
    color: var(--text-inverse);
    border: none;
    box-shadow: var(--shadow-sm);
}


/* 控制按钮 */
.control-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}


.control-btn.active {
    background: var(--morandi-blue);
    border-color: var(--morandi-blue);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

/* 状态文本 */
.status-text {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

/* 设备选择器 */
.device-select {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}


.device-select:focus {
    outline: none;
    border-color: var(--morandi-blue);
    box-shadow: 0 0 0 3px rgba(167, 185, 194, 0.2);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    display: flex;
    height: calc(100vh - 90px);
    overflow: hidden;
    position: relative;
}

/* 面板通用样式 */
.editor-panel, .preview-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 300px;
    position: relative;
    overflow: hidden;
}

.editor-panel {
    flex: 1;
    border-right: 1px solid var(--border-color);
}

.preview-panel {
    flex: 1;
    background: var(--bg-secondary);
}

/* 面板头部 */
.panel-header {
    height: 48px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.editor-controls, .preview-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 代码编辑器容器 - 莫兰迪风格 */
.editor-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* Monaco Editor 主题调整 - 莫兰迪色系 */
.monaco-editor {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.monaco-editor .margin {
    background-color: var(--bg-secondary) !important;
}

.monaco-editor .current-line {
    background-color: rgba(198, 169, 179, 0.08) !important;
    border: none !important;
}

.monaco-editor .line-numbers {
    color: var(--text-muted) !important;
}

.monaco-editor .cursor {
    color: var(--morandi-pink) !important;
}

/* 选中文本样式 */
.monaco-editor .selected-text {
    background-color: rgba(167, 185, 194, 0.2) !important;
}

/* 滚动条样式 */
.monaco-editor .monaco-scrollable-element .scrollbar {
    background-color: transparent !important;
}

.monaco-editor .monaco-scrollable-element .slider {
    background-color: var(--border-color) !important;
    border-radius: 4px;
}

/* HTML 语法高亮 - 莫兰迪配色 */
.monaco-editor .token.tag {
    color: var(--morandi-pink) !important;
}

.monaco-editor .token.attribute.name {
    color: var(--morandi-blue) !important;
}

.monaco-editor .token.attribute.value,
.monaco-editor .token.string {
    color: var(--morandi-green) !important;
}

.monaco-editor .token.comment {
    color: var(--text-muted) !important;
    font-style: italic;
}

.monaco-editor .token.delimiter {
    color: var(--text-secondary) !important;
}

/* 搜索高亮 */
.monaco-editor .findMatch {
    background-color: rgba(193, 207, 161, 0.3) !important;
    border: 1px solid var(--morandi-green) !important;
}

.monaco-editor .currentFindMatch {
    background-color: rgba(193, 207, 161, 0.5) !important;
    border: 1px solid var(--morandi-green) !important;
}

/* 错误提示 */
.monaco-editor .squiggly-error {
    border-bottom: 2px wavy rgba(196, 154, 154, 0.8) !important;
}

.monaco-editor .squiggly-warning {
    border-bottom: 2px wavy var(--warning) !important;
}

/* 预览容器 */
.preview-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.preview-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
}

/* 设备预览模式 */
.preview-container.device-mobile iframe {
    width: 375px;
    height: 667px;
    margin: 40px auto;
    border: 8px solid #000;
    border-radius: 36px;
    box-shadow: var(--shadow-xl);
}

.preview-container.device-tablet iframe {
    width: 768px;
    height: 1024px;
    margin: 40px auto;
    border: 8px solid #000;
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
}

/* 分割线 */
.resizer {
    width: 1px;
    background: var(--border-color);
    cursor: col-resize;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.resizer:hover {
    background: var(--accent-primary);
    width: 3px;
}

/* 拖动时的样式 */
body.resizing {
    cursor: col-resize !important;
    user-select: none;
}

body.resizing * {
    cursor: col-resize !important;
}

body.resizing iframe {
    pointer-events: none;
}

.resize-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    cursor: col-resize;
    display: none;
}

body.resizing .resize-overlay {
    display: block;
}

/* 底部状态栏 */
.status-bar {
    height: 32px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* 编辑覆盖层 */
.edit-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
}

.edit-tooltip {
    position: absolute;
    background: var(--text-primary);
    color: var(--text-inverse);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -8px;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.edit-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--text-primary);
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(32, 33, 36, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.2s ease;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 500px;
    max-width: 90vw;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.2s ease;
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}


.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* 表单组件 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
    resize: vertical;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-group input[readonly] {
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .btn span {
        display: none;
    }
    
    .btn-group {
        gap: 4px;
        padding: 0 8px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .editor-panel {
        height: 50%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .preview-panel {
        height: 50%;
    }
    
    .resizer {
        width: 100%;
        height: 1px;
        cursor: row-resize;
    }
    
    .toolbar {
        height: auto;
        flex-wrap: wrap;
        padding: 12px 16px;
    }
    
    .toolbar-left {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .toolbar h1 {
        margin-bottom: 12px;
        padding-right: 0;
        border-right: none;
    }
}

/* 预览模式样式 */
.preview-mode .editor-panel {
    display: none;
}

.preview-mode .resizer {
    display: none;
}

.preview-mode .preview-panel {
    flex: 1;
    width: 100%;
}

/* 全屏预览模式 */
.fullscreen-preview {
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

.fullscreen-preview .panel-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.fullscreen-preview .preview-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    padding: 40px;
}

.fullscreen-preview .preview-container iframe {
    max-width: 100%;
    max-height: 100%;
    box-shadow: var(--shadow-xl);
    border-radius: var(--radius-lg);
}

/* 元素高亮效果 */
.element-highlight {
    outline: 2px solid var(--accent-primary) !important;
    outline-offset: 2px;
    background: rgba(25, 118, 210, 0.1) !important;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.element-highlight:hover {
    outline-color: var(--accent-secondary) !important;
    background: rgba(25, 118, 210, 0.15) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* 代码行号高亮 */
.line-highlight {
    background: rgba(25, 118, 210, 0.1) !important;
}

/* 动画定义 */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* 通知弹窗样式 */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.notification {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 10px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(420px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: all;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification.hide {
    transform: translateX(420px);
    opacity: 0;
}

.notification-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification.success .notification-icon {
    color: var(--success);
}

.notification.error .notification-icon {
    color: var(--danger);
}

.notification.warning .notification-icon {
    color: var(--warning);
}

.notification.info .notification-icon {
    color: var(--accent-primary);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.notification-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notification-close {
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    flex-shrink: 0;
}

.notification-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}