@charset "utf-8";

/* ===== 亮色模式 - 明亮乾淨的主題 ===== */
:root {
    /* 主要綠色 */
    --primary-green: #2DD881;
    --primary-green-hover: #25B86D;
    --primary-green-light: #E8F9F0;
    --primary-green-bg: #F0FDF7;

    /* 文字顏色 - 深色高對比 */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;

    /* 背景顏色 - 明亮清爽 */
    --bg-body: #F5F7FA;
    --bg-white: #FFFFFF;
    --bg-gray: #F9FAFB;
    --bg-card: #FFFFFF;

    /* 邊框顏色 - 淺灰柔和 */
    --border-color: #E5E7EB;
    --border-light: #F3F4F6;

    /* 陰影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* 字體大小系統 - 中等（預設） */
    --font-size-xs: 11px;      /* 極小文字 */
    --font-size-sm: 13px;      /* 小文字 */
    --font-size-base: 15px;    /* 基礎文字 */
    --font-size-md: 16px;      /* 中等文字 */
    --font-size-lg: 18px;      /* 大文字 */
    --font-size-xl: 20px;      /* 特大文字 */
    --font-size-2xl: 24px;     /* 標題 */
    --font-size-3xl: 28px;     /* 大標題 */
    --font-size-4xl: 32px;     /* 超大標題 */
}

/* ===== 深色模式 - 專業金融應用風格 ===== */
body.dark-mode {
    /* 主要綠色 - 更亮以提高可見度 */
    --primary-green: #009838;
    --primary-green-hover: #3BC970;
    --primary-green-light: #1F3A2C;
    --primary-green-bg: #162A20;

    /* 文字顏色 - 高對比 */
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-light: #6B7280;

    /* 背景顏色 - 深色專業 */
    --bg-body: #0F1419;
    --bg-white: #1A1F26;
    --bg-gray: #0F1419;
    --bg-card: #1E242C;

    /* 邊框顏色 - 微妙分隔 */
    --border-color: #2D333B;
    --border-light: #252A32;

    /* 陰影 - 深色模式下的層次 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* ===== 全域樣式 ===== */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    line-height: 1.6;
    background-color: var(--bg-body);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.pos-container {
    width: 100%;
    height: 100%;
}

/* ===== 主版面配置 ===== */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
    width: 100%;
    height: 100%;
}

/* ===== 左側：商品選單區 ===== */
.menu-section {
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.menu-header {
    flex-shrink: 0;
    padding: 25px 25px 20px 25px;
    background: var(--bg-white);
}

.menu-header h2 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: var(--text-primary);
    font-weight: 600;
}

/* 分類標籤 */
.menu-categories {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.menu-categories::-webkit-scrollbar {
    height: 6px;
}

.menu-categories::-webkit-scrollbar-track {
    background: transparent;
}

.menu-categories::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.menu-categories::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.category-btn {
    padding: 8px 16px;
    background: var(--bg-gray);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.category-btn.active {
    background: var(--primary-green);
    color: white;
}

.category-btn span {
    display: inline-block;
    margin-left: 5px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    font-size: 12px;
}

.category-btn.active span {
    background: rgba(255,255,255,0.4);
}

/* 商品網格 */
.product-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 0 20px 20px 20px;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    align-content: start;
    background: var(--bg-white);
    position: relative; /* 讓載入動畫正確定位 */
}

.product-grid::-webkit-scrollbar {
    width: 8px;
}

.product-grid::-webkit-scrollbar-track {
    background: var(--bg-gray);
}

.product-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.product-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* 圖片懶加載相關樣式 */
.image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

/* 載入動畫 - 旋轉圓圈 */
.loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(45, 216, 129, 0.1);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 懶加載圖片淡入效果 */
.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.lazy-image.loaded {
    opacity: 1;
}

.product-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 15px;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid var(--border-light);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-green);
}

/* 產品顏色圓點 */
.product-color-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--bg-white);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative; /* 讓 absolute 定位的 placeholder 正確定位 */
}

