:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #7db9b6;
    --light-color: #e6f4f1;
    --dark-color: #333;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --gray-color: #6c757d;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f8f9fa;
    padding: 20px;
    min-height: 100vh;
}

h1, h2, h3 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-top: 1rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

button {
    cursor: pointer;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    transition: var(--transition);
}

button:hover {
    background-color: var(--secondary-color);
}

button:disabled {
    background-color: var(--gray-color);
    cursor: not-allowed;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn:hover {
    background-color: var(--secondary-color);
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #218838;
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* 上傳區域 */
.upload-section {
    margin-bottom: 2rem;
    text-align: center;
}

.upload-container {
    border: 2px dashed var(--primary-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 1rem;
    background-color: var(--light-color);
    transition: var(--transition);
    cursor: pointer;
}

.upload-container:hover {
    background-color: #d9edf7;
}

.upload-container.drag-over {
    background-color: #d1ecf1;
    border-color: var(--secondary-color);
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-label {
    display: block;
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    cursor: pointer;
}

.upload-hint {
    color: var(--gray-color);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.file-input {
    display: none;
}

.upload-status {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
}

.progress-container {
    width: 100%;
    height: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 100%;
    background-color: var(--success-color);
    border-radius: 5px;
    width: 0;
    transition: width 0.3s ease;
}

.upload-count {
    font-size: 0.9rem;
    color: var(--gray-color);
}

/* 預覽區域 */
.preview-section {
    display: none;
    margin-bottom: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.preview-item {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.preview-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.5);
}

.preview-image-container {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 比例 */
    overflow: hidden;
}

.preview-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: #f8f9fa;
}

.preview-info {
    padding: 0.75rem;
    background-color: #f8f9fa;
}

.image-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-size {
    font-size: 0.8rem;
    color: var(--gray-color);
}

.preview-actions-btn {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.select-box {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    padding: 0.25rem;
    width: 24px;
    height: 24px;
}

.select-image {
    cursor: pointer;
}

/* 結果區域 */
.result-section {
    display: none;
    margin-bottom: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.result-item {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

.result-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.5);
}

.result-item::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.6);
    opacity: 0;
    transition: var(--transition);
    z-index: 1;
    pointer-events: none;
}

.result-item.selected::before {
    opacity: 1;
}

.result-item.selected::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: var(--primary-color);
    z-index: 2;
}

.result-image-container {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 比例 */
    overflow: hidden;
    background-color: transparent; /* 確保透明背景 */
}

.result-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-info {
    padding: 0.75rem;
    background-color: #f8f9fa;
}

.result-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.25rem;
}

.result-actions button {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.download-btn {
    background-color: var(--success-color);
}

.delete-result-btn {
    background-color: var(--danger-color);
    flex: 0 0 auto;
}

.main-btn {
    background-color: var(--primary-color);
    font-weight: 500;
}

.tab-btn {
    background-color: var(--accent-color);
    font-weight: 500;
}

/* 提示信息 */
.hint-text {
    color: var(--gray-color);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* 切割模式選擇器樣式 */
.split-mode-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem;
}

.split-mode-label {
    font-size: 0.9rem;
    color: var(--gray-color);
}

.btn-mode {
    background-color: #f0f0f0;
    color: var(--dark-color);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-mode.active {
    background-color: var(--primary-color);
    color: white;
}

.btn-mode:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 下載選項樣式 */
.download-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-size-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
}

.size-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.size-options label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.custom-size-inputs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.custom-size-inputs input {
    width: 60px;
    padding: 0.25rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* 添加表情貼按鈕樣式 */
.btn-exp {
    background-color: #8e44ad;
    color: white;
    font-size: 0.75rem !important;
    padding: 0.25rem 0.4rem !important;
}

.btn-exp:hover {
    background-color: #7d3c98;
}

/* 切割線樣式 */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.grid-line {
    position: absolute;
    background-color: rgba(255, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.grid-line.horizontal, .grid-line.horizontal-2, .grid-line.horizontal-3 {
    width: 100%;
    height: 2px;
    left: 0;
}

.grid-line.vertical, .grid-line.vertical-2, .grid-line.vertical-3 {
    width: 2px;
    height: 100%;
    top: 0;
}

.grid-line.horizontal {
    top: 50%;
}

.grid-line.vertical {
    left: 50%;
}

/* 4x4 網格的額外線條 */
.grid-line.horizontal-2 {
    top: 25%;
}

.grid-line.horizontal-3 {
    top: 75%;
}

.grid-line.vertical-2 {
    left: 25%;
}

.grid-line.vertical-3 {
    left: 75%;
}

/* 響應式設計 */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .preview-grid, .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .upload-container {
        padding: 1.5rem 1rem;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .upload-label {
        font-size: 1rem;
    }
    
    .preview-header, .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .preview-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .split-mode-selector {
        justify-content: space-between;
        margin: 0.5rem 0;
    }
    
    .download-options {
        width: 100%;
    }
    
    .size-options {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .result-actions button {
        padding: 0.4rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

/* iPhone SE和小型手機適配 */
@media screen and (max-width: 375px) {
    body {
        padding: 8px;
    }
    
    .container {
        padding: 0.8rem;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    .preview-grid, .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.5rem;
    }
    
    .image-name, .result-name {
        font-size: 0.8rem;
    }
    
    .image-size {
        font-size: 0.7rem;
    }
    
    .result-actions {
        grid-template-columns: 1fr 1fr auto;
    }
    
    .select-box {
        width: 20px;
        height: 20px;
    }
    
    .result-actions .main-btn {
        grid-column: 1;
        grid-row: 1;
    }
    
    .result-actions .tab-btn {
        grid-column: 2;
        grid-row: 1;
    }
    
    .result-actions .download-btn {
        grid-column: 1;
        grid-row: 2;
    }
    
    .result-actions .btn-exp {
        grid-column: 2;
        grid-row: 2;
    }
    
    .result-actions .delete-result-btn {
        grid-column: 3;
        grid-row: 1 / span 2;
    }
}

/* iPad適配 */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .preview-grid, .result-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* iOS Safari特定修復 */
@supports (-webkit-overflow-scrolling: touch) {
    /* iOS特定樣式 */
    input[type="file"] {
        font-size: 16px; /* 防止iOS縮放 */
    }
    
    button {
        -webkit-appearance: none; /* 移除iOS默認按鈕樣式 */
        border-radius: var(--border-radius);
    }
    
    /* 改善iOS點擊體驗 */
    .upload-container, .preview-item, .result-item, 
    button, .upload-label, .select-image {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent; /* 移除iOS點擊高亮 */
    }
    
    /* 修復iOS透明度問題 */
    .result-image-container {
        background-image: 
            linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
            linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
            linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
            linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
        background-size: 20px 20px;
        background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    }
    
    /* 提高iOS上按鈕可點擊區域 */
    .btn, button {
        min-height: 44px; /* iOS推薦的最小點擊區域 */
    }
    
    /* 修正iOS固定定位問題 */
    .select-box {
        position: absolute; 
        -webkit-transform: translateZ(0);
    }
}

/* 添加新增區塊的樣式 */

.introduction {
    background-color: #f8f9fa;
    padding: 2rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.introduction h2 {
    margin-top: 0;
    color: #4a6fa5;
    margin-bottom: 1rem;
}

.introduction ul {
    padding-left: 1.5rem;
    margin-bottom: 0;
}

.introduction li {
    margin-bottom: 0.5rem;
}

.faq-section {
    margin-top: 3rem;
    margin-bottom: 3rem;
    padding: 2rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.faq-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #4a6fa5;
}

.faq-item {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 1.5rem;
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.faq-item h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.faq-item p {
    margin-bottom: 0;
}

footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid #dee2e6;
    color: #6c757d;
}

footer a {
    color: #4a6fa5;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* 調整現有功能的樣式 */
.container {
    max-width: 1200px;
    padding: 1rem;
}

header {
    margin-bottom: 2rem;
}

/* 響應式調整 */
@media (max-width: 768px) {
    .introduction,
    .faq-section {
        padding: 1.5rem;
    }
    
    .introduction ul {
        padding-left: 1.2rem;
    }
    
    .faq-item h3 {
        font-size: 1.1rem;
    }
} 