﻿/* POS 系統樣式 */

/* 基本容器 */
.pos-container {
    display: flex;
    min-height: calc(100vh - 60px);
}

.pos-left {
    flex: 1;
    padding: 15px;
    background: white;
    border-right: 2px solid #e9ecef;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.pos-right {
    width: 400px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

/* 搜尋區域 */
.pos-search {
    margin-bottom: 15px;
}

.pos-search .input-group {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pos-search input {
    font-size: 16px;
    padding: 12px;
}

/* 分類標籤 */
.pos-categories {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.btn-category {
    background: #e9ecef;
    border: 1px solid #dee2e6;
    color: #495057;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-category:hover {
    background: #dee2e6;
    transform: translateY(-1px);
}

.btn-category.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* 商品網格 */
.pos-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding-bottom: 20px;
    width: 100%;
}

.product-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 220px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card:hover {
    border-color: #007bff;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
    transform: translateY(-2px);
}

.product-card.out-of-stock {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8f9fa;
}

.product-card.out-of-stock:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border-color: #e9ecef;
}

.product-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin: 0 auto 10px auto;
    display: block;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    line-height: 1.3;
    flex-grow: 1;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.product-code {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
}

.product-price {
    font-size: 16px;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 5px;
}

.product-stock {
    font-size: 12px;
    color: #6c757d;
}

.product-stock.low-stock {
    color: #dc3545;
    font-weight: 600;
}

/* 購物車區域 */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 15px;
}

.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 15px;
    min-height: 200px;
    max-height: 40vh;
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
}

.cart-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    position: relative;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.cart-item-name {
    font-weight: 600;
    font-size: 14px;
    flex-grow: 1;
    margin-right: 10px;
    line-height: 1.3;
}

.cart-item-remove {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.cart-item-remove:hover {
    background: rgba(220, 53, 69, 0.1);
}

.cart-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quantity-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    transition: all 0.2s;
}

.quantity-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.quantity-input {
    width: 50px;
    text-align: center;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px;
    font-size: 13px;
}

.item-total {
    font-weight: 600;
    color: #28a745;
}

/* 購物車總計 */
.cart-summary {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-line.total {
    border-top: 1px solid #e9ecef;
    padding-top: 8px;
    margin-top: 8px;
    font-weight: bold;
    font-size: 16px;
    color: #28a745;
}

/* 客戶資訊 */
.customer-info {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

/* 結帳按鈕 */
.checkout-actions {
    margin-top: auto;
}

.btn-checkout {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-checkout:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-checkout:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* 結帳模態框 */
.checkout-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
}

.payment-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

/* 條碼掃描 */
#barcodeInput {
    text-align: center;
    font-size: 18px;
    letter-spacing: 2px;
}

/* 載入動畫 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 成功提示 */
.success-message {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

/* 錯誤提示 */
.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .pos-right {
        width: 350px;
    }
    
    .pos-products {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 992px) {
    .pos-container {
        flex-direction: column;
        min-height: auto;
    }
    
    .pos-left {
        max-height: none;
        border-right: none;
        border-bottom: 2px solid #e9ecef;
        min-height: 60vh;
    }
    
    .pos-right {
        width: 100%;
        max-height: none;
        border-left: none;
        border-top: 1px solid #dee2e6;
        min-height: 40vh;
    }
    
    .pos-products {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .product-card {
        min-height: 180px;
        padding: 10px;
    }
    
    .product-image {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 768px) {
    .pos-left,
    .pos-right {
        padding: 10px;
    }
    
    .pos-products {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }
    
    .product-card {
        min-height: 160px;
        padding: 8px;
    }
    
    .product-image {
        width: 50px;
        height: 50px;
    }
    
    .product-name {
        font-size: 12px;
        min-height: 30px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .btn-category {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .pos-products {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 6px;
    }
    
    .product-card {
        min-height: 140px;
        padding: 6px;
    }
    
    .product-image {
        width: 40px;
        height: 40px;
    }
    
    .product-name {
        font-size: 11px;
        min-height: 24px;
    }
}

/* 滾動條美化 */
.pos-left::-webkit-scrollbar,
.pos-right::-webkit-scrollbar,
.cart-items::-webkit-scrollbar {
    width: 6px;
}

.pos-left::-webkit-scrollbar-track,
.pos-right::-webkit-scrollbar-track,
.cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.pos-left::-webkit-scrollbar-thumb,
.pos-right::-webkit-scrollbar-thumb,
.cart-items::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.pos-left::-webkit-scrollbar-thumb:hover,
.pos-right::-webkit-scrollbar-thumb:hover,
.cart-items::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 空白狀態改善 */
.pos-products > div:first-child:last-child {
    grid-column: 1 / -1;
}