.product-image svg {
    width: 100%;
    height: 100%;
    display: block;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card h4 {
    margin: 0 0 2px 0;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
}

.product-price {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 700;
}

/* 加入購物車按鈕 */
.add-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: var(--text-primary);
    color: var(--bg-white);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-btn:hover {
    background: var(--primary-green);
    transform: scale(1.1);
}

.add-btn:active {
    transform: scale(0.95);
}

/* ===== 右側：訂單區域 ===== */
.order-section {
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.order-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 25px 15px 25px;
    border-bottom: 1px solid var(--border-color);
}

.order-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

.order-actions {
    display: flex;
    gap: 10px;
}

.btn-query {
    padding: 8px 16px;
    background: var(--primary-green);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-query:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-query:visited {
    color: white;
}

.btn-reset {
    padding: 8px 16px;
    background: var(--bg-gray);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-reset:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* 訂單項目列表 */
.order-items {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 20px 25px;
    background: var(--bg-white);
}

.order-items::-webkit-scrollbar {
    width: 6px;
}

.order-items::-webkit-scrollbar-track {
    background: var(--bg-gray);
    border-radius: 3px;
}

.order-items::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.order-items::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.empty-order {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-order p {
    margin: 5px 0;
}

.empty-order .empty-hint {
    font-size: 14px;
    color: #bbb;
}

.order-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 0;
    background: var(--bg-gray);
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    transition: all 0.3s;
}

.order-item:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.order-item:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-bottom: none;
}

.order-item:hover {
    background: var(--bg-gray);
}

.order-item-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-item-number {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 400;
    text-align: center;
    flex-shrink: 0;
}

.order-item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    position: relative;
}

.order-item-color-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.order-item-icon {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.order-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-item-details h4 {
    margin: 0;
    padding: 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

.item-options {
    margin: 0;
    padding: 0;
    font-size: 15px;
    color: var(--text-light);
}

.item-price {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 700;
    display: none;
}

.order-item-row-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 0;
    padding-right: 0;
}

/* 數量控制 */
.order-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-qty {
    width: 36px;
    height: 36px;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-qty:hover {
    background: var(--bg-gray);
    border-color: #bbb;
    color: var(--text-primary);
}

.qty-display {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.qty-display:hover {
    background: var(--primary-green);
    color: white;
}

/* 刪除按鈕 */
.btn-delete {
    width: 38px;
    height: 38px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-delete:hover {
    background: var(--primary-green);
    color: white;
    transform: scale(1.1);
}

.btn-delete:active {
    transform: scale(0.95);
}

/* 訂單摘要 */
.order-summary {
    flex-shrink: 0;
    padding: 5px 20px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 15px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 3px 10px;
    background: var(--bg-gray);
    border-radius: 8px;
}

.summary-label {
    font-size: 9px;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    width: 100%;
    line-height: 1.1;
}

.summary-item.total {
    grid-column: 2;
    background: var(--primary-green);
}

.summary-item.total .summary-label {
    color: white;
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
}

.summary-item.total .summary-value {
    color: white;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
}

/* 收款金額區 */
.payment-area {
    flex-shrink: 0;
    padding: 12px 20px;
    background: var(--bg-white);
}

.received-input {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.received-input label {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.received-input input {
    flex: 1;
    max-width: 200px;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    text-align: right;
    cursor: pointer;
}

.received-input input:focus {
    outline: none;
    border-color: var(--primary-green);
}

/* 找零顯示 */
.change-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--primary-green-bg);
    border-radius: 6px;
    border: 1px solid var(--primary-green);
}

.change-display span:first-child {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.change-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-green);
}

/* 底部操作按鈕 */
.order-footer {
    flex-shrink: 0;
    padding: 12px 20px 20px 20px;
}

.btn-pay-now {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.btn-pay-now:hover {
    transform: translateY(-2px);
    background: var(--primary-green-hover);
    box-shadow: 0 8px 20px rgba(45, 216, 129, 0.3);
}

.btn-pay-now:active {
    transform: translateY(0);
}

.footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-print-only,
.btn-open-bill,
.btn-open-drawer {
    padding: 10px 12px;
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.btn-print-only:hover,
.btn-open-bill:hover,
.btn-open-drawer:hover {
    background: var(--bg-gray);
    border-color: var(--primary-green);
    color: var(--text-primary);
}

.btn-print-only {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: white;
}

.btn-print-only:hover {
    background: var(--primary-green-hover);
    border-color: var(--primary-green-hover);
    color: white;
}

.btn-open-drawer {
    background: var(--bg-white);
    border-color: var(--primary-green);
    color: var(--primary-green);
}

.btn-open-drawer:hover {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: white;
}

/* ===== 印表機設定區 ===== */
.printer-settings {
    background: var(--bg-white);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-top: 20px;
}

.printer-settings h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.settings-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.settings-row label {
    min-width: 120px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.settings-row input[type="text"],
.settings-row input[type="number"],
.settings-row select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    flex: 1;
}

.settings-row input[type="text"]:focus,
.settings-row input[type="number"]:focus,
.settings-row select:focus {
    outline: none;
    border-color: var(--primary-green);
}

.settings-row input[type="checkbox"] {
    margin-right: 8px;
}

/* ===== 產品管理介面 ===== */
.menu-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-settings {
    width: 40px;
    height: 40px;
    background: var(--bg-gray);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-settings:hover {
    background: var(--primary-green);
    border-color: var(--primary-green);
}

/* 彈出視窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 15px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: var(--text-primary);
}

.modal-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-refresh-db {
    padding: 8px 16px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-refresh-db:hover {
    background: var(--primary-green-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.btn-refresh-db:active {
    transform: translateY(0);
}

.btn-close-modal {
    width: 36px;
    height: 36px;
    background: var(--bg-gray);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-modal:hover {
    background: var(--primary-green);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 30px;
}

/* 同步資訊 */
.sync-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--primary-green-light);
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #1565C0;
    border-left: 4px solid #2196F3;
}

.sync-info .last-update {
    font-weight: 600;
    color: #0D47A1;
}

/* 分頁按鈕 */
.tab-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 管理區塊 */
.manager-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-gray);
    border-radius: 10px;
}

.manager-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

/* 表單 */
.form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    flex: 1;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-green);
}

.category-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.category-checkbox:hover {
    border-color: var(--primary-green);
    background: var(--primary-green-light);
}

.category-checkbox input[type="checkbox"],
.category-checkbox input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-green);
}

