/* Windows 11 风格 - 移动端响应式样式 */

/* ============================================
   平板设备 (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .win11-window {
        min-width: 320px;
        min-height: 250px;
    }
    
    .pinned-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ============================================
   手机横屏和小平板 (481px - 768px)
   ============================================ */
@media (max-width: 768px) {
    /* 任务栏 - 开始按钮在最左侧 */
    .win11-taskbar {
        justify-content: flex-start !important;
        padding-left: 8px !important;
    }
    
    .taskbar-left {
        display: none !important;
    }
    
    .taskbar-center {
        position: static !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .taskbar-right {
        position: absolute !important;
        right: 0 !important;
    }
    
    /* 桌面图标区域 */
    .desktop-icons {
        top: 10px;
        left: 10px;
        gap: 6px;
    }
    
    .desktop-icon {
        width: 74px;
        height: 84px;
        padding: 8px 4px;
    }
    
    .desktop-icon .icon-image {
        width: 44px;
        height: 44px;
        min-height: 44px;
        flex-shrink: 0;
        margin-bottom: 4px;
        border-radius: 10px;
    }
    
    .desktop-icon .icon-image i {
        font-size: 22px;
    }
    
    .desktop-icon .icon-label {
        font-size: 11px;
        height: 26px;
        line-height: 1.2;
    }
    
    /* 开始菜单 */
    .start-menu {
        width: calc(100% - 16px);
        max-width: 100%;
        height: calc(100vh - 70px);
        max-height: calc(100vh - 70px);
        bottom: 56px;
        left: 8px;
        right: 8px;
        transform: scale(0.95);
    }
    
    .start-menu.show {
        transform: scale(1);
    }
    
    .start-search {
        padding: 24px 20px 16px;
    }
    
    .pinned-apps {
        padding: 0 20px;
    }
    
    .pinned-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }
    
    .pinned-item {
        padding: 10px 6px;
    }
    
    .pinned-item .item-icon {
        width: 32px;
        height: 32px;
        margin-bottom: 6px;
    }
    
    .pinned-item .item-icon i {
        font-size: 24px;
    }
    
    .pinned-item .item-name {
        font-size: 11px;
    }
    
    .start-footer {
        padding: 12px 20px;
    }
    
    /* 搜索面板 */
    .search-panel {
        width: calc(100% - 16px);
        max-width: 100%;
        height: calc(100vh - 70px);
        left: 8px;
        right: 8px;
        transform: scale(0.95);
    }
    
    .search-panel.show {
        transform: scale(1);
    }
    
    .search-panel-content {
        padding: 16px;
    }
    
    /* 窗口 */
    .win11-window {
        min-width: 100%;
        min-height: 200px;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: calc(100% - 48px) !important;
    }
    
    .window-titlebar {
        height: 40px;
        padding: 0 4px;
    }
    
    .window-control-btn {
        width: 50px;
        height: 40px;
    }
    
    /* 隐藏调整大小手柄 */
    .resize-handle {
        display: none;
    }
}

/* ============================================
   手机设备竖屏 (小于等于 480px)
   ============================================ */
