/* WCO 點餐前端 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:   #4a2c2a;
    --primary2:  #6b3a37;
    --accent:    #c8956c;
    --bg:        #f5f5f5;
    --card:      #ffffff;
    --text:      #1a1a1a;
    --muted:     #888;
    --border:    #e0d8d0;
    --radius:    10px;
    --shadow:    0 2px 10px rgba(0,0,0,.08);
    --mobile-bar: 64px;
}

body { background: var(--bg); font-family: -apple-system, 'Noto Sans TC', sans-serif; color: var(--text); }

/* ── Header ── */
.wco-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90;
}
.wco-cafe-name { font-size: 17px; font-weight: 700; }
.wco-table-badge {
    background: var(--primary); color: #fff;
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; font-weight: 600;
}

/* ── Two-column layout ── */
.wco-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    align-items: start;
}
@media (max-width: 900px) {
    .wco-layout { grid-template-columns: 1fr; }
    .wco-cart-col { display: none; }
    .wco-menu-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 搜尋 ── */
.wco-search-wrap { padding: 14px 20px 10px; background: var(--card); }
.wco-search-input {
    width: 100%; padding: 10px 16px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 14px; outline: none; background: #fafafa;
    transition: border-color .15s;
}
.wco-search-input:focus { border-color: var(--primary); }

/* ── 分類 ── */
.wco-cat-nav {
    display: flex; gap: 8px; padding: 10px 20px;
    overflow-x: auto; scrollbar-width: none;
    background: var(--card); border-bottom: 1px solid var(--border);
    position: sticky; top: 53px; z-index: 80;
}
.wco-cat-nav::-webkit-scrollbar { display: none; }
.wco-cat-btn {
    flex-shrink: 0; padding: 7px 18px; border-radius: 20px;
    border: 2px solid var(--border); background: transparent;
    color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
    white-space: nowrap;
}
.wco-cat-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 菜單區 ── */
.wco-menu-col { min-width: 0; }
#wco-menu-section { padding: 16px 20px 80px; }
.wco-cat-section { margin-bottom: 24px; }
.wco-cat-title {
    font-size: 15px; font-weight: 700; margin-bottom: 12px;
    padding-left: 10px; border-left: 4px solid var(--primary);
}
.wco-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.wco-loading { padding: 40px; text-align: center; color: var(--muted); }

.wco-item-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); cursor: pointer;
    transition: transform .12s, box-shadow .12s; overflow: hidden;
}
.wco-item-card:active { transform: scale(.97); }
.wco-item-img-wrap {
    width: 100%; aspect-ratio: 1; overflow: hidden;
    background: #f0ebe5; display: flex; align-items: center; justify-content: center;
}
.wco-item-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.wco-item-img-placeholder { display:flex; align-items:center; justify-content:center; color: #c8bdb5; }
.wco-item-info { padding: 10px 10px 12px; }
.wco-item-name { font-size: 14px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; }
.wco-item-price { font-size: 14px; font-weight: 700; color: var(--primary); }

/* 搜尋結果時用 list 樣式 */
.wco-search-results .wco-item-card {
    display: flex; align-items: center; gap: 12px;
    border-radius: var(--radius); padding: 10px; width: 100%;
}
.wco-search-results .wco-item-img-wrap { width: 64px; height: 64px; border-radius: 8px; flex-shrink: 0; aspect-ratio: auto; }
.wco-search-results .wco-menu-grid { grid-template-columns: 1fr; }

/* ── 購物車側邊欄（桌面）── */
.wco-cart-col {
    border-left: 1px solid var(--border);
    position: sticky; top: 53px;
    height: calc(100vh - 53px);
    overflow-y: auto;
}
.wco-cart-sidebar { padding: 20px; }
.wco-cart-heading { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.wco-cart-empty { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }

/* Cart item rows */
.wco-cart-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.wco-cart-row:last-child { border-bottom: none; }
.wco-cart-row-left { flex: 1; }
.wco-cart-row-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.wco-cart-row-sub { font-size: 12px; color: var(--muted); }
.wco-cart-row-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wco-cart-qty-ctrl { display: flex; align-items: center; gap: 6px; }
.wco-qty-sm { width: 22px; height: 22px; border: none; background: none; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 700; padding: 0; }
.wco-cart-row-price { font-size: 14px; font-weight: 700; min-width: 54px; text-align: right; }

.wco-cart-subtotal {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 0 12px; font-size: 15px; border-top: 1px solid var(--border); margin-top: 4px;
}
.wco-cart-subtotal strong { font-size: 18px; color: var(--primary); }

.wco-submit-btn {
    width: 100%; padding: 14px; background: var(--primary); color: #fff;
    border: none; border-radius: 8px; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: opacity .15s; margin-bottom: 16px;
}
.wco-submit-btn:disabled { opacity: .45; cursor: not-allowed; }
.wco-submit-btn:not(:disabled):active { opacity: .8; }

/* 點餐紀錄 */
.wco-record-heading { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 8px; }
.wco-record-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.wco-record-row:last-child { border-bottom: none; }
.wco-record-row-left { color: var(--muted); }
.wco-record-row-right { font-weight: 600; }
.wco-record-sub { font-size: 11px; color: var(--muted); }

/* ── 手機底部列 ── */
.wco-mobile-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--primary); color: #fff; z-index: 200;
    cursor: pointer; transition: opacity .15s;
}
.wco-mobile-bar-inner {
    max-width: 600px; margin: 0 auto;
    display: flex; align-items: center; gap: 10px; padding: 12px 20px;
}
.wco-mobile-badge {
    background: var(--accent); width: 24px; height: 24px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.wco-mobile-label { flex: 1; font-weight: 600; font-size: 15px; }
.wco-mobile-bar-inner strong { font-size: 16px; font-weight: 700; }

/* ── 手機購物車面板 ── */
.wco-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; }
.wco-mobile-cart {
    position: fixed; left: 0; right: 0; bottom: 0;
    max-height: 85vh; background: var(--card);
    border-radius: 20px 20px 0 0; z-index: 400;
    display: flex; flex-direction: column;
    animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.wco-mobile-cart-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.wco-mobile-cart-header h2 { font-size: 18px; font-weight: 700; }
.wco-close-btn { background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px; color: var(--muted); }
.wco-mobile-cart-body { flex: 1; overflow-y: auto; padding: 0 20px 20px; }

/* ── 品項 Modal ── */
.wco-modal {
    position: fixed; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, 94vw); background: var(--card);
    border-radius: 16px; padding: 28px 24px 24px; z-index: 500;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
@media (max-width: 600px) {
    .wco-modal {
        left: 0; right: 0; bottom: 0; top: auto;
        transform: none; width: 100%;
        border-radius: 20px 20px 0 0;
        animation: sheetUp .22s ease;
    }
}
.wco-modal-title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }
.wco-modal-label { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

.wco-temp-pills { display: flex; gap: 10px; margin-bottom: 18px; }
.wco-temp-pill {
    flex: 1; padding: 10px; border: 2px solid var(--border);
    border-radius: 8px; background: none; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: .15s; color: var(--text);
}
.wco-temp-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.wco-modal-qty-row {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.wco-qty-group { display: flex; align-items: center; gap: 14px; }
.wco-qty-circle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1.5px solid var(--primary); background: none; font-size: 18px;
    cursor: pointer; color: var(--primary); display: flex; align-items: center; justify-content: center;
    transition: .1s;
}
.wco-qty-circle:active { background: var(--primary); color: #fff; }
#wco-modal-qty { font-size: 20px; font-weight: 700; min-width: 24px; text-align: center; }
.wco-modal-price { font-size: 18px; font-weight: 700; color: var(--primary); margin-left: auto; }

.wco-modal-note {
    width: 100%; min-height: 80px; padding: 10px 12px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-size: 14px; resize: none; margin-bottom: 18px; outline: none;
    transition: border-color .15s;
}
.wco-modal-note:focus { border-color: var(--primary); }

.wco-modal-actions { display: flex; gap: 10px; }
.wco-btn-cancel {
    flex: 1; padding: 13px; border: 1.5px solid var(--border);
    border-radius: 8px; background: none; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.wco-btn-confirm {
    flex: 2; padding: 13px; border: none;
    border-radius: 8px; background: var(--primary); color: #fff;
    font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.wco-btn-confirm:active { opacity: .8; }

/* ── Toast ── */
.wco-toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: #1c1917; color: #fff; padding: 10px 22px;
    border-radius: 24px; font-size: 14px; font-weight: 600;
    z-index: 600; pointer-events: none; white-space: nowrap;
    animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity:0; transform: translateX(-50%) translateY(8px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

.wco-error { padding: 40px; text-align: center; color: #c62828; }
