/* 全局和基础样式 (无变化) */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
}

.app-wrapper {
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box; /* 确保padding不会导致宽度溢出 */
}

.container {
    width: 100%;
    max-width: 500px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background-color: #007bff;
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    margin: 0;
    font-size: 24px;
}

.tab-buttons {
    display: flex;
    justify-content: space-between; /* 改为两端对齐，让按钮充分利用空间 */
    flex-wrap: nowrap; /* 强制不换行 */
    margin-top: 15px;
    overflow-x: auto; /* 保险措施：如果按钮实在太多，也只会在这个区域内产生横向滚动条 */
    -webkit-overflow-scrolling: touch; /* 在iOS上提供更平滑的滚动体验 */
    padding-bottom: 5px; /* 为可能的滚动条留出一点空间 */
}

.tab-buttons button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    padding: 10px 8px; /* 减小了左右内边距 */
    cursor: pointer;
    font-size: 15px; /* 略微减小字体大小 */
    position: relative;
    transition: color 0.3s;
    flex-shrink: 0; /* 防止按钮被过度压缩 */
}

.tab-buttons button.active {
    color: white;
    font-weight: 600;
}

.tab-buttons button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
}

main {
    padding: 20px;
}

section {
    display: none;
}

section.active {
    display: block;
}

/* 表单样式 */
#checkin-form .date-display { text-align: center; margin-bottom: 25px; font-size: 16px; color: #555; }
.input-group, .checkbox-group { margin-bottom: 20px; }
.input-group label, .checkbox-group h3, .checkbox-group.single-checkbox label { display: block; margin-bottom: 8px; font-weight: 500; color: #333; }
.input-with-feedback { display: flex; align-items: center; }
.input-with-feedback input { flex-grow: 1; width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 16px; transition: border-color 0.3s, box-shadow 0.3s; }
.input-with-feedback input:focus { outline: none; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1); }
.emoji-feedback { font-size: 24px; margin-left: 10px; width: 30px; text-align: center; }
.checkbox-group h3 { display: inline-block; }
.checkbox-item { display: flex; align-items: center; margin-bottom: 10px; }
.checkbox-item input[type="checkbox"] { width: 1.3em; height: 1.3em; margin-right: 10px; cursor: pointer; }
.checkbox-item label { font-weight: 400; }
/* 新增样式，用于单行复选框 */
.checkbox-group.single-checkbox .checkbox-item { justify-content: space-between; }
.checkbox-group.single-checkbox label { margin-bottom: 0; }

