/* =============================================
   輕鬆點餐飲管理 - 全域樣式
   主要優化目標：10吋平板 (1280×800, 1024×768)
   響應式支援：手機 768px 以下
   ============================================= */

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 70px; /* 稍微增加高度，讓標題與圖示更清晰 */
    --sidebar-width: 220px;
    --cart-width: 320px;
}

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

html {
    font-size: 16px; /* 提升基準字型 */
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.6;
    /* 觸控裝置順暢滑動 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 滾軸樣式 */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

/* =====================
   Layout
   ===================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* =====================
   Header — 固定在頂部
   ===================== */
header {
    min-height: var(--header-height);
    padding: 0 1.5rem;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
    flex-wrap: wrap;
}

/* =====================
   漢堡選單按鈕 (手機用)
   ===================== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.5rem;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 200;
}
.menu-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition);
    padding: 0.6rem 1rem;
    border-radius: 0.6rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px; /* 增加圖示與文字間距 */
}

nav a i {
    font-size: 1.05rem;
    color: inherit;
    opacity: 0.85;
}

nav a:hover, nav a.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

/* 針對 10 吋平板 (1280px) 的導覽列優化：防止右上角按鈕被截斷 */
@media (max-width: 1300px) {
    header {
        padding: 0 0.75rem;
    }
    .logo {
        font-size: 1.25rem;
        margin-right: 0.5rem;
        white-space: nowrap;
    }
    #main-nav {
        gap: 0.5rem !important;
    }
    #admin-nav {
        gap: 0.15rem !important;
    }
    #admin-nav a {
        padding: 0.5rem 0.6rem;
        font-size: 0.88rem;
        gap: 4px;
    }
    #admin-nav a i {
        font-size: 0.95rem;
    }
    /* 在平板上隱藏部分次要連結的文字，僅保留圖示 */
    #admin-nav li:nth-child(n+7) a span, 
    .quick-nav-text {
        display: none;
    }
    .quick-nav-area {
        gap: 0.4rem !important;
        padding-left: 0.5rem !important;
    }
    .quick-nav-area .add-btn, .quick-nav-area .checkout-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
}

/* =====================
   Hero (首頁)
   ===================== */
.hero {
    padding: 3rem 1.5rem;
    text-align: center;
    background: radial-gradient(circle at top, rgba(99, 102, 241, 0.12) 0%, transparent 65%);
}

.hero h1 {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

/* =====================
   點餐介面 (order.html)
   以 10 吋平板 1280px 為主
   ===================== */
.order-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--cart-width);
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* 分類側欄 */
.categories-sidebar {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
}

.category-btn {
    padding: 0.85rem 1rem; /* 增加高度更適合觸控 */
    border: none;
    background: transparent;
    color: var(--text-muted);
    text-align: center;
    border-radius: 0.75rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: var(--transition);
    white-space: nowrap;
    width: 100%;
}

.category-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.category-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

/* 產品清單 */
.products-container {
    overflow-y: auto;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1rem;
    padding-right: 0.25rem;
}

.product-card {
    background: var(--bg-card);
    border-radius: 0.875rem;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.product-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.15);
}

.product-img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: #2d3748;
}

.product-info {
    padding: 0.75rem;
}

.product-name {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    line-height: 1.3;
}

.product-price {
    color: var(--accent-color);
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
}

.add-btn {
    width: 100%;
    padding: 0.85rem 1.25rem;
    border-radius: 0.75rem;
    border: none;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.add-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* 收據模態框動作按鈕 - 統一圖示置頂樣式 */
.btn-grid-action {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.2rem 0.5rem;
    font-size: 0.95rem;
    gap: 8px;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-color);
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
}

.btn-grid-action i {
    font-size: 1.4rem;
}

.btn-grid-action:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.25);
}

/* 購物車面板 */
.cart-panel {
    background: var(--bg-card);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;
}

.cart-header {
    font-size: 1.1rem;
    font-weight: 700;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* 讓 flex 能正確收縮 */
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 0.5rem;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-info h4 {
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255,255,255,0.03);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.qty-btn:hover { background: var(--primary-color); border-color: var(--primary-color); }

.cart-footer {
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.checkout-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 0.75rem;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
    transition: var(--transition);
}

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

/* =====================
   Modal
   ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.modal-content {
    background: var(--bg-card);
    padding: 1.75rem;
    border-radius: 1.25rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* 產品選項樣式 */
.options-group {
    margin-bottom: 1.5rem;
}

.options-group-title {
    font-weight: 700;
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-main);
    font-size: 1.1rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 0.25rem;
}

.option-item {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    user-select: none;
}

.option-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.option-item input {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.option-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
}

.option-price {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.9rem;
}


.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    color: var(--text-muted);
    font-size: 1.05rem;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 1rem 1.25rem; /* 增加點擊範圍 */
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* =====================
   Animations
   ===================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.35s ease-out forwards;
}

