/* ====================================
   iPad 專用優化樣式
   適用於 iPad (768px - 1024px)
   ==================================== */

/* iPad 橫屏和豎屏適配 */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 15px;
    }
    
    /* 主標題優化 */
    .main-header {
        padding: 20px;
        margin-bottom: 20px;
        border-radius: 16px;
    }
    
    .logo {
        width: 55px;
        height: 55px;
    }
    
    .logo-text h1 {
        font-size: 1.4em;
    }
    
    /* 導航欄優化 - 使用桌面版但調整大小 */
    .desktop-nav {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px;
    }
    
    .nav-item {
        padding: 12px 16px;
        min-width: 85px;
        flex: 0 1 auto;
    }
    
    .nav-item i {
        font-size: 22px;
        margin-bottom: 6px;
    }
    
    .nav-item span {
        font-size: 0.9em;
    }
    
    /* 隱藏漢堡菜單 */
    .hamburger-menu {
        display: none !important;
    }
    
    .mobile-menu {
        display: none !important;
    }
    
    /* 功能區塊優化 */
    .feature-section {
        padding: 20px;
        margin-bottom: 20px;
        border-radius: 16px;
    }
    
    .section-header {
        flex-direction: row;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .section-icon {
        width: 55px;
        height: 55px;
        font-size: 28px;
    }
    
    .section-title h2 {
        font-size: 1.5em;
    }
    
    .section-title p {
        font-size: 0.95em;
    }
    
    /* 上傳區域優化 - 更大的觸控區域 */
    .upload-area {
        min-height: 180px;
        padding: 30px 20px;
        border-width: 3px;
    }
    
    .upload-placeholder {
        pointer-events: none;
    }
    
    .upload-icon {
        font-size: 48px;
        margin-bottom: 15px;
    }
    
    .upload-placeholder p {
        font-size: 1.2em;
        font-weight: 600;
    }
    
    .upload-placeholder small {
        font-size: 0.9em;
    }
    
    /* 按鈕優化 - 更大更容易點擊 */
    .action-btn,
    .primary-btn,
    .danger-btn,
    button[type="button"],
    button[type="submit"] {
        min-height: 50px;
        padding: 15px 25px;
        font-size: 1.1em;
        border-radius: 12px;
        touch-action: manipulation;
    }
    
    /* 輸入框和文本域優化 */
    input[type="text"],
    input[type="number"],
    input[type="color"],
    textarea,
    select {
        min-height: 45px;
        padding: 12px 15px;
        font-size: 16px; /* 防止 iOS 縮放 */
        border-radius: 10px;
        touch-action: manipulation;
    }
    
    textarea {
        min-height: 100px;
        font-size: 16px;
    }
    
    /* 滑塊優化 - 更大的拖動區域 */
    input[type="range"] {
        height: 40px;
        -webkit-appearance: none;
        background: transparent;
    }
    
    input[type="range"]::-webkit-slider-runnable-track {
        height: 8px;
        border-radius: 4px;
        background: #e2e8f0;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        background: #667eea;
        margin-top: -10px;
        cursor: pointer;
        touch-action: manipulation;
        box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    }
    
    /* 圖片編輯區域優化 */
    #frameEditorStage,
    #textFrameEditorStage {
        min-height: 400px;
        border-radius: 16px;
        touch-action: none; /* 防止滾動干擾拖曳 */
    }
    
    /* 預覽圖片優化 */
    .preview-area img {
        max-height: 400px;
        border-radius: 12px;
    }
    
    /* 結果圖片優化 */
    .result-image {
        max-width: 100%;
        max-height: 500px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
    
    /* 選項卡片優化 */
    .wan-sketch-card,
    .wan-multi-card,
    .wan-expand-card,
    .text-option-card {
        padding: 18px;
        border-radius: 12px;
        margin-bottom: 15px;
    }
    
    .wan-sketch-card label,
    .wan-multi-card label,
    .wan-expand-card label,
    .text-option-card label {
        font-size: 1em;
        margin-bottom: 10px;
    }
    
    /* 複選框優化 - 更大的點擊區域 */
    .checkbox-label {
        min-height: 45px;
        padding: 10px 15px;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .checkbox-custom {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }
    
    .checkbox-text {
        font-size: 1em;
    }
    
    /* 預設選項優化 */
    .preset-option {
        min-width: 160px;
        padding: 15px;
        border-radius: 12px;
        touch-action: manipulation;
    }
    
    .preset-option .preset-icon {
        width: 60px;
        height: 60px;
        font-size: 28px;
        margin-bottom: 10px;
    }
    
    .preset-option span {
        font-size: 0.95em;
    }
    
    /* 提示框優化 */
    .prompt-tips,
    .prompt-guide {
        padding: 15px;
        border-radius: 10px;
        font-size: 0.95em;
        margin-top: 10px;
    }
    
    .prompt-tips strong,
    .prompt-guide-title {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .prompt-tips ul li,
    .prompt-guide-list li {
        font-size: 0.95em;
        margin-bottom: 6px;
    }
    
    /* 加載指示器優化 */
    .loading-overlay {
        font-size: 1.2em;
    }
    
    .loading-spinner {
        width: 60px;
        height: 60px;
        border-width: 5px;
    }
    
    /* 錯誤/成功提示優化 */
    .error-message,
    .success-message {
        padding: 15px 20px;
        border-radius: 10px;
        font-size: 1em;
        min-height: 50px;
        display: flex;
        align-items: center;
    }
}

/* iPad 橫屏優化 */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    .container {
        max-width: 1200px;
    }
    
    .feature-section {
        padding: 25px;
    }
    
    /* 多列佈局 */
    .image-options {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .text-options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* iPad 豎屏優化 */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .container {
        padding: 12px;
    }
    
    .feature-section {
        padding: 18px;
    }
    
    /* 單列佈局 */
    .image-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .text-options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* 調整編輯區域高度 */
    #frameEditorStage,
    #textFrameEditorStage {
        min-height: 350px;
    }
}

/* ====================================
   觸控優化 - 防止意外縮放和滾動
   ==================================== */

/* 防止 Safari 雙擊縮放 */
* {
    touch-action: manipulation;
}

/* 編輯區域禁止默認觸控行為 */
#frameEditorStage,
#textFrameEditorStage,
.upload-area {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 圖片禁止拖曳 */
#frameEditorPhoto,
#frameEditorOverlay,
#textFrameEditorPhoto,
#textFrameEditorOverlay,
.preview-area img,
.result-image {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none; /* 防止干擾父級拖曳 */
}

/* 可拖曳元素 */
#textFrameEditorText {
    touch-action: none;
    cursor: move;
    -webkit-user-select: none;
    user-select: none;
}

/* ====================================
   iPad 特定優化 - 防止 Safari 問題
   ==================================== */

/* 防止 iOS 自動調整字體大小 */
body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* 輸入框字體大小至少 16px 防止縮放 */
input,
textarea,
select {
    font-size: 16px !important;
}

/* 移除 iOS 輸入框默認樣式 */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 10px;
}

