/* ========================================
   基础样式重置和变量定义
   ======================================== */
:root {
  --card-radius: 12px;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --transition: transform 0.2s ease;
  --font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --section-gap: 20px;
  --header-height: 56px;
}

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

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: #2c3e50;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  padding: 20px 0;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
}

/* ========================================
   容器样式 - 电脑端网格布局
   ======================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--section-gap);
  align-items: start;
}

/* ========================================
   头部区域样式
   ======================================== */
.header {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--theme-color) 0%, #1565c0 100%);
  color: #fff;
  padding: 35px 40px;
  text-align: center;
  border-radius: var(--card-radius);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--section-gap);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.header h1 {
  font-size: 2.5em;
  font-weight: 600;
  margin-bottom: 18px;
  letter-spacing: 1px;
}

.header .date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.header .solar {
  font-size: 1.25em;
  opacity: 0.95;
  font-weight: 500;
}

.header .lunar {
  font-size: 1.15em;
  opacity: 0.9;
  display: flex;
  gap: 20px;
}

/* 每日一语样式 */
.header .daily-quote {
  margin: 25px auto 0;
  padding: 25px;
  max-width: 900px;
  border-top: 1px solid rgba(255,255,255,0.15);
  position: relative;
}

.header .daily-quote::before,
.header .daily-quote::after {
  content: '"';
  position: absolute;
  font-size: 4.5em;
  font-family: Georgia, serif;
  opacity: 0.15;
  line-height: 1;
}

.header .daily-quote::before {
  left: 0;
  top: 10px;
  transform: translateX(-50%);
}

.header .daily-quote::after {
  right: 0;
  bottom: -25px;
  transform: translateX(50%);
}

.header .daily-quote p {
  font-size: 1.15em;
  line-height: 1.9;
  opacity: 0.95;
  font-weight: 300;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
  padding: 0 35px;
}

/* ========================================
   卡片基础样式 - 完整显示所有内容
   ======================================== */