@media (max-width: 480px) {
    /* 桌面背景调整 */
    .win11-desktop {
        bottom: 56px;
    }
    
    /* 桌面图标 */
    .desktop-icons {
        top: 8px;
        left: 8px;
        gap: 4px;
        max-height: calc(100% - 16px);
    }
    
    .desktop-icon {
        width: 68px;
        height: 76px;
        padding: 6px 4px;
    }
    
    .desktop-icon .icon-image {
        width: 40px;
        height: 40px;
        min-height: 40px;
        flex-shrink: 0;
        margin-bottom: 4px;
        border-radius: 10px;
    }
    
    .desktop-icon .icon-image i {
        font-size: 20px;
    }
    
    .desktop-icon .icon-label {
        font-size: 10px;
        height: 24px;
        line-height: 1.2;
        -webkit-line-clamp: 2;
    }
    
    /* 任务栏 - 增加高度方便触摸，开始按钮在最左侧 */
    .win11-taskbar {
        height: 56px !important;
        justify-content: flex-start !important;
        padding-left: 8px !important;
    }
    
    .taskbar-left {
        display: none !important;
    }
    
    .taskbar-center {
        position: static !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .taskbar-right {
        position: absolute !important;
        right: 0 !important;
    }
    
    /* 任务栏按钮增大触摸区域 */
    .start-btn,
    .search-btn,
    .task-view-btn,
    .widgets-btn {
        width: 48px;
        height: 48px;
        margin-right: 0;
    }
    
    .start-btn i {
        font-size: 22px;
    }
    
    .search-btn i,
    .task-view-btn i,
    .widgets-btn i {
        font-size: 20px;
    }
    
    .taskbar-item {
        width: 48px;
        height: 48px;
        margin: 0;
    }
    
    .taskbar-item i {
        font-size: 22px;
    }
    
    /* 隐藏小组件按钮以节省空间 */
    .widgets-btn {
        display: none;
    }
    
    /* 系统托盘精简 */
    .system-tray {
        padding: 0 4px;
        margin-right: 2px;
    }
    
    .tray-icons {
        gap: 2px;
    }
    
    .tray-icons i {
        font-size: 12px;
        padding: 2px;
    }
    
    /* 隐藏部分托盘图标 */
    .tray-icons i:not(:last-child) {
        display: none;
    }
    
    /* 时钟区域 */
    .clock-area {
        padding: 2px 8px;
        min-width: auto;
        height: 48px;
    }
    
    .clock-time {
        font-size: 11px;
    }
    
    .clock-date {
        font-size: 10px;
    }
    
    /* 通知按钮 */
    .notification-btn {
        width: 32px;
        height: 48px;
        margin-right: 4px;
    }
    
    .notification-btn i {
        font-size: 12px;
    }
    
    /* 显示桌面按钮 */
    .show-desktop-btn {
        width: 8px;
    }
    
    /* 开始菜单 - 紧凑模式 */
    .start-menu {
        width: 100%;
        height: auto;
        max-height: 70vh;
        bottom: 56px;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        transform: translateX(0) translateY(100%);
        overflow-y: auto;
    }
    
    .start-menu.show {
        transform: translateX(0) translateY(0);
    }
    
    .pinned-apps {
        flex: 0 0 auto;
        overflow-y: visible;
    }
    
    /* 隐藏搜索框 */
    .start-search {
        display: none !important;
    }
    
    /* 隐藏"所有应用"文字 */
    .pinned-header .all-apps-btn {
        display: none !important;
    }
    
    /* 隐藏"已固定"文字 */
    .pinned-header h3 {
        display: none !important;
    }
    
    .start-search-input {
        height: 42px;
        font-size: 16px; /* 防止iOS缩放 */
        border-radius: 21px;
    }
    
    .pinned-apps {
        padding: 0 16px;
    }
    
    .pinned-header {
        margin-bottom: 12px;
    }
    
    .pinned-header h3 {
        font-size: 13px;
    }
    
    .pinned-header .all-apps-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .pinned-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    
    .pinned-item {
        padding: 12px 4px;
    }
    
    .pinned-item .item-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 6px;
    }
    
    .pinned-item .item-icon i {
        font-size: 28px;
    }
    
    .pinned-item .item-name {
        font-size: 10px;
    }
    
    .start-footer {
        padding: 12px 16px;
    }
    
    .user-info {
        padding: 6px 10px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        margin-right: 8px;
    }
    
    .user-avatar i {
        font-size: 14px;
    }
    
    .user-name {
        font-size: 12px;
    }
    
    .power-btn {
        width: 40px;
        height: 40px;
    }
    
    /* 搜索面板 - 全屏 */
    .search-panel {
        width: 100%;
        height: calc(100vh - 64px);
        max-height: calc(100vh - 64px);
        bottom: 56px;
        left: 0;
        right: 0;
        border-radius: 16px 16px 0 0;
        transform: translateX(0) translateY(100%);
    }
    
    .search-panel.show {
        transform: translateX(0) translateY(0);
    }
    
    .search-panel-content {
        padding: 16px;
    }
    
    .search-panel-input {
        height: 44px;
        font-size: 16px; /* 防止iOS缩放 */
        border-radius: 22px;
        padding-left: 44px;
    }
    
    .search-panel-wrapper i {
        left: 16px;
        top: 15px;
    }
    
    .search-category h4 {
        font-size: 11px;
    }
    
    .search-result-item {
        padding: 12px 10px;
    }
    
    .search-result-item .result-icon {
        width: 36px;
        height: 36px;
    }
    
    .search-result-item .result-name {
        font-size: 14px;
    }
    
    /* 右键菜单 - 在手机上作为底部弹出 */
    .context-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: 16px 16px 0 0;
        min-width: 100%;
        max-height: 60vh;
        overflow-y: auto;
        transform: translateY(100%);
        padding: 8px 8px 20px;
    }
    
    .context-menu.show {
        transform: translateY(0);
    }
    
    .context-menu-item {
        padding: 14px 16px;
    }
    
    .context-menu-item i {
        font-size: 18px;
        margin-right: 14px;
    }
    
    .context-menu-item span {
        font-size: 15px;
    }
    
    /* 窗口 - 全屏模式 */
    .windows-container {
        bottom: 56px;
    }
    
    .win11-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-width: 100%;
        min-height: 100%;
        border-radius: 0;
        box-shadow: none;
    }
    
    .win11-window.maximized {
        height: 100% !important;
    }
    
    .window-titlebar {
        height: 44px;
        padding: 0 8px;
        background: rgba(255, 255, 255, 0.98);
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .window-icon {
        width: 20px;
        height: 20px;
    }
    
    .window-icon i {
        font-size: 16px;
    }
    
    .window-title {
        font-size: 14px;
        font-weight: 500;
    }
    
    .window-control-btn {
        width: 44px;
        height: 44px;
    }
    
    .window-control-btn i {
        font-size: 12px;
    }
    
    /* 隐藏最小化和最大化按钮，只保留关闭 */
    .window-control-btn.minimize,
    .window-control-btn.maximize {
        display: none;
    }
    
    .window-content {
        height: calc(100% - 44px);
    }
    
    /* 加载遮罩 */
    .loading-spinner {
        width: 40px;
        height: 40px;
    }
    
    .loading-text {
        font-size: 13px;
        margin-top: 16px;
    }
    
    /* 移动端小组件面板 - 全屏弹出样式 */
    .side-widget-panel {
        display: block !important;
        position: fixed !important;
        width: 100% !important;
        height: calc(100% - 56px) !important;
        max-height: calc(100% - 56px) !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 56px !important;
        top: 0 !important;
        border-radius: 0 !important;
        transform: translateY(100%) !important;
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease !important;
        z-index: 10000;
        background: rgba(32, 32, 32, 0.95);
        backdrop-filter: blur(20px);
    }
    
    .side-widget-panel.show {
        transform: translateY(0) !important;
        opacity: 1;
        pointer-events: auto;
    }
    
    /* 调整手机框 */
    .side-widget-panel .phone-frame {
        border-radius: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }
    
    .side-widget-panel .phone-frame::before,
    .side-widget-panel .phone-frame::after {
        display: none;
    }
    
    .side-widget-panel .phone-screen {
        border-radius: 0;
    }
    
    .side-widget-panel .side-widget-content {
        border-radius: 0;
    }
    
    /* 隐藏关闭和拖动按钮 */
    .side-widget-panel .phone-close-btn {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.5);
    }
    
    .side-widget-panel .phone-drag-handle {
        display: none;
    }
    
    /* 底部指示条 */
    .side-widget-panel .phone-indicator {
        display: none;
    }
}

