* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #d4af37;
    --primary-dark: #b8941f;
    --purple: #8b5cf6;
    --purple-dark: #7c3aed;
    --purple-light: #a78bfa;
    --bg: #f5f1e8;
    --bg-light: #fafafa;
    --card: #ffffff;
    --text: #333;
    --text-light: #666;
    --border: #e0dcc8;
    --success: #4caf50;
    --error: #f44336;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: 100px; /* 为底部导航栏留出空间 */
}

/* 顶部栏 */
.header {
    background: var(--purple-dark);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lantern-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo {
    font-size: 22px;
    font-weight: bold;
    margin: 0;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
    line-height: 1.2;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.3);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--error);
    color: white;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* 主内容区域 */
.main-content {
    padding: 12px;
    min-height: calc(100vh - 200px);
}

/* 欢迎卡片 */
.welcome-card {
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.welcome-greeting h2 {
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 8px;
}

.assistant-intro {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 16px;
}

.action-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.action-item:hover {
    background: var(--bg-light);
}

.action-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.action-text {
    font-size: 14px;
    color: var(--text);
}

.call-to-action {
    padding: 12px;
    background: var(--bg-light);
    border-radius: 8px;
    margin-bottom: 12px;
}

.call-to-action p {
    font-size: 14px;
    color: var(--text);
    margin: 0;
    text-align: center;
}

.voice-support-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    font-size: 12px;
    color: var(--text-light);
}

.lightbulb-icon {
    font-size: 16px;
}

/* 对话面板 */
.chat-panel {
    background: var(--card);
    margin: 12px 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 360px;
    max-height: 50vh;
    overflow: hidden;
}

.chat-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--purple-dark);
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.icon-btn-small {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.icon-btn-small:hover {
    background: rgba(255,255,255,0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #fafafa;
}

.message {
    margin-bottom: 10px;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-text {
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    display: inline-block;
    max-width: 80%;
    word-wrap: break-word;
}

.message.assistant .msg-text {
    background: white;
    border: 1px solid var(--border);
}

.message.user .msg-text {
    background: var(--purple);
    color: white;
    margin-left: auto;
    display: block;
    text-align: right;
}

.input-bar {
    padding: 10px;
    border-top: 1px solid var(--border);
    background: white;
    display: flex;
    gap: 8px;
    align-items: center;
}

.text-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    background: var(--bg-light);
}

.text-input:focus {
    border-color: var(--purple);
    background: white;
}

.btn-voice {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--purple);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.btn-voice:hover:not(:disabled):not(.listening) {
    background: var(--purple-dark);
    transform: scale(1.05);
}

.btn-voice:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-voice:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-voice.listening {
    animation: pulse 1.5s infinite;
    background: var(--error);
    border-color: var(--error);
    color: white;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(244, 67, 54, 0);
    }
}

/* 手机端优化 */
@media (max-width: 768px) {
    .btn-voice {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .btn-voice.listening {
        animation: pulseMobile 1.2s infinite;
    }
}

@keyframes pulseMobile {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.5);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
}

.btn-send {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--purple);
    color: white;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--purple-dark);
    transform: scale(1.05);
}

.btn-send span {
    line-height: 1;
}

.status-text {
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    min-height: 18px;
}

/* 周次选择 */
.week-selector {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.week-selector::-webkit-scrollbar {
    display: none;
}

.week-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--text);
}

.week-btn:hover {
    border-color: var(--purple);
    color: var(--purple);
}

.week-btn.active {
    background: var(--purple);
    border-color: var(--purple);
    color: white;
}

/* 菜单网格 */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 0 12px;
}

