/* ============================================================
   米拉瓦餐厅 - 主样式
   ============================================================ */

:root {
    --primary: #FF6B00;
    --primary-light: #FFF3E8;
    --primary-dark: #E55D00;
    --red: #FF4D4F;
    --text: #1A1A1A;
    --text-secondary: #666;
    --text-light: #999;
    --bg: #F5F5F5;
    --white: #FFFFFF;
    --border: #F0F0F0;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ============================================================
   Hero Banner
   ============================================================ */
.hero-banner {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: linear-gradient(135deg, #FF6B00 0%, #FF8F3C 50%, #FFB978 100%);
    position: relative;
}
.hero-banner::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20%;
    background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.3));
    pointer-events: none;
}
.hero-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.hero-banner.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-placeholder-text {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ============================================================
   Shop Info Bar
   ============================================================ */
.shop-info-bar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.3);
    gap: 12px;
    border-radius: 16px 16px 0 0;
    margin: -16px 0 0 0;
    position: relative;
    z-index: 2;
}
.shop-logo-wrap { flex-shrink: 0; }
.shop-logo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}
.shop-logo-placeholder {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.shop-name-group { flex: 1; min-width: 0; }
.shop-name { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.3; }
.shop-subtitle { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.admin-entry {
    background: var(--primary);
    color: #fff;
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 12px;
    text-decoration: none;
    flex-shrink: 0;
    font-weight: 500;
}

.tablet-toggle {
    background: #fff;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 5px 14px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    font-weight: 500;
}
.tablet-toggle:active { background: var(--primary-light); }
.tablet-toggle.active {
    background: var(--primary);
    color: #fff;
}

/* ============================================================
   Order Layout - Sidebar + Main
   ============================================================ */
.order-layout {
    display: flex;
    flex: 1;
    background: var(--white);
    min-height: 0;
}

/* ---------- Sidebar ---------- */
.order-sidebar {
    width: 80px;
    min-width: 80px;
    background: #F8F8F8;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}
.order-sidebar::-webkit-scrollbar { display: none; }

.sidebar-cat {
    padding: 10px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    line-height: 1.3;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.sidebar-cat .cat-icon {
    font-size: 20px;
    display: block;
    line-height: 1;
}
.sidebar-cat.active {
    background: #FFF;
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}
.sidebar-cat:active { background: #EEE; }
.sidebar-cat-parent::after {
    content: ' ▶';
    font-size: 8px;
    opacity: 0.5;
}
.sidebar-cat-parent.expanded::after {
    content: ' ▼';
}

.sidebar-subcat {
    padding: 10px 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    background: #ECECEC;
    display: none;
}
.sidebar-subcat.show { display: block; }
.sidebar-subcat.active {
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
    background: #FFF;
}
.sidebar-subcat:active { background: #E0E0E0; }

/* ---------- Main Dish Area ---------- */
.order-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dish-list { padding: 8px; }

.dish-row {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    cursor: pointer;
    gap: 10px;
    transition: transform 0.15s;
}
.dish-row:active { transform: scale(0.98); }

.dish-row-img {
    width: 72px;
    height: 72px;
    min-width: 72px;
    border-radius: 8px;
    overflow: hidden;
    background: #F5F5F5;
    flex-shrink: 0;
    position: relative;
}
.dish-row-img img { width: 100%; height: 100%; object-fit: cover; }
.dish-row-noimg {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #ddd;
}

/* 图片加载动画 */
.img-loading {
    position: relative;
    background: #F0F0F0 !important;
    overflow: hidden;
}
.img-loading::before {
    content: '0%';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #FF6B00;
    z-index: 2;
    background: rgba(240,240,240,0.8);
}
.img-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1;
    background: linear-gradient(90deg, transparent, rgba(255,107,0,0.08), transparent);
    animation: imgShimmer 1.5s infinite;
}
@keyframes imgShimmer {
    0% { left: -100%; width: 100%; }
    100% { left: 100%; width: 100%; }
}
.img-percent-10::before { content: '10%'; }
.img-percent-20::before { content: '20%'; }
.img-percent-30::before { content: '30%'; }
.img-percent-40::before { content: '40%'; }
.img-percent-50::before { content: '50%'; }
.img-percent-60::before { content: '60%'; }
.img-percent-70::before { content: '70%'; }
.img-percent-80::before { content: '80%'; }
.img-percent-90::before { content: '90%'; }
.img-percent-100::before { content: '✓'; color: #27AE60; }
.dish-row-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
}

.dish-row-info { flex: 1; min-width: 0; }
.dish-row-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    margin-bottom: 4px;
    word-break: break-all;
}
.dish-name-zh {
    font-size: 14px;
    color: var(--text);
    line-height: 1.4;
}
.dish-name-pt {
    font-size: 11px;
    color: var(--text-light);
    line-height: 1.4;
    font-weight: 400;
    font-style: italic;
    margin-top: 1px;
}
.dish-row-desc {
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.dish-row-price { font-size: 15px; font-weight: 700; color: var(--primary); }

.dish-row-add {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dish-row-add:active { background: var(--primary-dark); }

.loading-text { text-align: center; padding: 40px; color: var(--text-light); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.loading-text .loading-icon { font-size: 36px; }

/* ============================================================
   Error / Timeout Page
   ============================================================ */
.error-cover {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
}
.error-cover img {
    width: 160px;
    height: 160px;
    border-radius: 20px;
    object-fit: cover;
}
.error-cover .error-text {
    font-size: 16px;
    color: #666;
    text-align: center;
    line-height: 1.6;
}
.error-cover .error-countdown {
    font-size: 13px;
    color: var(--primary);
    margin-top: 4px;
}

/* ============================================================
   Cart Float Button
   ============================================================ */
.cart-float-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 10px 32px;
    border-radius: 28px;
    box-shadow: 0 4px 16px rgba(255,107,0,0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    z-index: 100;
}
.cart-float-icon { font-size: 20px; }
.cart-float-count {
    background: #fff;
    color: var(--primary);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

/* ============================================================
   Cart Panel
   ============================================================ */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.cart-overlay.open { display: flex; }

.cart-panel {
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.cart-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 600;
}
.cart-clear-btn { background: none; border: none; color: var(--text-light); font-size: 13px; cursor: pointer; }
.cart-panel-items { flex: 1; overflow-y: auto; padding: 12px 20px; }
.cart-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    gap: 10px;
}
.cart-item-name { flex: 1; font-size: 14px; }
.cart-item-price { color: var(--text-secondary); font-size: 13px; }
.cart-qty-btn {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cart-item-qty { min-width: 22px; text-align: center; font-weight: 600; }
.cart-empty-text { text-align: center; padding: 30px; color: var(--text-light); }
.cart-panel-extra { padding: 8px 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.cart-panel-extra input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    min-width: 0;
}
.cart-panel-extra input:first-child {
    width: 100%;
    border-color: var(--primary);
    color: var(--text);
}
.cart-panel-total {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    font-size: 18px;
    font-weight: 700;
    border-top: 2px solid var(--primary-light);
}
.cart-submit-btn {
    margin: 0 20px 20px;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.cart-submit-btn:active { background: var(--primary-dark); }

/* ============================================================
   Dish Detail Overlay
   ============================================================ */
.dish-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.dish-detail-overlay.open { display: flex; }

.dish-detail-card {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 360px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}
.detail-close {
    position: absolute;
    top: 8px; right: 8px;
    width: 30px; height: 30px;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    color: #fff;
    border: none;
    font-size: 16px;
    cursor: pointer;
    z-index: 1;
}
.detail-image { width: 100%; height: 200px; object-fit: cover; }
.detail-info { padding: 16px; }
.detail-info h3 { font-size: 20px; margin-bottom: 6px; }
.detail-info p { color: var(--text-secondary); font-size: 13px; margin-bottom: 12px; line-height: 1.6; }
.detail-price { font-size: 22px; font-weight: 700; color: var(--primary); }
.detail-add-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 0 16px 16px;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.detail-add-btn:active { background: var(--primary-dark); }

/* ============================================================
   Tablet Mode
   ============================================================ */
body.tablet-mode {
    max-width: 1024px;
    font-size: 16px;
}

body.tablet-mode .hero-banner {
    height: 260px;
}

body.tablet-mode .shop-logo {
    width: 64px;
    height: 64px;
}
body.tablet-mode .shop-name {
    font-size: 22px;
}
body.tablet-mode .shop-subtitle {
    font-size: 14px;
}

body.tablet-mode .order-sidebar {
    width: 110px;
    min-width: 110px;
}
body.tablet-mode .sidebar-cat {
    font-size: 13px;
    padding: 14px 8px;
}
body.tablet-mode .sidebar-subcat {
    font-size: 12px;
    padding: 12px 6px;
}

body.tablet-mode .dish-row {
    padding: 14px;
    gap: 14px;
    border-radius: 14px;
}
body.tablet-mode .dish-row-img {
    width: 100px;
    height: 100px;
    min-width: 100px;
}
body.tablet-mode .dish-row-name {
    font-size: 16px;
}
body.tablet-mode .dish-row-desc {
    font-size: 13px;
}
body.tablet-mode .dish-row-price {
    font-size: 18px;
}
body.tablet-mode .dish-row-add {
    width: 38px;
    height: 38px;
    min-width: 38px;
    font-size: 22px;
}

body.tablet-mode .cart-float-btn {
    font-size: 18px;
    padding: 12px 40px;
}
body.tablet-mode .cart-panel {
    max-width: 1024px;
}
body.tablet-mode .dish-detail-card {
    max-width: 500px;
}
body.tablet-mode .detail-image {
    height: 280px;
}