.submit-btn { width: 100%; padding: 15px; background-color: #28a745; color: white; border: none; border-radius: 8px; font-size: 18px; font-weight: 600; cursor: pointer; transition: background-color 0.3s; }
.submit-btn:hover { background-color: #218838; }

/* 历史记录样式 */
#history-section { max-height: 60vh; overflow-y: auto; }
.history-header h2 { text-align: center; margin-top: 0; margin-bottom: 20px; }
.history-card { background-color: #f9f9f9; border: 1px solid #eee; border-radius: 12px; padding: 15px; margin-bottom: 15px; }
.history-date { font-weight: 600; font-size: 16px; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.history-label { color: #555; }
.history-value { font-weight: 500; }
.history-emoji { margin-left: 8px; }
.no-records { text-align: center; color: #888; padding: 20px; }

/* 日历样式 */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.calendar-header button { background: #f0f0f0; border: 1px solid #ddd; border-radius: 50%; width: 30px; height: 30px; cursor: pointer; }
#calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.calendar-grid-header { text-align: center; font-weight: 600; color: #888; padding-bottom: 10px; }
.day-cell { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 50px; border: 1px solid #f0f0f0; border-radius: 8px; font-size: 14px; }
.day-cell.empty { background-color: #fafafa; }
.day-cell .day-number { font-weight: 500; }
.day-cell .day-emoji { font-size: 20px; margin-top: 2px; }

/* 分析样式 */
.analysis-container { max-height: 60vh; overflow-y: auto; padding-right: 10px; }
.chart-container { margin-bottom: 30px; }
.chart-container h3 { text-align: center; margin-bottom: 15px; }

/* 通知和模态框样式 (无变化) */
.notification { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background-color: #dc3545; color: white; padding: 15px 25px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 1001; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s, bottom 0.3s; }
.notification.show { opacity: 1; visibility: visible; bottom: 30px; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background-color: #ffffff; padding: 30px 40px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); text-align: center; transform: scale(0.9); transition: transform 0.3s ease; }
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-content p { margin: 0 0 20px; font-size: 18px; color: #333; }
.modal-content button { background-color: #007bff; color: white; border: none; padding: 10px 25px; border-radius: 8px; cursor: pointer; font-size: 16px; transition: background-color 0.2s; }
.modal-content button:hover { background-color: #0056b3; }

/* 响应式设计 (无变化) */
@media (min-width: 768px) {
    .container { max-width: 720px; }
    header h1 { font-size: 28px; }
    .tab-buttons button { font-size: 18px; padding: 12px 25px; }
    main { padding: 30px; }
    .day-cell { height: 65px; }
    .day-cell .day-number { font-size: 16px; }
    .day-cell .day-emoji { font-size: 24px; }
    #history-section, .analysis-container { max-height: 70vh; }
}
/* --- 更新：可折叠历史记录项的样式 (V2) --- */

/* 1. <details> 容器的基本设置 (无变化) */
.history-item-details {
    padding: 5px 0;
}

/* 2. <summary> 是可点击的标题行 (无变化) */
.history-item-details summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    list-style: none;
}
.history-item-details summary::-webkit-details-marker {
    display: none;
}

/* 3. 新增：用于包裹“标签+箭头”的容器 */
.history-label-group {
    display: flex;
    align-items: center; /* 垂直居中对齐标签和箭头 */
    color: #555;
}

/* 4. 自定义箭头样式 (调整了边距) */
.details-arrow {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-left: 2px solid #888;
    border-bottom: 2px solid #888;
    transform: rotate(-45deg);
    transition: transform 0.3s ease;
    margin-left: 8px; /* 箭头和标签文字之间的距离 */
}

/* 5. 当 <details> 展开时，旋转箭头 (无变化) */
.history-item-details[open] > summary .details-arrow {
    transform: rotate(135deg);
}

/* 6. 展开后的内容区域样式 (无变化) */
.history-details-content {
    padding: 10px 15px;
    margin-top: 8px;
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    text-align: right;
}

/* --- 设置页面样式 --- */
#settings-section h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 30px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 12px;
}

.setting-label {
    font-size: 16px;
    font-weight: 500;
}

.settings-btn {
    padding: 8px 15px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

/* --- 开关(Toggle Switch)样式 --- */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #28a745; /* 开启时的颜色 */
}

input:disabled + .slider {
  background-color: #dc3545; /* 禁用时的颜色 */
  cursor: not-allowed;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* --- 喜庆弹窗样式 --- */
.modal-content.festive {
    padding: 40px 50px; /* 增加内边距，让弹窗更大 */
    max-width: 90%; /* 限制最大宽度 */
}

.modal-celebration {
    font-size: 48px; /* 超大号Emoji */
    margin-bottom: 15px;
    animation: tada 1.5s ease-in-out; /* 添加一个可爱的动画 */
}

.festive-btn {
    background-color: #ff4757; /* 使用一个更喜庆的颜色 */
    font-weight: 600;
    padding: 12px 30px !important; /* 强制使用更大的padding */
    transform: scale(1.0);
    transition: background-color 0.3s, transform 0.2s;
}

.festive-btn:hover {
    background-color: #e04050 !important;
    transform: scale(1.05);
}

/* 定义一个从Animate.css借鉴的动画 */
@keyframes tada {
  from { transform: scale3d(1, 1, 1); }
  10%, 20% { transform: scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg); }
  30%, 50%, 70%, 90% { transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg); }
  40%, 60%, 80% { transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg); }
  to { transform: scale3d(1, 1, 1); }
}