.card {
  background: #ffffff;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition);
  height: auto; /* 自适应高度，不限制 */
  min-height: auto;
  border: 1px solid rgba(0,0,0,0.08);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

/* 卡片标题样式 */
.section-title {
  height: auto;
  min-height: var(--header-height);
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 2px solid rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: flex-start;
  position: sticky;
  top: 0;
  z-index: 10;
}

.section-title h2 {
  font-size: 1.15em;
  color: var(--theme-color);
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  padding: 10px 0;
}

.section-title img {
  margin-right: 12px;
  border-radius: 4px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* 卡片内容区域 - 完整显示，不滚动 */
.section-content {
  padding: 15px 20px;
  overflow: visible; /* 不限制内容显示 */
}

/* ========================================
   列表项样式
   ======================================== */
.list-item, .hot-item {
  display: flex;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  transition: var(--transition);
  background: transparent;
}

.list-item:hover, .hot-item:hover {
  background: rgba(var(--theme-rgb), 0.06);
  transform: translateX(5px);
}

.list-item:last-child, .hot-item:last-child {
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

/* 历史上的今天样式 */
.list-item .index {
  width: 70px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  background: rgba(var(--theme-rgb), 0.1);
  border-radius: 6px;
  color: var(--theme-color);
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
  margin-top: 2px;
}

.list-item .content {
  flex: 1;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word;
  font-size: 15px;
  color: #2c3e50;
  padding-left: 15px;
  line-height: 1.6;
}

/* ========================================
   热搜列表样式
   ======================================== */
.hot-item {
  border: none;
  margin-bottom: 2px;
}

.hot-index {
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  background: #f0f7ff;
  border-radius: 6px;
  margin-right: 14px;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  color: #666;
  margin-top: 2px;
}

.hot-content {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hot-title {
  flex: 1;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word;
  font-size: 15px;
  color: #2c3e50;
  line-height: 1.6;
}

.hot-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.hot-tag {
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(var(--theme-rgb), 0.1);
  color: var(--theme-color);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.hot-score {
  font-size: 13px;
  color: #f44336;
  font-weight: 500;
  min-width: 45px;
  text-align: right;
  white-space: nowrap;
}

/* 热搜前三名样式 */
.hot-item:nth-child(1) {
  background: #fff8f8;
}

.hot-item:nth-child(1) .hot-index {
  background: #f44336;
  color: #fff;
}

.hot-item:nth-child(2) {
  background: #fff8f5;
}

.hot-item:nth-child(2) .hot-index {
  background: #ff5722;
  color: #fff;
}

.hot-item:nth-child(3) {
  background: #fffaf2;
}

.hot-item:nth-child(3) .hot-index {
  background: #ff9800;
  color: #fff;
}

/* 4-10名序号样式 */
.hot-item:nth-child(n+4):nth-child(-n+10) .hot-index {
  background: rgba(var(--theme-rgb), 0.15);
  color: var(--theme-color);
}

/* ========================================
   今日黄历样式
   ======================================== */
.lunar-section {
  grid-column: 1 / -1;
}

.lunar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px;
}

.lunar-item {
  flex: 1;
  min-width: 220px;
  padding: 14px 18px;
  background: #fafafa;
  border: 1px solid rgba(var(--theme-rgb), 0.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.lunar-item .label {
  font-weight: 600;
  margin-right: 18px;
  color: #666;
  font-size: 15px;
  min-width: 45px;
}

.lunar-item .value {
  color: #333;
  font-size: 15px;
  flex: 1;
}

/* 宜忌样式 */
.lunar-item.yi,
.lunar-item.ji {
  flex: 2;
  min-width: 350px;
}

.lunar-item.yi .label {
  color: #52c41a;
}

.lunar-item.ji .label {
  color: #ff4d4f;
}

.lunar-item.yi .value,
.lunar-item.ji .value {
  white-space: normal;
  line-height: 1.9;
}

/* ========================================
   保存按钮样式
   ======================================== */
.save-btn {
  position: fixed;
  right: 30px;
  bottom: 30px;
  padding: 14px 24px;
  background: var(--theme-color);
  color: #fff;
  border-radius: 28px;
  box-shadow: 0 4px 16px rgba(var(--theme-rgb), 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
  z-index: 100;
  font-size: 15px;
  font-weight: 500;
}

.save-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(var(--theme-rgb), 0.45);
}

.save-btn svg {
  transition: transform 0.3s ease;
}

.save-btn:hover svg {
  transform: translateY(-2px);
}

.save-btn.loading {
  opacity: 0.8;
  cursor: wait;
}

@keyframes saving {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

.save-btn.loading {
  animation: saving 1s infinite;
}

/* ========================================
   加载动画容器
   ======================================== */
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-container.active {
  display: flex;
}

.loading-spinner {
  width: 140px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.spinner {
  width: 45px;
  height: 45px;
  margin: 15px auto;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--theme-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   海报样式
   ======================================== */
.poster-container {
  max-width: 750px;
  width: 100%;
  background: #ffffff;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin: 0 auto;
  border: 1px solid rgba(0,0,0,0.08);
}

.poster-header {
  text-align: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.poster-header h1 {
  font-size: 26px;
  color: var(--theme-color);
  margin-bottom: 12px;
  text-align: center;
  width: 100%;
}

.poster-header .date {
  font-size: 15px;
  color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.poster-header .date span {
  text-align: center;
  display: inline-block;
}

.poster-section-title {
  font-size: 19px;
  font-weight: 600;
  color: var(--theme-color);
  margin: 22px 0 16px;
  padding-left: 14px;
  border-left: 4px solid var(--theme-color);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  overflow: visible;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
}

.poster-section-title img {
  height: 22px;
  width: auto;
}

.poster-list {
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 22px;
}

.poster-list .hot-item {
  padding: 14px 15px;
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

.poster-list .hot-item:last-child {
  border-bottom: 1px solid rgba(0,0,0,0.15);
}

.poster-content {
  padding: 0 18px;
}

.poster-footer {
  margin-top: 25px;
  padding: 18px;
  border-top: 2px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8f9fa;
  border-radius: 8px;
}

.poster-info {
  flex: 1;
  padding-right: 18px;
}

.poster-info .title {
  font-size: 17px;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
}

.poster-info .desc {
  font-size: 13px;
  color: #666;
}

.poster-qrcode {
  width: 85px;
  height: 85px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ========================================
   图片样式
   ======================================== */
img {
  max-width: 100%;
  height: auto;
  display: inline-block;
  content-visibility: auto;
}

/* ========================================
   移动端样式适配
   ======================================== */
@media (max-width: 768px) {
  body {
    padding: 0;
    margin: 0;
    width: 100vw;
    overflow-x: hidden;
    background: #ffffff;
  }

  .container {
    padding: 12px 15px;
    margin: 0;
    width: 100%;
    max-width: 100%;
    display: block;
  }

  /* 头部样式 */
  .header {
    padding: 25px 20px;
    margin-bottom: 15px;
  }

  .header h1 {
    font-size: 1.8em;
    margin-bottom: 12px;
  }

  .header .date {
    gap: 8px;
  }

  .header .solar {
    font-size: 1.1em;
  }

  .header .lunar {
    font-size: 1em;
    gap: 12px;
  }

  .header .daily-quote {
    margin: 18px auto 0;
    padding: 18px 15px;
    max-width: 100%;
  }

  .header .daily-quote p {
    font-size: 1em;
    line-height: 1.7;
    padding: 0 20px;
  }

  .header .daily-quote::before,
  .header .daily-quote::after {
    font-size: 3em;
  }

  /* 卡片样式 */
  .card {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
  }

  .section-title {
    height: auto;
    padding: 0 15px;
    min-height: 50px;
    background: #ffffff;
  }

  .section-title h2 {
    font-size: 1.05em;
    line-height: 1.4;
    overflow: visible;
    word-wrap: break-word;
    word-break: break-word;
  }

  .section-title img {
    height: 20px;
  }

  .section-content {
    padding: 12px 15px;
  }

  /* 列表项样式 */
  .list-item, .hot-item {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
    background: transparent;
  }

  .list-item:last-child, .hot-item:last-child {
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  }

  .list-item .index {
    width: 55px;
    height: 24px;
    line-height: 24px;
    font-size: 13px;
  }

  .list-item .content {
    font-size: 14px;
    padding-left: 12px;
  }

  /* 热搜样式 */
  .hot-index {
    width: 22px;
    height: 22px;
    line-height: 22px;
    font-size: 12px;
    margin-right: 10px;
  }

  .hot-title {
    font-size: 14px;
    padding-right: 10px;
  }

  .hot-tag {
    padding: 2px 6px;
    font-size: 11px;
  }

  .hot-score {
    font-size: 12px;
    min-width: 40px;
  }

  /* 黄历样式 */
  .lunar-grid {
    padding: 15px;
    gap: 8px;
  }

  .lunar-item {
    min-width: 150px;
    padding: 12px 14px;
  }

  .lunar-item .label {
    font-size: 14px;
    min-width: 40px;
    margin-right: 12px;
  }

  .lunar-item .value {
    font-size: 14px;
  }

  .lunar-item.yi,
  .lunar-item.ji {
    min-width: 100%;
  }

  /* 保存按钮 */
  .save-btn {
    right: 15px;
    bottom: 15px;
    padding: 12px 18px;
    font-size: 14px;
  }

  /* 海报样式 */
  .poster-container {
    width: 100%;
    padding: 12px;
    margin: 0;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
  }

  .poster-header {
    margin-bottom: 15px;
    padding-bottom: 12px;
  }

  .poster-header h1 {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .poster-header .date {
    font-size: 13px;
    gap: 4px;
  }

  .poster-section-title {
    font-size: 15px;
    margin: 15px 0 10px;
    padding-left: 10px;
    border-left: 3px solid var(--theme-color);
  }

  .poster-section-title img {
    height: 16px;
  }

  .poster-list {
    margin-bottom: 15px;
    background: transparent;
  }

  .poster-list .hot-item {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.15);
  }

  .poster-list .hot-item:last-child {
    border-bottom: 1px solid rgba(0,0,0,0.15);
  }

  .poster-content {
    padding: 0 10px;
  }

  .poster-footer {
    margin-top: 15px;
    padding: 12px;
  }

  .poster-info .title {
    font-size: 14px;
    margin-bottom: 4px;
  }

  .poster-info .desc {
    font-size: 11px;
  }

  .poster-qrcode {
    width: 55px;
    height: 55px;
  }
}

/* ========================================
   平板端样式适配
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    grid-template-columns: repeat(2, 1fr);
  }
}
