/* 响应式样式 */

/* 小屏幕手机 (< 640px) */
@media (max-width: 639px) {
    :root {
        --toolbar-height: 50px;
        --console-height: 150px;
    }
    
    /* 工具栏 */
    .toolbar {
        padding: 0 var(--spacing-sm);
    }
    
    .logo-text {
        display: none;
    }
    
    .btn .text {
        display: none;
    }
    
    .toolbar-center {
        flex: 1;
        justify-content: center;
    }
    
    /* 主容器垂直布局 */
    .main-container {
        flex-direction: column;
        height: calc(100vh - var(--toolbar-height) - var(--console-height));
    }
    
    .editor-section {
        height: 50%;
        min-height: 200px;
    }
    
    .resizer {
        width: 100%;
        height: 4px;
        cursor: row-resize;
    }
    
    .preview-section {
        height: 50%;
        min-height: 200px;
    }
    
    /* 控制台 */
    .console-panel {
        height: var(--console-height);
    }
    
    .console-header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    /* 通知 */
    .notification-container {
        left: var(--spacing-sm);
        right: var(--spacing-sm);
        top: auto;
        bottom: var(--spacing-sm);
    }
    
    .notification {
        min-width: auto;
    }
}

/* 平板 (640px - 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
    .toolbar {
        padding: 0 var(--spacing-md);
    }
    
    .btn .text {
        display: none;
    }
    
    .main-container {
        flex-direction: column;
    }
    
    .editor-section {
        height: 50%;
    }
    
    .resizer {
        width: 100%;
        height: 4px;
        cursor: row-resize;
    }
    
    .preview-section {
        height: 50%;
    }
}

/* 笔记本和小桌面 (1024px - 1439px) */
@media (min-width: 1024px) and (max-width: 1439px) {
    .toolbar-center .btn .text {
        display: inline;
    }
    
    .toolbar-right .btn .text {
        display: none;
    }
}

/* 大桌面 (>= 1440px) */
@media (min-width: 1440px) {
    :root {
        --font-size-base: 15px;
    }
    
    .main-container {
        max-width: 1920px;
        margin: 0 auto;
    }
}

/* 超宽屏 (>= 1920px) */
@media (min-width: 1920px) {
    :root {
        --font-size-base: 16px;
        --toolbar-height: 70px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: var(--spacing-sm) var(--spacing-lg);
    }
    
    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }
    
    .tab-btn {
        min-height: 44px;
    }
    
    .resizer {
        width: 8px;
    }
    
    @media (max-width: 639px) {
        .resizer {
            height: 8px;
        }
    }
}

/* 横屏模式 */
@media (max-width: 1023px) and (orientation: landscape) {
    .main-container {
        flex-direction: row;
        height: calc(100vh - var(--toolbar-height) - 100px);
    }
    
    .editor-section {
        width: 50%;
        height: 100%;
    }
    
    .resizer {
        width: 4px;
        height: 100%;
        cursor: col-resize;
    }
    
    .preview-section {
        width: 50%;
        height: 100%;
    }
    
    .console-panel {
        height: 100px;
    }
}

/* 打印样式 */
@media print {
    .toolbar,
    .console-panel,
    .editor-section {
        display: none;
    }
    
    .main-container {
        height: auto;
    }
    
    .preview-section {
        width: 100%;
        height: auto;
    }
    
    .preview-header {
        display: none;
    }
}

/* 减少动画（用户偏好） */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --shadow-sm: 0 0 0 1px #000000;
        --shadow-md: 0 0 0 2px #000000;
        --shadow-lg: 0 0 0 3px #000000;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* 暗色模式偏好 */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        --bg-primary: #1e1e1e;
        --bg-secondary: #252526;
        --bg-tertiary: #2d2d30;
        --bg-dark: #1e1e1e;
        
        --text-primary: #d4d4d4;
        --text-secondary: #969696;
        --text-muted: #6e6e6e;
        
        --border-color: #3e3e42;
    }
}

/* 小高度屏幕 */
@media (max-height: 600px) {
    :root {
        --toolbar-height: 50px;
        --console-height: 120px;
    }
    
    .console-panel {
        height: var(--console-height);
    }
}

/* 超小高度（像是折叠屏） */
@media (max-height: 400px) {
    .console-panel {
        display: none;
    }
    
    .main-container {
        height: calc(100vh - var(--toolbar-height));
    }
}

/* iPad Pro 特定尺寸 */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: portrait) {
    .main-container {
        flex-direction: column;
    }
    
    .editor-section,
    .preview-section {
        height: 50%;
    }
    
    .resizer {
        width: 100%;
        height: 4px;
        cursor: row-resize;
    }
}

/* 可折叠设备 */
@media (horizontal-viewport-segments: 2) {
    .main-container {
        flex-direction: row;
    }
    
    .editor-section {
        width: env(viewport-segment-width 0 0);
    }
    
    .preview-section {
        width: env(viewport-segment-width 1 0);
    }
    
    .resizer {
        display: none;
    }
}