/* =====================
   後台管理
   ===================== */
.admin-container {
    padding: 1.25rem 1.5rem;
    max-width: 1300px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 0.875rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.admin-card {
    background: var(--bg-card);
    border-radius: 0.875rem;
    padding: 1.25rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 1.1rem;
    vertical-align: middle;
}

tr:hover td { background: rgba(255,255,255,0.015); }

.action-btn {
    padding: 0.6rem 1.2rem; /* 加大觸控區域 */
    border-radius: 0.6rem;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    margin-right: 0.6rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn:hover { opacity: 0.9; transform: translateY(-1px); scale: 1.02; }
.edit-btn { background: var(--primary-color); color: white; }
.delete-btn { background: var(--danger-color); color: white; }

/* =====================
   響應式斷點
   ===================== */

/* 10 吋平板橫式 (1024px) — 側欄略縮 */
@media (max-width: 1100px) {
    :root {
        --sidebar-width: 160px;
        --cart-width: 280px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .dashboard-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 10 吋平板直式 (768px) — 切為垂直布局 + 底部收納購物車 */
@media (max-width: 900px) {
    header {
        padding: 0 1rem;
    }

    .logo { font-size: 1.1rem; }
    nav a { padding: 0.4rem 0.65rem; font-size: 0.82rem; }

    .order-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
        min-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    /* 分類改為橫向捲動列 */
    .categories-sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        height: auto;
        min-height: unset;
        padding: 0.65rem;
        gap: 0.4rem;
        border-radius: 0.75rem;
    }

    .category-btn {
        flex-shrink: 0;
        width: auto;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .products-container {
        overflow-y: visible;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    /* 購物車固定在底部 */
    .cart-panel {
        position: sticky;
        bottom: 0;
        border-radius: 1rem 1rem 0 0;
        max-height: 320px;
        z-index: 50;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    }

    .dashboard-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
}

/* =====================
   手機版 (768px 以下) — 漢堡選單 + RWD 修正
   ===================== */
@media (max-width: 768px) {
    /* 顯示漢堡選單按鈕 */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* header 改為固定高度，不要因為 wrap 而撐高 */
    header {
        padding: 0 0.75rem;
        min-height: var(--header-height);
        flex-wrap: nowrap;
        position: sticky;
        top: 0;
    }

    .logo {
        font-size: 1rem;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* nav 預設隱藏，展開時變全寬下拉 */
    header nav {
        display: none !important;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        height: calc(100vh - var(--header-height));
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        z-index: 1500;
        flex-direction: column;
        padding: 1.5rem 1rem;
        overflow-y: auto;
        animation: navSlideDown 0.25s ease-out;
        width: 100%;
    }

    header nav.nav-open {
        display: flex !important;
    }

    @keyframes navSlideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    /* 導航連結改為垂直排列 */
    header nav ul {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5rem;
        width: 100%;
        overflow: visible;
        padding: 0;
        margin: 0;
    }

    header nav ul li {
        width: 100%;
    }

    header nav a {
        display: block;
        padding: 0.85rem 1rem;
        font-size: 1rem;
        border-radius: 0.75rem;
        border: 1px solid rgba(255,255,255,0.05);
        text-align: left;
    }

    header nav a:hover,
    header nav a.active {
        background: rgba(99, 102, 241, 0.15);
        border-color: rgba(99, 102, 241, 0.3);
    }

    /* 後台頁面的右側按鈕群（前台首頁/點餐/結帳/登出）也垂直排列 */
    header nav > div {
        flex-direction: column !important;
        gap: 0.5rem !important;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    header nav > div a,
    header nav > div button {
        width: 100% !important;
        text-align: center;
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem !important;
        border-radius: 0.75rem;
    }
}

/* 手機 (600px 以下) — 額外精細調整 */
@media (max-width: 600px) {
    html { font-size: 14px; }

    .order-layout { padding: 0.5rem; gap: 0.5rem; }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }

    .product-img { height: 100px; }

    /* =====================
       Modal 手機版 — 置中顯示修正
       ===================== */
    .modal-overlay {
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }

    .modal-content {
        position: relative;
        bottom: auto;
        margin: 0 auto;
        padding: 1.25rem;
        border-radius: 1rem;
        max-height: 90vh;
        max-width: 100%;
        width: 100%;
    }

    .options-group-title {
        font-size: 1rem;
    }

    .option-item {
        padding: 0.65rem 0.75rem;
        gap: 10px;
    }

    .option-name {
        font-size: 0.95rem;
    }

    .modal-footer-btns {
        flex-direction: row !important;
    }

    .dashboard-stats {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .admin-container { padding: 0.75rem; }

    /* 縮小 table 字體 */
    th, td { padding: 0.6rem 0.65rem; font-size: 0.82rem; }
}

