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

:root {
    --primary-color: #0070ba;
    --primary-hover: #005ea6;
    --secondary-color: #142c8e;
    --success-color: #28a745;
    --warning-color: #ffc439;
    --danger-color: #dc3545;
    --light-gray: #f7f9fa;
    --medium-gray: #e5e7eb;
    --dark-gray: #6b7280;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* 導航欄樣式 */
.navbar {
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--medium-gray);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-brand i {
    font-size: 24px;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--medium-gray);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn:hover {
    background: var(--light-gray);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* 進度指示器 */
.progress-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    background: white;
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 200px;
}

.step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: var(--medium-gray);
    z-index: 1;
}

.step.active:not(:last-child)::after {
    background: var(--primary-color);
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--medium-gray);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
    transition: var(--transition);
}

.step.active .step-number {
    background: var(--primary-color);
}

.step-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.step.active .step-label {
    color: var(--primary-color);
}

/* 區塊標題 */
.section-header {
    text-align: center;
    margin-bottom: 40px;
}

.section-header h2 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* 表單樣式 */
.form-section {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.form-card {
    background: var(--light-gray);
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--medium-gray);
}

.form-card h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: var(--transition);
    background: white;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 112, 186, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 商品庫存樣式 */
.inventory-section {
    margin-bottom: 32px;
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.inventory-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.inventory-item {
    background: white;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.inventory-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.inventory-item.selected {
    border-color: var(--primary-color);
    background: rgba(0, 112, 186, 0.05);
}

.inventory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.inventory-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.inventory-item-category {
    background: var(--light-gray);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.inventory-item-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.inventory-item-price {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.inventory-item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition);
}

.inventory-item:hover .inventory-item-actions {
    opacity: 1;
}

.inventory-action-btn {
    background: white;
    border: 1px solid var(--medium-gray);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.inventory-action-btn:hover {
    background: var(--light-gray);
}

/* 商品清單樣式 */
.items-section {
    background: var(--light-gray);
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--medium-gray);
}

.items-section h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 16px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--border-radius);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 16px;
    padding: 16px;
    background: white;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.item-info {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.item-description {
    font-size: 14px;
    color: var(--text-secondary);
}

.item-price,
.item-subtotal {
    font-weight: 600;
    color: var(--text-primary);
}

.item-quantity-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    text-align: center;
}

.items-summary {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 16px;
    border: 1px solid var(--medium-gray);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 16px;
}

.summary-item.total {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
    border-top: 2px solid var(--medium-gray);
    padding-top: 12px;
    margin-top: 12px;
}

.summary-item.change {
    font-weight: 600;
    color: #27ae60;
    background-color: #f8f9fa;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    margin-top: 8px;
    border: 1px solid #d4edda;
}

/* 按鈕樣式 */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--medium-gray);
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: var(--light-gray);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--medium-gray);
}

.download-buttons {
    display: flex;
    gap: 12px;
}