/* ============================================
   超小屏手机 (小于 360px)
   ============================================ */
@media (max-width: 360px) {
    .desktop-icons {
        gap: 2px;
    }
    
    .desktop-icon {
        width: 58px;
        height: 68px;
        padding: 5px 3px;
    }
    
    .desktop-icon .icon-image {
        width: 34px;
        height: 34px;
        min-height: 34px;
        border-radius: 8px;
        margin-bottom: 3px;
    }
    
    .desktop-icon .icon-image i {
        font-size: 18px;
    }
    
    .desktop-icon .icon-label {
        font-size: 9px;
        height: 22px;
    }
    
    .pinned-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .start-btn,
    .search-btn,
    .task-view-btn {
        width: 44px;
    }
    
    /* 隐藏任务视图 */
    .task-view-btn {
        display: none;
    }
}

/* ============================================
   横屏模式优化
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .win11-taskbar {
        height: 40px;
    }
    
    .win11-desktop {
        bottom: 40px;
    }
    
    .windows-container {
        bottom: 40px;
    }
    
    .start-btn,
    .search-btn,
    .task-view-btn,
    .widgets-btn,
    .taskbar-item {
        width: 40px;
        height: 36px;
    }
    
    .clock-area {
        height: 36px;
        padding: 2px 6px;
    }
    
    .clock-time,
    .clock-date {
        font-size: 10px;
    }
    
    .start-menu {
        height: calc(100vh - 50px);
        max-height: calc(100vh - 50px);
        bottom: 40px;
    }
    
    .search-panel {
        height: calc(100vh - 50px);
        max-height: calc(100vh - 50px);
        bottom: 40px;
    }
    
    .start-search {
        padding: 12px 16px 8px;
    }
    
    .pinned-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .pinned-item {
        padding: 8px 4px;
    }
    
    .pinned-item .item-icon {
        width: 28px;
        height: 28px;
        margin-bottom: 4px;
    }
    
    .pinned-item .item-icon i {
        font-size: 22px;
    }
    
    .pinned-item .item-name {
        font-size: 9px;
    }
    
    .start-footer {
        padding: 8px 16px;
    }
}

/* ============================================
   触摸优化
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* 移除悬停效果，添加触摸反馈 */
    .desktop-icon:hover {
        background: transparent;
    }
    
    .desktop-icon:active {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(0.95);
    }
    
    .start-btn:hover,
    .search-btn:hover,
    .task-view-btn:hover,
    .widgets-btn:hover,
    .taskbar-item:hover {
        background: transparent;
    }
    
    .start-btn:active,
    .search-btn:active,
    .task-view-btn:active,
    .widgets-btn:active,
    .taskbar-item:active {
        background: rgba(0, 0, 0, 0.1);
    }
    
    .pinned-item:hover {
        background: transparent;
    }
    
    .pinned-item:active {
        background: rgba(0, 0, 0, 0.1);
        transform: scale(0.95);
    }
    
    .context-menu-item:hover {
        background: transparent;
    }
    
    .context-menu-item:active {
        background: rgba(0, 0, 0, 0.08);
    }
    
    .search-result-item:hover {
        background: transparent;
    }
    
    .search-result-item:active {
        background: rgba(0, 0, 0, 0.08);
    }
    
    /* 增加所有可点击元素的最小尺寸 */
    .pinned-item,
    .search-result-item,
    .context-menu-item {
        min-height: 44px;
    }
    
    /* 禁用文本选择 */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
}

