/* 全局样式 */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --text-color: #333;
    --card-bg-color: #ffffff;
    --border-radius: 8px;
    --box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    background-image: linear-gradient(to bottom right, #f8f9fa, #e9ecef);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 新增：当弹出层打开时，禁止body滚动 */
body.modal-open {
    overflow: hidden;
}

.view {
    display: none; /* 默认隐藏 */
    padding: 15px;
}

/* 登录视图样式 */
#login-view {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 320px;
    padding: 20px;
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button:hover, .button:disabled {
    background-color: #0056b3;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.button.secondary {
    background-color: var(--secondary-color);
}
.button.secondary:hover {
    background-color: #5a6268;
}

.error-message {
    color: #dc3545;
    text-align: center;
    margin-top: 10px;
    min-height: 1em;
}

/* 主视图样式 */
#main-view {
    display: none; /* 由JS控制显示 */
    flex-direction: column;
    gap: 15px;
}

#main-header {
    display: flex;
    align-items: center;
    padding: 0 5px;
    color: #666;
    flex-grow: 1;
    justify-content: flex-end;
}

.menu-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card {
    background: var(--card-bg-color);
    border-radius: var(--border-radius);
    padding: 15px;
    box-shadow: var(--box-shadow);
    border: 1px solid #dee2e6;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

/* 菜单区域 */
#menu-section {
}

#menu-section #menu-title {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.25em;
}

#balance-section h3 {
    margin-top: 0;
}

/* 新菜单布局样式 */
#menu-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.meal-group {
    border-top: 2px solid var(--primary-color);
    padding-top: 10px;
}

.meal-title {
    font-size: 1.4em;
    font-weight: bold;
    margin: 0 0 15px 0;
}

.canteen-group {
    margin-bottom: 15px;
}

.canteen-title {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--secondary-color);
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.canteen-group ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.canteen-group li {
    padding: 2px 0;
    font-size: 0.9em;
}


/* 余额区域 */
#balance-section {
    text-align: center;
    padding: 10px;
}

#balance-section h3 {
    font-size: 1em;
    font-weight: normal;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#balance-section #balance {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary-color);
}

/* 付款码按钮 */
.show-qrcode-wrapper {
    padding: 15px 0;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#show-qrcode-button, #show-week-menu-button {
    flex: 1;
    max-width: 180px;
    padding: 15px;
    font-size: 16px;
}

/* 页脚 */
footer {
    text-align: center;
    margin-top: 10px;
}

#logout-button {
    max-width: 200px;
    padding: 8px 16px;
    font-size: 14px;
}

/* 遮罩层通用样式 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: pointer;
    transition: opacity 0.3s;
    padding: 20px;
    box-sizing: border-box;
}

.overlay.hidden {
    display: none;
}

.modal-content {
    cursor: default;
    width: 100%;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* 付款码弹出层 */
#qrcode-modal-content {
    background: transparent;
    box-shadow: none;
    width: 90vw; /* 使用视口宽度的90% */
    max-width: 500px; /* 最大宽度为500px */
    text-align: center;
}

#qrcode-modal-img {
    display: none;
    width: 100%;
    height: auto;
    background: white;
    padding: 15px;
    border-radius: var(--border-radius);
    box-sizing: border-box;
}

#qrcode-modal-text {
    color: white;
    font-size: 1.2em;
}

/* 本周菜单弹出层 */
#week-menu-modal-content {
    background-color: #f9f9f9; /* 修改：使用稍暗的白色背景以区分 */
    padding: 20px;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: var(--border-radius);
}

#week-menu-modal-content h2 {
    margin-top: 0;
    text-align: center;
    color: var(--primary-color);
    flex-shrink: 0;
}

.modal-content-scrollable {
    overflow-y: auto;
}

/* 新增：本周菜单垂直列表样式 */
.week-menu-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.week-menu-day-card {
    background-color: var(--card-bg-color);
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    padding: 15px;
}

.week-menu-day-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.week-menu-meal-section h4 {
    margin-top: 10px;
    margin-bottom: 8px;
    color: var(--secondary-color);
    font-size: 1em;
}

.week-menu-meal-section ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
}

.week-menu-meal-section li {
    padding: 3px 0;
}

/* 移除旧的表格样式 */
.week-menu-table { display: none; }