/* ============================================================
   萤火虫智能点餐系统 - 全局样式
   苹果极简风 | 萤火虫云服务
   ============================================================ */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #fafafa;
    --color-primary: #009fff;
    --color-secondary: #ff9500;
    --color-danger: #f23030;          /* 红色：极少使用（售罄/删除/退款/反结账） */
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #86868b;
    --border-color: #e5e5e5;
    --border-light: #f0f0f2;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: all 0.2s ease;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; transition: var(--transition); }
a:hover { opacity: 0.8; }

/* ============================================================
   导航栏
   ============================================================ */
.navbar {
    background: rgba(255,255,255,0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.navbar-brand img { height: 28px; width: auto; }

.navbar-separator { color: var(--text-tertiary); font-weight: 300; margin: 0 2px; }
.navbar-restaurant { color: var(--text-primary); font-weight: 500; font-size: 15px; }
.navbar-expire { font-size: 12px; padding: 2px 8px; border-radius: 10px; font-weight: 500; white-space: nowrap; }
.navbar-expire-normal { background: #e8f5e9; color: #2e7d32; }
.navbar-expire-info { background: #e3f2fd; color: #1565c0; }
.navbar-expire-warning { background: #fff3e0; color: #e65100; }
.navbar-expire-expired { background: #ffebee; color: #c62828; }

.navbar-bell {
    position: relative;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all .2s;
}
.navbar-bell:hover { color: var(--color-primary); background: #f0f9ff; }
.bell-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0 4px;
}

/* 公告弹窗 */
.ann-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ann-modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.ann-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}
.ann-modal-header h3 { font-size: 18px; margin: 0; }
.ann-modal-close {
    border: none; background: none; font-size: 24px;
    color: var(--text-tertiary); cursor: pointer; line-height: 1;
}
.ann-modal-body { overflow-y: auto; padding: 16px 20px; }
.ann-card {
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    margin-bottom: 12px;
    transition: all .2s;
}
.ann-card:not(.ann-read) {
    border-color: var(--color-primary);
    background: #f0f9ff;
}
.ann-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ann-type {
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 500;
}
.ann-time { font-size: 12px; color: var(--text-tertiary); margin-left: auto; }
.ann-unread-dot {
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 6px;
}
.ann-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.ann-content { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

.navbar-nav {
    display: flex;
    gap: 4px;
    list-style: none;
}

.navbar-nav a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
}

.navbar-nav a:hover, .navbar-nav a.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    opacity: 1;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.navbar-user .role-badge {
    background: var(--color-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* 汉堡菜单按钮（移动端） */
.navbar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
}
.navbar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: var(--transition);
}

/* ============================================================
   布局
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.container-fluid { padding: 24px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================================
   卡片
   ============================================================ */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
}

/* ============================================================
   统计卡片
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-value.primary { color: var(--color-primary); }

/* ============================================================
   按钮
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    gap: 6px;
}

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: #0078d4; opacity: 1; }

.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-light); }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-secondary); }

.btn-danger { background: #f23030; color: #fff; }
.btn-danger:hover { background: #d42828; }

.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; }

/* ============================================================
   表格
   ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table tr:hover td { background: var(--bg-tertiary); }

.table-actions { display: flex; gap: 8px; }

/* ============================================================
   表单
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-help {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0,159,255,0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ============================================================
   徽章/标签
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-warning { background: #fff3cd; color: #856404; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: var(--bg-secondary); color: var(--text-secondary); }

/* ============================================================
   弹窗
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

/* ============================================================
   消息提示
   ============================================================ */
.flash {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.flash-success { background: #d4edda; color: #155724; }
.flash-error { background: #f8d7da; color: #721c24; }

/* ============================================================
   页脚品牌
   ============================================================ */
.footer-brand {
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary);
    font-size: 13px;
}

.footer-brand img { height: 20px; vertical-align: middle; margin: 0 4px; }

/* ============================================================
   H5 手机端样式
   ============================================================ */
.h5-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-secondary);
}

.h5-header {
    background: var(--bg-primary);
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
}

.h5-header .restaurant-name {
    font-size: 18px;
    font-weight: 600;
}

.h5-header .table-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.h5-search {
    padding: 12px 16px;
    background: var(--bg-primary);
}

.h5-search input {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: 20px;
    background: var(--bg-secondary);
    font-size: 15px;
    font-family: inherit;
}

.h5-categories {
    display: flex;
    gap: 0;
    overflow-x: auto;
    background: var(--bg-primary);
    padding: 0 16px;
    border-bottom: 1px solid var(--border-light);
    -webkit-overflow-scrolling: touch;
}

.h5-categories a {
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.h5-categories a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.h5-dish-list {
    padding: 12px 16px;
}

.h5-dish-card {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.h5-dish-card .dish-img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    flex-shrink: 0;
    object-fit: cover;
}

.h5-dish-card .dish-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.h5-dish-card .dish-name {
    font-size: 15px;
    font-weight: 600;
}

.h5-dish-card .dish-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.h5-dish-card .dish-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.h5-dish-card .dish-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
}

.h5-dish-card .sold-out {
    color: var(--text-tertiary);
    text-decoration: line-through;
}

.h5-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.h5-cart-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--text-primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 60;
}

.h5-cart-bar .cart-total {
    font-size: 20px;
    font-weight: 700;
}

.h5-cart-bar .cart-count {
    background: var(--color-primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.h5-submit-btn {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 8px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ============================================================
   前台工作台
   ============================================================ */
.order-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-primary);
}

.order-card.confirmed { border-left-color: var(--color-secondary); }
.order-card.paid { border-left-color: #34c759; }

.order-card .order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.order-card .order-no {
    font-weight: 600;
    font-size: 15px;
}

.order-card .order-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.order-card .order-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.order-card .order-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ============================================================
   点单界面
   ============================================================ */
.ordering-layout {
    display: grid;
    grid-template-columns: 200px 1fr 320px;
    gap: 16px;
    height: calc(100vh - 100px);
}

.cat-sidebar {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 12px;
    overflow-y: auto;
}

.cat-sidebar a {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.cat-sidebar a.active {
    background: var(--color-primary);
    color: #fff;
}

.dish-grid {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 16px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.dish-item {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.dish-item:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }

.dish-item .dish-img {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    object-fit: cover;
    margin-bottom: 8px;
}

.dish-item .dish-name { font-size: 14px; font-weight: 500; }
.dish-item .dish-price { font-size: 14px; color: var(--color-primary); font-weight: 600; margin-top: 4px; }

.cart-panel {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.cart-panel .cart-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}

/* ============================================================
   响应式
   ============================================================ */

/* 平板 */
@media (max-width: 1024px) {
    .navbar { padding: 0 16px; }
    .navbar-brand span { font-size: 15px; }
    .navbar-nav a { padding: 6px 10px; font-size: 13px; }
    .container { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 手机 */
@media (max-width: 768px) {
    /* 导航栏 */
    .navbar {
        padding: 0 12px;
        height: 48px;
        flex-wrap: wrap;
    }
    .navbar-brand span { font-size: 14px; }
    .navbar-brand img { height: 22px; }
    .navbar-restaurant { font-size: 13px; }
    .navbar-expire { font-size: 11px; padding: 1px 6px; }
    .navbar-separator { display: none; }
    .navbar-bell { padding: 4px; }
    .navbar-toggle { display: flex; }
    .navbar-nav {
        display: none;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: #fff;
        border-bottom: 1px solid var(--border-color);
        padding: 8px 12px;
        gap: 2px;
        box-shadow: var(--shadow-md);
        z-index: 99;
    }
    .navbar-nav.nav-open { display: flex; }
    .navbar-nav a { padding: 12px 14px; border-radius: 8px; font-size: 15px; }
    .navbar-user { gap: 8px; font-size: 13px; }
    .navbar-user .role-badge { font-size: 11px; padding: 1px 6px; }
    .navbar-user span:not(.role-badge) { display: none; }
    .navbar-user span.role-badge + span { display: inline; font-size: 13px; }
    .navbar-user a[href*="change_password"] { display: none; }
    .navbar-user a { font-size: 12px; }

    /* 布局 */
    .container { padding: 12px; }
    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-title { font-size: 20px; }

    /* 统计卡片 */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 22px; }

    /* 卡片 */
    .card { padding: 14px; margin-bottom: 12px; }

    /* 表格横向滚动 */
    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .table th, .table td { padding: 10px 12px; }

    /* 表单 */
    .form-input, .form-select, .form-textarea { font-size: 16px; } /* 防止 iOS 缩放 */
    .btn { font-size: 15px; padding: 10px 16px; }
    .btn-sm { font-size: 13px; padding: 6px 12px; }

    /* 弹窗 */
    .modal-overlay { padding: 0; }
    .modal {
        width: 100%;
        max-width: none;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding: 16px;
    }
    .modal-title { font-size: 17px; margin-bottom: 14px; }
    .modal-actions { flex-direction: column; gap: 8px; }
    .modal-actions .btn { width: 100%; }

    /* 页脚 */
    .footer-brand { padding: 16px; font-size: 12px; }

    /* 点单布局（老版 ordering-layout） */
    .ordering-layout { grid-template-columns: 1fr; height: auto; gap: 12px; }
}

/* 小屏手机 */
@media (max-width: 380px) {
    .stats-grid { grid-template-columns: 1fr; }
    .navbar-brand span { font-size: 13px; }
}