/* 移除 iOS 按鈕默認樣式 */
button,
input[type="button"],
input[type="submit"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 12px;
}

/* 顏色輸入框優化 */
input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 100%;
    height: 50px;
    padding: 0;
    overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 10px;
}

/* ====================================
   加載狀態和動畫優化
   ==================================== */

/* 按鈕點擊反饋 */
button:active,
.preset-option:active,
.nav-item:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* 平滑過渡 */
.nav-item,
.preset-option,
button,
.upload-area {
    transition: all 0.2s ease;
}

/* 加載動畫 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading-overlay p {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ====================================
   iPad 橫屏快捷切換提示
   ==================================== */

@media (orientation: portrait) and (max-width: 1024px) {
    .landscape-hint {
        display: block;
        text-align: center;
        padding: 10px;
        background: #fff3cd;
        border: 1px solid #ffc107;
        border-radius: 8px;
        margin-bottom: 15px;
        font-size: 0.9em;
        color: #856404;
    }
}

@media (orientation: landscape) and (max-width: 1366px) {
    .landscape-hint {
        display: none;
    }
}

/* ====================================
   打印樣式（可選）
   ==================================== */

@media print {
    .main-header,
    .feature-nav,
    .action-section,
    .upload-section {
        display: none;
    }
    
    .result-section {
        display: block !important;
    }
    
    .result-image {
        max-width: 100%;
        box-shadow: none;
    }
}