.menu-item {
    background: var(--card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.menu-img {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.menu-info {
    padding: 8px;
}

.menu-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
    min-height: 36px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.menu-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
}

.menu-tag {
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--purple);
    color: white;
}

.menu-tag.chef { background: #ff6b6b; }
.menu-tag.not-spicy { background: var(--success); }
.menu-tag.specialty { background: #2196f3; }

.menu-footer {
    display: flex;
    justify-content: center;
    margin-top: 6px;
}

.btn-add {
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-add:hover {
    background: var(--purple-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-add:active {
    transform: translateY(0);
}

/* 侧边栏 */
.sidebar {
    position: fixed;
    right: -100%;
    top: 0;
    width: 85%;
    max-width: 380px;
    height: 100vh;
    background: var(--card);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--purple-dark);
    color: white;
}

.sidebar-header h3 {
    font-size: 18px;
}

.cart-select-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--purple);
}

.selected-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--purple);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 14px;
}

.cart-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #fafafa;
    border-radius: 6px;
    margin-bottom: 8px;
    align-items: flex-start;
}

.cart-item-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
}

.cart-item-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--purple);
    margin: 0;
}

.cart-item-checkbox .checkbox-custom {
    display: none;
}

.cart-item-img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    flex-shrink: 0;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.cart-item-name {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}

.cart-item-week {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--purple);
    color: white;
    border-radius: 10px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-qty {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-qty:hover {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
    transform: scale(1.1);
}

.btn-qty:active {
    transform: scale(0.95);
}

.qty-num {
    font-size: 15px;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
    color: var(--text);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: white;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--purple);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--purple-dark);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.history-item {
    background: #fafafa;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid var(--purple);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.history-date {
    font-size: 13px;
    font-weight: 600;
}

.history-id {
    font-size: 11px;
    color: var(--text-light);
}

.history-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--success);
    color: white;
}

.history-items {
    font-size: 13px;
}

.history-item-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.history-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.history-total-items {
    font-size: 11px;
    color: var(--text-light);
}

.history-sub-orders-count {
    font-size: 11px;
    color: var(--purple-dark);
    margin-top: 4px;
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 8px;
    display: inline-block;
}

.history-sub-order {
    margin-top: 12px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.history-sub-order:first-child {
    margin-top: 8px;
}

.history-sub-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--purple);
}

.history-sub-order-week {
    font-size: 13px;
    font-weight: 600;
    color: var(--purple-dark);
    padding: 4px 10px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 12px;
    display: inline-block;
}

.history-sub-order-count {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

.history-sub-order-items {
    font-size: 13px;
    padding-top: 4px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--purple-dark);
    color: white;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--purple);
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-secondary {
    padding: 10px 20px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f5f5f5;
}

/* 遮罩 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 999;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 提示 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 用户相关样式 */
.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.auth-tab.active {
    color: var(--purple-dark);
    border-bottom-color: var(--purple-dark);
}

.auth-form {
    animation: fadeIn 0.3s;
}

.form-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
    padding: 4px 0;
}

.user-info {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.user-phone {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 12px;
}

.user-stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--purple-dark);
}

/* 响应式 */
/* 底部导航栏 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    border-radius: 8px;
    margin: 0 4px;
}

.nav-btn.active {
    background: var(--purple);
    color: white;
}

.nav-btn:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
}

.nav-text {
    font-size: 11px;
    line-height: 1;
}

.nav-btn .badge {
    position: absolute;
    top: 2px;
    right: 8px;
    background: var(--error);
    color: white;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.nav-btn.active .badge {
    background: white;
    color: var(--error);
}

@media (max-width: 480px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .chat-panel {
        height: 300px;
        max-height: 45vh;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .user-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .user-stats {
        justify-content: center;
    }
    
    .cart-item-name-row {
        flex-wrap: wrap;
    }
    
    .cart-item-week {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* 手机端历史订单优化 */
    .history-item {
        padding: 10px;
        margin-bottom: 8px;
    }
    
    .history-sub-order {
        padding: 8px;
        margin-top: 10px;
    }
    
    .history-sub-order-header {
        margin-bottom: 6px;
        padding-bottom: 6px;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .history-sub-order-week {
        font-size: 12px;
        padding: 3px 8px;
        flex: 1;
        min-width: fit-content;
    }
    
    .history-sub-order-count {
        font-size: 11px;
    }
    
    .history-sub-order-items {
        font-size: 12px;
    }
    
    .history-item-row {
        padding: 3px 0;
        font-size: 12px;
    }
    
    .history-sub-orders-count {
        font-size: 10px;
        margin-top: 4px;
    }
}