.btn-download {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-download.pdf {
    background: #dc3545;
    color: white;
}

.btn-download.pdf:hover {
    background: #c82333;
}

.btn-download.png {
    background: #28a745;
    color: white;
}

.btn-download.png:hover {
    background: #218838;
}

.btn-download.mongodb {
    background: #007bff;
    color: white;
}

.btn-download.mongodb:hover {
    background: #0056b3;
}


/* 帳單預覽樣式 */
.bill-preview {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.bill-content {
    padding: 48px;
    background: white;
}

.bill-header {
    margin-bottom: 40px;
    border-bottom: 2px solid var(--medium-gray);
    padding-bottom: 32px;
}

.bill-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.bill-title h1 {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.bill-status {
    display: flex;
    align-items: center;
}

.status-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}

/* 不同狀態的顏色 */
.status-待付款 {
    background: var(--warning-color);
    color: #856404;
}

.status-已付款 {
    background: var(--success-color);
    color: white;
}

.status-部分付款 {
    background: #17a2b8;
    color: white;
}

.status-已取消 {
    background: var(--danger-color);
    color: white;
}

.status-草稿 {
    background: var(--medium-gray);
    color: var(--text-secondary);
}

.status-已逾期 {
    background: #dc3545;
    color: white;
}

.bill-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.meta-item {
    font-size: 16px;
    color: var(--text-secondary);
}

.meta-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* 收付款人資訊 */
.bill-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 40px;
    padding: 24px;
    background: var(--light-gray);
    border-radius: var(--border-radius);
}

.party-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.party-details {
    color: var(--text-secondary);
    line-height: 1.6;
}

.party-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.party-address {
    margin-bottom: 12px;
    white-space: pre-line;
}

.party-contact div {
    margin-bottom: 4px;
}

/* 帳單表格樣式 */
.bill-items {
    margin-bottom: 32px;
}

.bill-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.bill-table th {
    background: var(--primary-color);
    color: white;
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bill-table td {
    padding: 16px;
    border-bottom: 1px solid var(--medium-gray);
    font-size: 16px;
}

.bill-table th:last-child,
.bill-table td:last-child {
    text-align: right;
}

.bill-table tbody tr {
    background: white;
    transition: var(--transition);
}

.bill-table tbody tr:hover {
    background: var(--light-gray);
}

.bill-table tbody tr:last-child td {
    border-bottom: none;
}

/* 帳單摘要樣式 */
.bill-summary {
    background: var(--light-gray);
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--medium-gray);
    margin-bottom: 32px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 16px;
    color: var(--text-primary);
}

.summary-row.total {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px solid var(--primary-color);
    padding-top: 16px;
    margin-top: 16px;
}

.summary-row.change {
    font-weight: 600;
    color: #27ae60;
    background-color: #f8f9fa;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-top: 8px;
    border: 1px solid #d4edda;
}

/* 備註和提示區塊 */
.bill-notes {
    margin-top: 32px;
}

.notes-section,
.tips-section {
    background: var(--light-gray);
    padding: 24px;
    border-radius: var(--border-radius);
    border: 1px solid var(--medium-gray);
    margin-bottom: 16px;
}

.notes-section h3,
.tips-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.notes-section p,
.tips-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-line;
    margin: 0;
}

.notes-section h3 i {
    color: var(--warning-color);
}

.tips-section h3 i {
    color: var(--primary-color);
}

/* 模態框樣式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0 24px;
    border-bottom: 1px solid var(--medium-gray);
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--light-gray);
    color: var(--text-primary);
}

.modal-body {
    padding: 0 24px 24px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 24px;
    border-top: 1px solid var(--medium-gray);
    background: var(--light-gray);
    border-radius: 0 0 12px 12px;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 20px 10px;
    }
    
    .nav-container {
        padding: 0 10px;
    }
    
    .nav-brand span {
        display: none;
    }
    
    .nav-actions {
        gap: 8px;
    }
    
    .nav-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .progress-indicator {
        padding: 16px;
    }
    
    .step-label {
        font-size: 12px;
    }
    
    .form-section {
        padding: 24px 16px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .section-header h2 {
        font-size: 24px;
        flex-direction: column;
        gap: 8px;
    }
    
    .inventory-grid {
        grid-template-columns: 1fr;
    }
    
    .items-header,
    .item-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .items-header {
        display: none;
    }
    
    .item-row {
        padding: 12px;
    }
    
    .bill-content {
        padding: 24px 16px;
    }
    
    .bill-title {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .bill-title h1 {
        font-size: 28px;
    }
    
    .bill-parties {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .bill-meta {
        grid-template-columns: 1fr;
    }
    
    .bill-table {
        font-size: 14px;
    }
    
    .bill-table th,
    .bill-table td {
        padding: 12px 8px;
    }
    
    
    .step-actions {
        flex-direction: column;
        gap: 16px;
    }
    
    .download-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-download {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
}

/* 打印樣式 */
@media print {
    .form-section,
    .download-buttons {
        display: none;
    }
    
    .bill-preview {
        box-shadow: none;
        border: none;
    }
    
    .bill-content {
        padding: 20px;
    }
}