/* ===== 全域設定 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft JhengHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

/* ===== 主要容器 ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

/* ===== 標題區域 ===== */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 35px 30px;
    text-align: center;
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header .subtitle {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 300;
}

/* ===== 設定面板 (可摺疊) ===== */
.settings-panel {
    background: #f8f9fa;
    padding: 20px 30px;
    border-bottom: 1px solid #e9ecef;
    position: relative;
}

.settings-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    min-width: 110px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.setting-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.setting-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

/* ===== 區塊通用樣式 ===== */
section {
    padding: 30px;
    border-bottom: 1px solid #f0f0f0;
}

section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* ===== 上傳區域 (增強視覺回饋) ===== */
.drop-zone {
    border: 3px dashed #d1d5db;
    border-radius: 16px;
    padding: 50px 20px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: linear-gradient(135deg, #fafbfc 0%, #f8f9fa 100%);
    position: relative;
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
    opacity: 1;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
}

.upload-icon {
    width: 70px;
    height: 70px;
    color: #adb5bd;
    margin-bottom: 20px;
    transition: all 0.4s ease;
}

.drop-zone:hover .upload-icon,
.drop-zone.drag-over .upload-icon {
    color: #667eea;
    transform: scale(1.1);
}

.drop-zone p {
    color: #6c757d;
    margin-bottom: 20px;
    font-size: 1rem;
    font-weight: 500;
}

/* ===== 圖片預覽 ===== */
.image-preview {
    position: relative;
    margin-top: 20px;
    border-radius: 16px;
    overflow: hidden;
    border: 3px solid #e9ecef;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.image-preview img {
    width: 100%;
    max-height: 450px;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

#removeImageBtn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.3rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ===== 按鈕樣式 (全面增強) ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover::after {
    opacity: 1;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
}

.btn-large {
    padding: 16px 40px;
    font-size: 1.15rem;
    width: 100%;
    border-radius: 12px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* ===== 狀態列 (增強視覺) ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-radius: 12px;
    margin-top: 20px;
    color: #856404;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.2);
    border: 1px solid #ffc107;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #ffc107;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 結果區域 (頁籤增強) ===== */
.result-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 25px;
    background: #f8f9fa;
    padding: 4px;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tab-content {
    display: none;
    animation: fadeInUp 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 表單樣式 (增強) ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group input,
.form-group textarea {
    padding: 12px 14px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

/* ===== 商品/服務項目區域 (增強) ===== */
.items-section {
    margin-top: 10px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
}

.items-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #dee2e6;
}

.items-header label {
    margin-bottom: 0 !important;
    font-size: 1rem !important;
}

.items-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    background: white;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    animation: slideInItem 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

@keyframes slideInItem {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.item-row:hover {
    border-color: #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.item-row input {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s ease;
    width: 100%;
}

.item-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.item-row .item-quantity,
.item-row .item-unit-price {
    text-align: right;
}

.btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.2rem;
}

/* ===== JSON 輸出 (增強可讀性) ===== */
#jsonOutput {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    color: #d4d4d4;
    padding: 24px;
    border-radius: 12px;
    font-family: 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 250px;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid #404040;
}

/* ===== 結果操作按鈕 ===== */
.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 2px solid #f0f0f0;
}

/* ===== Footer ===== */
footer {
    padding: 24px 30px;
    text-align: center;
    color: #adb5bd;
    font-size: 0.9rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 1px solid #dee2e6;
}

footer p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ===== 隱藏類別 ===== */
.hidden {
    display: none !important;
}

/* ===== Toast 通知樣式 (增強) ===== */
.toast-enter {
    animation: toastSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes toastSlideIn {
    from { transform: translateX(100%) scale(0.8); opacity: 0; }
    to { transform: translateX(0) scale(1); opacity: 1; }
}

/* ===== RWD - 行動裝置優化 ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
        background-attachment: scroll;
    }

    .container {
        border-radius: 16px;
    }

    section, .settings-panel {
        padding: 20px;
    }

    header {
        padding: 25px 20px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .setting-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .setting-row label {
        min-width: auto;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }

    .item-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .item-row .btn-icon {
        align-self: flex-end;
    }

    .result-tabs {
        flex-direction: column;
        gap: 4px;
    }

    .drop-zone {
        padding: 35px 15px;
    }

    .upload-icon {
        width: 60px;
        height: 60px;
    }
}

/* ===== RWD - 小螢幕手機 ===== */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }

    .btn-large {
        padding: 14px 20px;
        font-size: 1rem;
    }
}