/* ============================================
   iOS Safari 特定修复
   ============================================ */
@supports (-webkit-touch-callout: none) {
    /* 修复 iOS Safari 底部安全区域 */
    .win11-taskbar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(56px + env(safe-area-inset-bottom));
    }
    
    .win11-desktop {
        bottom: calc(56px + env(safe-area-inset-bottom));
    }
    
    .windows-container {
        bottom: calc(56px + env(safe-area-inset-bottom));
    }
    
    .start-menu {
        bottom: calc(56px + env(safe-area-inset-bottom));
    }
    
    .search-panel {
        bottom: calc(56px + env(safe-area-inset-bottom));
    }
    
    .context-menu {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
    
    /* 修复 iOS 输入框缩放问题 */
    input[type="text"],
    input[type="search"] {
        font-size: 16px;
    }
}

/* ============================================
   深色模式支持（跟随系统）
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --win11-taskbar-bg: rgba(32, 32, 32, 0.85);
        --win11-window-bg: rgba(32, 32, 32, 0.95);
        --win11-text: #ffffff;
        --win11-text-secondary: #9a9a9a;
        --win11-hover: rgba(255, 255, 255, 0.08);
        --win11-active: rgba(255, 255, 255, 0.12);
    }
    
    .win11-taskbar {
        background: rgba(32, 32, 32, 0.85);
        border-top-color: rgba(255, 255, 255, 0.1);
    }
    
    .start-menu,
    .search-panel {
        background: rgba(32, 32, 32, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .start-search-input,
    .search-panel-input {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.1);
        color: #fff;
    }
    
    .start-search-input:focus,
    .search-panel-input:focus {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .pinned-header h3,
    .pinned-item .item-name,
    .user-name,
    .search-result-item .result-name {
        color: #fff;
    }
    
    .pinned-header .all-apps-btn {
        color: rgba(255, 255, 255, 0.8);
    }
    
    .search-category h4 {
        color: rgba(255, 255, 255, 0.6);
    }
    
    .start-footer {
        border-top-color: rgba(255, 255, 255, 0.1);
    }
    
    .pinned-item:active,
    .start-btn:active,
    .search-btn:active,
    .taskbar-item:active {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .context-menu {
        background: rgba(40, 40, 40, 0.98);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .context-menu-item span {
        color: #fff;
    }
    
    .context-menu-separator {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .win11-window {
        background: rgba(32, 32, 32, 0.98);
    }
    
    .window-titlebar {
        background: rgba(32, 32, 32, 0.98);
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }
    
    .window-title {
        color: #fff;
    }
    
    .window-control-btn i {
        color: #fff;
    }
    
    .window-content {
        background: #1e1e1e;
    }
}

/* ============================================
   打印样式（可选）
   ============================================ */
@media print {
    .win11-taskbar,
    .start-menu,
    .search-panel,
    .context-menu,
    .loading-overlay {
        display: none !important;
    }
    
    .win11-desktop {
        position: static;
        background: #fff;
    }
}