.category-checkbox input[type="checkbox"]:checked + span,
.category-checkbox input[type="radio"]:checked + span {
    color: var(--primary-green);
    font-weight: 600;
}

.category-checkbox span {
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.color-input {
    height: 45px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.btn-add-item {
    padding: 10px 20px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.btn-add-item:hover {
    background: var(--primary-green-hover);
}

.btn-save-product {
    padding: 12px 24px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-save-product:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-cancel {
    padding: 12px 24px;
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel:hover {
    background: var(--border-color);
    border-color: #bbb;
}

/* 項目列表 */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.item-list::-webkit-scrollbar {
    width: 6px;
}

.item-list::-webkit-scrollbar-track {
    background: var(--bg-gray);
    border-radius: 3px;
}

.item-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.category-item,
.product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--bg-white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.category-item:hover,
.product-item:hover {
    border-color: var(--primary-green);
}

.category-info,
.product-info {
    flex: 1;
}

.category-name,
.product-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.category-id,
.product-details {
    font-size: 13px;
    color: var(--text-light);
}

.item-actions {
    display: flex;
    gap: 8px;
}

.btn-edit,
.btn-delete-item {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-edit {
    background: var(--primary-green);
    color: white;
}

.btn-edit:hover {
    background: var(--primary-green);
}

.btn-delete-item {
    background: var(--primary-green);
    color: white;
}

.btn-delete-item:hover {
    background: var(--primary-green);
}

/* 產品列表網格 */
.product-list-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.product-item {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 12px;
    align-items: center;
}

.product-color-preview {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

/* ===== 訂單查詢樣式 ===== */

/* 統計卡片 */
.order-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--primary-green);
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stat-card:nth-child(2) {
    background: var(--bg-white);
}

.stat-card:nth-child(3) {
    background: var(--bg-white);
}

.stat-icon {
    font-size: 36px;
    opacity: 0.9;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

/* 訂單列表 */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.order-card {
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s;
}

.order-card:hover {
    border-color: var(--primary-green);
    box-shadow: 0 4px 12px rgba(245, 169, 98, 0.2);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-gray);
    cursor: pointer;
}

.order-header:hover {
    background: var(--bg-gray);
}

.order-info {
    flex: 1;
}

.order-number {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.order-time {
    font-size: 13px;
    color: var(--text-light);
}

.order-card .order-summary {
    display: flex;
    align-items: center;
    gap: 20px;
}

.order-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-green);
}

.order-items-count {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-white);
    padding: 5px 12px;
    border-radius: 20px;
}

.order-expand-icon {
    font-size: 20px;
    color: var(--text-light);
    transition: transform 0.3s;
}

.order-card.expanded .order-expand-icon {
    transform: rotate(180deg);
}

.order-details {
    display: none;
    padding: 20px 12px;
    border-top: 1px solid var(--border-color);
}

.order-card.expanded .order-details {
    display: block;
}

.order-items-table {
    width: 100%;
    margin-bottom: 15px;
}

.order-items-table th {
    text-align: left;
    padding: 10px;
    background: var(--bg-gray);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.order-items-table td {
    padding: 10px;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}

.order-items-table tr:last-child td {
    border-bottom: none;
}

.order-totals {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
    background: var(--bg-gray);
    border-radius: 8px;
}

.order-totals-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
}

.order-totals-row.total {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding-top: 8px;
    border-top: 2px solid var(--border-color);
}

/* ===== 印表機設定樣式 ===== */

/* 功能選項區域 */
.printer-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: var(--bg-white);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
}

.option-item:hover {
    border-color: var(--primary-green);
    background: var(--bg-gray);
}

.option-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-green);
}

.option-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.option-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.option-desc {
    font-size: 13px;
    color: var(--text-light);
}

/* 測試區域 */
.test-section {
    padding: 0;
}

.test-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-test-print,
.btn-test-drawer {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-test-print {
    background: var(--primary-green);
    color: white;
}

.btn-test-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-test-drawer {
    background: var(--bg-white);
    color: white;
}

.btn-test-drawer:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.btn-test-print:active,
.btn-test-drawer:active {
    transform: translateY(0);
}

/* ===== 響應式設計 ===== */
@media (max-width: 1400px) {
    .pos-layout {
        grid-template-columns: 1fr 380px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* 10吋平板優化 (1024px - 1280px) */
@media (max-width: 1280px) {
    .pos-layout {
        grid-template-columns: 1fr 350px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 12px;
    }

    .product-card {
        padding: 12px;
    }

    .product-name {
        font-size: 13px;
    }

    .product-price {
        font-size: 15px;
    }
}

/* 小平板橫屏 (834px - 1023px，不包含剛好 1024px) */
@media (max-width: 1023px) and (min-width: 835px) {
    .pos-layout {
        grid-template-columns: 1fr 320px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
        gap: 10px;
    }

    .product-card {
        padding: 10px;
    }
}

/* iPad Air 專用優化 (剛好 1024px) */
@media (min-width: 1024px) and (max-width: 1024px) {
    .pos-layout {
        grid-template-columns: 1fr 300px;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
        gap: 8px;
    }

    .product-card {
        padding: 10px;
    }

    .product-name {
        font-size: 13px;
    }

    .product-price {
        font-size: 15px;
    }
}

/* 小平板豎屏和以下 (< 834px) */
@media (max-width: 834px) {
    .pos-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .menu-section,
    .order-section {
        height: 100%;
    }

    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    }
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 15px;
    }

    .footer-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .menu-categories {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .category-btn {
        flex-shrink: 0;
    }

    /* .received-input, .btn-calc 樣式已停用（收款找零功能已移除） */
}

/* ===== 數字鍵盤 ===== */
.numpad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.numpad-container {
    background: var(--bg-white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
}

.numpad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: var(--primary-green);
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.numpad-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.numpad-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.numpad-display {
    padding: 30px 25px;
    font-size: 36px;
    font-weight: 700;
    text-align: right;
    color: var(--text-primary);
    background: var(--bg-gray);
    border-bottom: 2px solid var(--border-color);
    font-family: 'Courier New', monospace;
    min-height: 60px;
}

.numpad-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border-color);
    padding: 1px;
}

.numpad-btn {
    background: var(--bg-white);
    border: none;
    padding: 25px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.numpad-btn:hover {
    background: var(--bg-gray);
}

.numpad-btn:active {
    background: var(--border-color);
    transform: scale(0.95);
}

.numpad-btn.clear {
    background: var(--primary-green);
    color: white;
}

.numpad-btn.clear:hover {
    background: var(--primary-green);
}

.numpad-btn.confirm {
    background: var(--primary-green);
    color: white;
    grid-column: span 2;
}

.numpad-btn.confirm:hover {
    opacity: 0.9;
}

/* 讓收款金額input變成可點擊的樣式 */
#receivedAmount {
    cursor: pointer;
    background: var(--bg-white);
}

#receivedAmount:focus {
    outline: none;
    border-color: #667eea;
}

/* ===== 訂單/結帳模式切換 ===== */
.mode-switcher {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: var(--bg-gray);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.mode-btn {
    flex: 1;
    padding: 10px 20px;
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn:hover {
    background: var(--bg-gray);
    border-color: var(--primary-green);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: var(--primary-green);
    border-color: var(--primary-green);
    color: white;
    box-shadow: 0 4px 12px rgba(45, 216, 129, 0.3);
}

.mode-btn.active:hover {
    background: var(--primary-green-hover);
    transform: translateY(-2px);
}

/* 訂單模式按鈕樣式 */
.btn-save-order {
    width: 100%;
    padding: 10px 18px;
    background: var(--primary-green);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(45, 216, 129, 0.3);
    margin-bottom: 10px;
}

.btn-save-order:hover {
    background: var(--primary-green-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(45, 216, 129, 0.4);
}

.btn-save-order:active {
    transform: translateY(0);
}

.btn-clear-cart {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-white);
    color: #e74c3c;
    border: 2px solid #e74c3c;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-clear-cart:hover {
    background: var(--primary-green);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-clear-cart:active {
    transform: translateY(0);
}

/* ===== 訂單資訊彈出視窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-container {
    background: var(--bg-white);
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-gray);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px 30px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-gray);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

.modal-body .form-group {
    margin-bottom: 20px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-body .form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modal-body .form-input,
.modal-body .form-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s;
    box-sizing: border-box;
}

.modal-body .form-input:focus,
.modal-body .form-textarea:focus {
    outline: none;
    border-color: var(--primary-green);
    background: var(--bg-gray);
}

.modal-body .form-textarea {
    resize: vertical;
    min-height: 70px;
}

.modal-body .form-input::placeholder,
.modal-body .form-textarea::placeholder {
    color: #bbb;
}

/* 付款狀態選項 */
.payment-status-options {
    display: flex;
    gap: 15px;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-gray);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.radio-option:hover {
    background: var(--bg-gray);
    border-color: var(--border-color);
}

.radio-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-option input[type="radio"]:checked ~ .radio-label {
    color: var(--primary-green);
    font-weight: 700;
}

.radio-option:has(input[type="radio"]:checked) {
    background: var(--primary-green-light);
    border-color: var(--primary-green);
    box-shadow: 0 2px 8px rgba(45, 216, 129, 0.2);
}

.radio-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-option input[type="radio"]:checked ~ .radio-label::before {
    content: '●';
    font-size: 18px;
    color: var(--primary-green);
    margin-right: 4px;
}

.radio-option input[type="radio"]:not(:checked) ~ .radio-label::before {
    content: '○';
    font-size: 18px;
    color: var(--border-color);
    margin-right: 4px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 30px;
    border-top: 2px solid var(--border-color);
    flex-shrink: 0;
}

.btn-modal-cancel,
.btn-modal-save {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-modal-cancel {
    background: var(--bg-gray);
    color: var(--text-secondary);
}

.btn-modal-cancel:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-modal-save {
    background: var(--primary-green);
    color: white;
}

.btn-modal-save:hover {
    transform: translateY(-2px);
    background: var(--primary-green-hover);
    box-shadow: 0 6px 20px rgba(45, 216, 129, 0.3);
}

.btn-modal-save:active {
    transform: translateY(0);
}

/* 響應式設計 */
@media (max-width: 600px) {
    .modal-container {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-footer {
        padding: 15px 20px;
    }
}

/* ===== 深色模式支援 ===== */

/* 深色模式下的卡片和容器 */
body.dark-mode .menu-section,
body.dark-mode .order-section,
body.dark-mode .menu-header,
body.dark-mode .order-header,
body.dark-mode .modal-content,
body.dark-mode .modal-container,
body.dark-mode .printer-settings,
body.dark-mode .order-card,
body.dark-mode .category-item,
body.dark-mode .product-item,
body.dark-mode .option-item,
body.dark-mode .numpad-container {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* 深色模式下的標題和主要文字 */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode .menu-header h2,
body.dark-mode .order-header h2,
body.dark-mode .modal-header h2,
body.dark-mode .product-name,
body.dark-mode .order-item-name {
    color: var(--text-primary);
}

/* 深色模式下的次要文字 */
body.dark-mode .product-price,
body.dark-mode .order-items-count,
body.dark-mode .option-description,
body.dark-mode small,
body.dark-mode .text-muted {
    color: var(--text-secondary);
}

/* 深色模式下的按鈕 */
body.dark-mode .btn-qty {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.dark-mode .btn-qty:hover {
    background: var(--bg-gray);
    border-color: var(--primary-green);
}

/* 深色模式下的卡片陰影和邊框 */
body.dark-mode .product-card,
body.dark-mode .order-card,
body.dark-mode .category-item,
body.dark-mode .product-item {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

body.dark-mode .product-card:hover,
body.dark-mode .order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-color: var(--primary-green);
}

/* 深色模式下的模態框 */
body.dark-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

body.dark-mode .modal-container {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* 深色模式下的輸入框 */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="tel"],
body.dark-mode input[type="email"],
body.dark-mode textarea,
body.dark-mode select,
body.dark-mode .form-input,
body.dark-mode .form-textarea,
body.dark-mode .filter-input,
body.dark-mode .filter-select {
    background: var(--bg-gray);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="number"]:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
    border-color: var(--primary-green);
    background: var(--bg-card);
}

body.dark-mode .category-checkbox {
    background: var(--bg-gray);
    border-color: var(--border-color);
}

body.dark-mode .category-checkbox:hover {
    background: var(--border-light);
    border-color: var(--primary-green);
}

body.dark-mode .category-checkbox span {
    color: var(--text-secondary);
}

body.dark-mode .category-checkbox input[type="checkbox"]:checked + span,
body.dark-mode .category-checkbox input[type="radio"]:checked + span {
    color: var(--primary-green);
}

/* 深色模式下的數字鍵盤 */
body.dark-mode .numpad-btn {
    background: var(--bg-card);
    color: var(--text-primary);
}

body.dark-mode .numpad-btn:hover {
    background: var(--bg-gray);
}

/* 深色模式下的訂單項目 */
body.dark-mode .order-item {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .order-item:hover {
    background: var(--border-light);
}

/* 深色模式下的空狀態 */
body.dark-mode .empty-order,
body.dark-mode .empty-state {
    color: var(--text-secondary);
}

/* 深色模式下的分隔線 */
body.dark-mode hr,
body.dark-mode .divider {
    border-color: var(--border-color);
}

/* 深色模式下的表格 */
body.dark-mode table {
    background: var(--bg-card);
    color: var(--text-primary);
}

body.dark-mode th {
    background: var(--bg-gray);
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

body.dark-mode td {
    border-color: var(--border-light);
}

body.dark-mode tr:hover {
    background: var(--border-light);
}

/* 深色模式下的訂單總計區塊 */
body.dark-mode .order-total-section,
body.dark-mode .total-section {
    background: var(--bg-card);
    border-color: var(--border-color);
}

/* 深色模式下的分類標籤 */
body.dark-mode .category-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

body.dark-mode .category-btn:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
    border-color: var(--primary-green);
}

body.dark-mode .category-btn.active {
    background: var(--primary-green);
    color: #FFFFFF;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

/* 深色模式下的捲軸 */
body.dark-mode ::-webkit-scrollbar {
    width: 10px;
    background: var(--bg-gray);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-green);
}

/* 深色模式下的訂單摘要 */
body.dark-mode .order-summary {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .summary-item {
    background: var(--bg-gray);
}

body.dark-mode .summary-item.total {
    background: var(--border-light);
    border: 1px solid var(--primary-green);
}

/* 深色模式下的付款區域 */
body.dark-mode .payment-area {
    background: var(--bg-card);
}

/* 深色模式下的產品網格底部 */
body.dark-mode .menu-content {
    background: var(--bg-card);
}

body.dark-mode .product-grid {
    background: var(--bg-card);
}

/* 深色模式下的圖片載入動畫 */
body.dark-mode .image-placeholder {
    background: linear-gradient(135deg, #1E242C 0%, #2D333B 100%);
}

body.dark-mode .loading-spinner {
    border-color: rgba(45, 216, 129, 0.2);
    border-top-color: var(--primary-green);
}

/* 深色模式下的訂單詳情總計 */
body.dark-mode .order-totals {
    background: var(--bg-card);
}

body.dark-mode .order-totals-row {
    border-color: var(--border-color);
}

/* 深色模式下的訂單列表區域 */
body.dark-mode .order-items {
    background: var(--bg-card);
}

body.dark-mode .order-section {
    background: var(--bg-card);
}

body.dark-mode .order-header {
    background: var(--bg-card);
    border-bottom-color: var(--border-color);
}

/* 深色模式下的訂單卡片 header */
body.dark-mode .order-card .order-header {
    background: var(--bg-gray);
}

body.dark-mode .order-card .order-header:hover {
    background: var(--border-light);
}

/* 深色模式下的訂單卡片背景 */
body.dark-mode .order-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .order-card:hover {
    border-color: var(--primary-green);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.2);
}

/* ===== 列印成功提示彈窗 ===== */
.success-modal-container {
    background: #FFFFFF;
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.success-modal-header {
    background: linear-gradient(135deg, #2DD881 0%, #25B86D 100%);
    color: white;
    padding: 30px 25px;
    text-align: center;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    margin: 0 auto 15px;
    border: 3px solid rgba(255, 255, 255, 0.5);
}

.success-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.success-modal-body {
    padding: 25px;
    background: #FFFFFF;
}

.success-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.info-label {
    font-size: 15px;
    color: #6B7280;
    font-weight: 500;
}

.info-value {
    font-size: 16px;
    color: #1F2937;
    font-weight: 600;
}

.info-value.highlight {
    font-size: 18px;
    color: #2DD881;
}

.info-value.highlight-green {
    font-size: 22px;
    color: #2DD881;
    font-weight: 700;
}

.success-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 15px 0;
}

.success-customer-info {
    margin-top: 10px;
    padding-top: 10px;
}

.success-modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px 25px;
    background: #F9FAFB;
    border-top: 1px solid #E5E7EB;
}

.btn-success-cancel,
.btn-success-confirm {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-success-cancel {
    background: #FFFFFF;
    color: #6B7280;
    border: 2px solid #E5E7EB;
}

.btn-success-cancel:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    transform: translateY(-2px);
}

.btn-success-confirm {
    background: #2DD881;
    color: white;
}

.btn-success-confirm:hover {
    background: #25B86D;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 216, 129, 0.3);
}

/* 深色模式支援 */
body.dark-mode .success-modal-container {
    background: var(--bg-card);
}

body.dark-mode .success-modal-body {
    background: var(--bg-card);
}

body.dark-mode .info-value {
    color: var(--text-primary);
}

body.dark-mode .success-modal-footer {
    background: var(--bg-gray);
    border-top-color: var(--border-color);
}

body.dark-mode .btn-success-cancel {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

body.dark-mode .btn-success-cancel:hover {
    background: var(--border-light);
}

body.dark-mode .success-divider {
    background: var(--border-color);
}

/* ===== 使用教學彈窗樣式 ===== */

/* 教學分頁按鈕 */
.tutorial-tabs {
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.tutorial-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.tutorial-tab:hover {
    color: var(--primary-green);
    background: rgba(45, 216, 129, 0.1);
}

.tutorial-tab.active {
    color: var(--primary-green);
    border-bottom-color: var(--primary-green);
    background: rgba(45, 216, 129, 0.1);
}

/* 教學內容 */
.tutorial-content {
    -webkit-overflow-scrolling: touch;
}

.tutorial-content::-webkit-scrollbar {
    width: 8px;
}

.tutorial-content::-webkit-scrollbar-track {
    background: var(--bg-gray);
}

.tutorial-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.tutorial-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.tutorial-section {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tutorial-section h2 {
    font-size: 24px;
    font-weight: 700;
}

.tutorial-item {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-gray);
    border-radius: 10px;
    border-left: 4px solid var(--primary-green);
}

.tutorial-item:last-child {
    margin-bottom: 0;
}

.tutorial-item h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px 0;
}

.tutorial-item p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
    margin: 8px 0;
}

.tutorial-item p:first-of-type {
    margin-top: 0;
}

.tutorial-item p:last-child {
    margin-bottom: 0;
}

.tutorial-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* 深色模式 - 教學彈窗 */
body.dark-mode .tutorial-tab {
    color: var(--text-secondary);
}

body.dark-mode .tutorial-tab:hover {
    color: var(--primary-green);
    background: rgba(45, 216, 129, 0.15);
}

body.dark-mode .tutorial-tab.active {
    color: var(--primary-green);
    background: rgba(45, 216, 129, 0.15);
}

body.dark-mode .tutorial-item {
    background: var(--bg-card);
    border-left-color: var(--primary-green);
}

body.dark-mode .tutorial-item h3 {
    color: var(--text-primary);
}

body.dark-mode .tutorial-item p {
    color: var(--text-secondary);
}

body.dark-mode .tutorial-item strong {
    color: var(--text-primary);
}

/* ===== 字體大小模式 ===== */

/* 小字體模式 */
body.font-size-small {
    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-base: 13px;
    --font-size-md: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 18px;
    --font-size-2xl: 20px;
    --font-size-3xl: 24px;
    --font-size-4xl: 28px;
}

/* 中字體模式（預設，已在 :root 定義） */
body.font-size-medium {
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 15px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 28px;
    --font-size-4xl: 32px;
}

/* 大字體模式 */
body.font-size-large {
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 17px;
    --font-size-md: 18px;
    --font-size-lg: 20px;
    --font-size-xl: 22px;
    --font-size-2xl: 28px;
    --font-size-3xl: 32px;
    --font-size-4xl: 36px;
}

/* 套用字體大小到各元素 */
body {
    font-size: var(--font-size-base);
}

/* 商品名稱 */
.product-name {
    font-size: var(--font-size-base) !important;
}

/* 商品價格 */
.product-price {
    font-size: var(--font-size-lg) !important;
}

/* 分類按鈕 */
.category-btn {
    font-size: var(--font-size-sm) !important;
}

/* 訂單項目 */
.order-item-name {
    font-size: var(--font-size-base) !important;
}

.order-item-price {
    font-size: var(--font-size-md) !important;
}

/* 金額顯示 */
.summary-label {
    font-size: var(--font-size-md) !important;
}

.summary-value {
    font-size: var(--font-size-lg) !important;
}

#total {
    font-size: var(--font-size-2xl) !important;
}

/* 按鈕文字 */
.btn-pay-now,
.btn-save-order {
    font-size: var(--font-size-md) !important;
}

/* 表單標籤 */
label {
    font-size: var(--font-size-sm) !important;
}

/* 輸入框 */
input,
textarea,
select {
    font-size: var(--font-size-base) !important;
}

/* 標題 */
h1 {
    font-size: var(--font-size-3xl) !important;
}

h2 {
    font-size: var(--font-size-2xl) !important;
}

h3 {
    font-size: var(--font-size-xl) !important;
}

/* 模態框標題 */
.modal-header h2,
.modal-header h3 {
    font-size: var(--font-size-xl) !important;
}

/* 設定項目 */
.setting-title {
    font-size: var(--font-size-md) !important;
}

.setting-desc {
    font-size: var(--font-size-sm) !important;
}

/* 數字鍵盤 */
.numpad-display {
    font-size: var(--font-size-4xl) !important;
}

.numpad-btn {
    font-size: var(--font-size-xl) !important;
}

/* 今日訂單卡片 */
.tutorial-item h3 {
    font-size: var(--font-size-lg) !important;
}

.tutorial-item p {
    font-size: var(--font-size-base) !important;
}

/* 字體大小按鈕樣式 */
.font-size-btn {
    position: relative;
    border: 2px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
}

.font-size-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.font-size-btn.active {
    border: 2px solid var(--primary-green) !important;
    background: var(--primary-green) !important;
    color: white !important;
}

/* 深色模式下的字體大小按鈕 */
body.dark-mode .font-size-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

body.dark-mode .font-size-btn:hover {
    background: var(--border-light);
}

body.dark-mode .font-size-btn.active {
    background: var(--primary-green) !important;
    border: 2px solid var(--primary-green) !important;
    color: white !important;
}

/* ===== 載入畫面樣式 ===== */
#overlay {
    transition: opacity 0.3s ease;
}

#nowLoadingWrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#nowLoading {
    background: var(--bg-white);
    border-radius: 20px;
    padding: 50px 60px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-icon {
    color: var(--primary-green);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

#nowLoading h1 {
    font-size: var(--font-size-2xl);
    color: var(--text-primary);
    margin: 0;
    font-weight: 700;
}

#loadingStatus {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin: 0;
    min-height: 24px;
}

.progress-container {
    width: 100%;
    margin-top: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green) 0%, #009838 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-text {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#progressPercent {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--primary-green);
    font-family: 'Courier New', monospace;
}

/* 深色模式樣式 */
body.dark-mode #nowLoading {
    background: var(--bg-card);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

body.dark-mode .progress-bar {
    background: var(--border-color);
}

body.dark-mode .progress-fill {
    background: linear-gradient(90deg, var(--primary-green) 0%, #5AEE90 100%);
}

/* ===== 商品區載入動畫（小型居中顯示）===== */
.product-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.product-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.product-loading-content {
    text-align: center;
    padding: 30px 40px;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 280px;
}

.loading-icon-small {
    color: var(--primary-green);
    margin-bottom: 16px;
    animation: bounce 1.5s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.product-loading-content h3 {
    font-size: var(--font-size-base);
    color: var(--text-primary);
    margin: 0 0 16px 0;
    font-weight: 600;
}

.progress-container-small {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.progress-bar-small {
    width: 200px;
    height: 6px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill-small {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-green) 0%, #009838 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill-small::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

.progress-percent-small {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--primary-green);
    font-family: 'Courier New', monospace;
}

/* 深色模式 */
body.dark-mode .product-loading-overlay {
    background: rgba(22, 27, 34, 0.95);
}

body.dark-mode .product-loading-content {
    background: var(--bg-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .progress-bar-small {
    background: var(--border-color);
}

body.dark-mode .progress-fill-small {
    background: linear-gradient(90deg, var(--primary-green) 0%, #5AEE90 100%);
}

/* ===== 掃描槍輸入框 ===== */
.barcode-scanner-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    transition: all 0.3s ease;
}

.barcode-scanner-container:focus-within {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(45, 216, 129, 0.1);
}

.barcode-scanner-container i.fa-barcode {
    color: var(--text-secondary);
    font-size: 18px;
}

.barcode-scanner-container:focus-within i.fa-barcode {
    color: var(--primary-green);
}

#barcodeInput {
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    width: 150px;
    font-family: 'Courier New', monospace;
}

#barcodeInput::placeholder {
    color: var(--text-light);
}

.scanner-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scanner-status.ready {
    opacity: 0.5;
    color: var(--primary-green);
}

.scanner-status.scanning {
    opacity: 1;
    color: var(--primary-green);
}

.scanner-status.success {
    opacity: 1;
    color: #4CAF50;
    animation: scaleIn 0.3s ease;
}

.scanner-status.error {
    opacity: 1;
    color: #f44336;
    animation: shake 0.5s ease;
}

@keyframes scaleIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* 深色模式 */
body.dark-mode .barcode-scanner-container {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .barcode-scanner-container:focus-within {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

body.dark-mode #barcodeInput {
    color: var(--text-primary);
}

body.dark-mode #barcodeInput::placeholder {
    color: var(--text-light);
}
