/* 基础样式和重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans CN', sans-serif;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

:root {
    --primary-color: #4CAF50;
    --primary-light: #81C784;
    --primary-dark: #388E3C;
    --accent-color: #2196F3;
    --text-primary: #333333;
    --text-secondary: #666666;
    --bg-light: #f5f5f5;
    --bg-dark: #333333;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-bg-dark: rgba(40, 40, 40, 0.75);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-border-dark: rgba(255, 255, 255, 0.1);
    --shadow-light: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-dark: 0 8px 32px rgba(0, 0, 0, 0.3);
    --border-radius: 12px;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    background: linear-gradient(135deg, #e0f2f1, #e8f5e9);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-overflow-scrolling: touch; /* 增加 iOS 滚动惯性 */
}

/* 玻璃拟态效果 */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
}

/* 应用容器 */
.app-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-overflow-scrolling: touch;
}

/* 头部样式 */
.app-header {
    height: 60px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--glass-bg);
    box-shadow: var(--shadow-light);
    box-sizing: border-box;
    flex-shrink: 0; /* 防止头部被压缩 */
}

.logo-container {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.logo-image {
    height: 40px;
    max-width: 200px;
    object-fit: contain;
}

.app-header h1 {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-dark);
}

/* 主内容区域 */
.app-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 10px;
    overflow: hidden;
    height: calc(100% - 60px);
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

/* 移动优化 */
@media (max-width: 768px) {
    .app-content {
        flex-direction: column;
        height: calc(100% - 60px);
        padding: 5px;
    }

    .logo-title {
        justify-content: center;
    }
}

/* 标题和图标样式 */
.logo-title {
    display: flex;
    align-items: center;
}

.logo {
    width: 40px;
    height: 40px;
    margin-right: 10px;
}

/* 面板通用样式 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h2 {
    font-size: 18px;
    color: var(--primary-dark);
}

.panel-controls {
    display: flex;
    gap: 10px;
}

/* 编辑器区域 */
.editor-container {
    display: flex;
    flex-direction: column;
    height: 50vh;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    max-height: 50vh;
    box-sizing: border-box;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

#htmlEditor {
    flex: 1;
    padding: 15px;
    border: none;
    background: transparent;
    resize: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    overflow-x: hidden;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

/* 预览区域 */
.preview-container {
    display: flex;
    flex-direction: column;
    height: 50vh;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    max-height: 50vh;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.preview-content {
    background-color: #fff;
    color: var(--text-primary);
    padding: 15px;
    margin: 15px;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    overflow-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.preview-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
}

/* 按钮样式 */
button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    color: var(--primary-dark);
    border-radius: 50%;
}

.icon-btn:hover {
    background-color: rgba(76, 175, 80, 0.1);
}

.primary-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.primary-btn .material-symbols-rounded {
    font-size: 18px;
}

/* 通知样式 */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

/* 页脚样式 */
.app-footer {
    height: 40px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    box-shadow: var(--shadow-light);
    box-sizing: border-box;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        text-align: center;
        padding: 10px;
        margin-bottom: 10px;
    }
    
    .logo-container {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .app-header h1 {
        font-size: 18px;
    }
    
    .panel-header {
        padding: 8px 10px;
    }
    
    .panel-header h2 {
        font-size: 16px;
    }
    
    .editor-container,
    .preview-container {
        height: calc(50% - 5px);
        max-height: calc(50% - 5px);
    }
    
    .app-container {
        padding: 5px;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .app-content {
        flex: 1;
        overflow: hidden;
        margin-bottom: 5px;
    }
    
    .app-footer {
        padding: 5px;
    }
    
    body.keyboard-open .editor-container {
        flex: 2;
    }
    
    body.keyboard-open .preview-container {
        flex: 1;
    }
    
    .preview-content {
        margin: 5px;
        padding: 10px;
    }

    .panel-controls {
        flex-wrap: wrap;
        gap: 5px;
    }

    .primary-btn {
        padding: 6px 12px;
        font-size: 14px;
    }

    .logo-title h1 {
        font-size: 18px;
    }
}

/* 图片预览容器样式 */
.image-preview-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.image-preview-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 10px auto;
    -webkit-tap-highlight-color: transparent;
}
