/* static/css/app-store.css - App Store 功能樣式 (修正螢幕擷圖顯示) */
/* Version: 3.1 - App Review Advanced Editor with Image Management */

/* ============ App Store 表單樣式 ============ */
.app-store-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* ============ App 預覽容器 ============ */
.app-preview-container {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.app-header {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e9ecef;
}

.app-icon {
    width: 100px;
    height: 100px;
    border-radius: 22.5%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-right: 20px;
}

.app-info h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 24px;
}

.app-info .text-muted {
    margin: 0;
    font-size: 14px;
}

/* ============ 主題圖容器 ============ */
.feature-image-container {
    margin-bottom: 30px;
}

.feature-image-container h5 {
    color: #0056b3;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.feature-image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ============ 描述區域樣式 ============ */
.app-description,
#app-store-translated {
    margin-bottom: 30px;
}

.app-description h5,
#app-store-translated h5 {
    color: #0056b3;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.description-box, #translated-content {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #495057;
    max-height: 300px;
    overflow-y: auto;
}

#translated-content {
    background: #e7f3ff;
}

/* ============ 螢幕擷圖樣式 (修正版) ============ */
.app-screenshots {
    margin-bottom: 30px;
}

.app-screenshots h5 {
    color: #0056b3;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.screenshot-tabs {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
}

#screenshot-device-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 10px;
}

.tab-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #545b62;
}

.tab-btn.active {
    background: #007bff;
}

/* 螢幕擷圖內容區域 - 修正顯示問題 */
#screenshot-device-content,
.tab-content-area {
    min-height: 420px; /* 確保有最小高度 */
    position: relative;
    background: #fff;
    border-radius: 4px;
    padding: 10px;
}

/* 螢幕擷圖面板樣式 - 修正顯示邏輯 */
.screenshot-pane {
    display: none;
    width: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

.screenshot-pane.active {
    display: block !important; /* 確保覆蓋其他樣式 */
    visibility: visible !important;
    opacity: 1 !important;
}

/* 螢幕擷圖畫廊 - 修正佈局 */
.screenshot-gallery {
    display: flex;
    flex-wrap: nowrap; /* 改為不換行，使用水平滾動 */
    gap: 15px;
    padding: 10px 5px;
    overflow-x: auto; /* 啟用水平滾動 */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滾動 */
}

/* 自定義滾動條 */
.screenshot-gallery::-webkit-scrollbar {
    height: 8px;
}

.screenshot-gallery::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 4px;
}

.screenshot-gallery::-webkit-scrollbar-thumb {
    background-color: #007bff;
    border-radius: 4px;
}

.screenshot-gallery::-webkit-scrollbar-thumb:hover {
    background-color: #0056b3;
}

/* 螢幕擷圖容器 */
.screenshot-container {
    flex: 0 0 auto; /* 不要伸縮 */
    display: inline-block;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #f8f9fa;
}

.screenshot-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* 螢幕擷圖圖片 */
.screenshot-img {
    display: block;
    height: 400px;
    width: auto;
    max-width: none; /* 移除最大寬度限制 */
    object-fit: contain;
    border-radius: 6px;
    background-color: #f8f9fa;
}

/* 載入中的圖片樣式 */
.screenshot-img[src=""] {
    width: 200px;
    background: #e9ecef;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .screenshot-img {
        height: 300px;
    }
    
    .screenshot-gallery {
        gap: 10px;
        padding: 5px;
    }
    
    #screenshot-device-content {
        min-height: 320px;
    }
}

/* 載入動畫 */
@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* 錯誤狀態 */
.screenshot-img[src*="data:image/svg"] {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8d7da;
    color: #842029;
    font-family: Arial, sans-serif;
    font-size: 14px;
    padding: 20px;
    text-align: center;
    box-sizing: border-box;
    width: 200px;
    height: 400px;
}

/* ============ 操作按鈕區域 ============ */
.app-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* ============ 其他響應式設計 ============ */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        text-align: center;
    }
    
    .app-icon {
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    #screenshot-device-tabs {
        justify-content: center;
    }
    
    .app-actions {
        flex-direction: column;
    }
    
    .app-actions button {
        width: 100%;
    }
}

/* 確保文字樣式 */
.text-muted {
    color: #6c757d;
}

.p-3 {
    padding: 1rem;
}

/* ============ 編輯介面樣式 ============ */
.edit-title-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #007bff;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    font-weight: 600;
}

.edit-title-input:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.edit-content-textarea {
    width: 100%;
    min-height: 500px !important; /* 增加編輯空間 */
    max-height: 700px;
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    border: 2px solid #007bff;
    border-radius: 6px;
    background: #fff;
    color: #495057;
    resize: vertical; /* 允許垂直調整大小 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.edit-content-textarea:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* 編輯模式提示 */
.editing-mode-hint {
    background: #e7f3ff;
    border: 1px solid #b3d7ff;
    color: #0056b3;
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}

.editing-mode-hint::before {
    content: "✏️ ";
    margin-right: 5px;
}

/* ============ 截圖選擇介面樣式 ============ */
.screenshot-selection {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.screenshot-selection h3 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 18px;
}

.screenshot-selection p {
    color: #6c757d;
    margin-bottom: 20px;
    font-size: 14px;
}

.device-screenshots {
    margin-bottom: 25px;
}

.device-screenshots h4 {
    color: #343a40;
    margin-bottom: 15px;
    font-size: 16px;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
}

.screenshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.screenshot-item {
    position: relative;
}

.screenshot-item input[type="checkbox"] {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.screenshot-item label {
    display: block;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.screenshot-item label:hover {
    border-color: #007bff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.screenshot-item input[type="checkbox"]:checked + label {
    border-color: #28a745;
    background-color: #d4edda;
}

.screenshot-item input[type="checkbox"]:disabled + label {
    opacity: 0.5;
    cursor: not-allowed;
}

.screenshot-item img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 200px;
    object-fit: cover;
}

.screenshot-label {
    display: block;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    color: #495057;
    background: white;
    border-top: 1px solid #e9ecef;
}

.selection-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 15px;
    border-top: 1px solid #dee2e6;
    margin-top: 15px;
}

.selection-count {
    font-weight: 600;
    color: #495057;
    margin-left: auto;
}

.selection-count span {
    color: #007bff;
}

/* ============ App Review 進階編輯器樣式 ============ */

#appReviewEditModal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

.screenshot-selection-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.selected-screenshots-preview {
    background: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    margin: 10px 0;
}

.selected-screenshots-info p {
    margin-bottom: 10px;
    color: #495057;
}

.screenshot-thumbnails {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.screenshot-thumbnail {
    border: 2px solid #007bff;
}

.more-count {
    background: #6c757d;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.app-icon-label {
    background: #007bff;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 5px;
}

.gallery-item {
    position: relative;
}

.gallery-item.thumbnail-selected {
    border: 3px solid #007bff;
    background: #e7f3ff;
}

.gallery-item-controls {
    padding: 8px;
    text-align: center;
    background: #f8f9fa;
}

.gallery-item-controls button {
    margin: 2px;
    padding: 4px 8px;
    font-size: 12px;
}

/* App Review 編輯器的上傳標籤頁 */
.upload-pane#app-wp-library,
.upload-pane#app-upload-file,
.upload-pane#app-upload-url {
    display: none;
}

.upload-pane#app-wp-library.active,
.upload-pane#app-upload-file.active,
.upload-pane#app-upload-url.active {
    display: block;
}