/* 全局变量和重置 */
:root {
  --primary-color: #87CEEB;
  --secondary-color: #B6D7FF;
  --accent-color: #A8D8EA;
  --warm-yellow: #FFE4B6;
  --mint-green: #B6FFE4;
  --soft-pink: #FFB6C1;
  --text-dark: #2C3E50;
  --text-light: #7F8C8D;
  --white: #FFFFFF;
  --shadow: rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: linear-gradient(135deg, #EBF5FB 0%, #F0F8FF 50%, #E8F6F3 100%);
  min-height: 100vh;
  color: var(--text-dark);
  overflow-x: hidden;
}

/* 背景装饰 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(135, 206, 235, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(168, 216, 234, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(182, 215, 255, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* 头部区域 */
.header {
  text-align: center;
  padding: 60px 20px 40px;
  position: relative;
  animation: fadeInDown 1s ease-out;
}

.header-title {
  font-size: 2.5em;
  font-weight: bold;
  background: linear-gradient(135deg, #5DADE2 0%, #85C1E9 50%, #AED6F1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
  letter-spacing: 2px;
}

.header-subtitle {
  font-size: 1.3em;
  color: var(--text-light);
  margin-bottom: 20px;
  font-style: italic;
}

.header-decoration {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 20px 0;
}

.decoration-icon {
  width: 40px;
  height: 40px;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

.decoration-icon:nth-child(2) {
  animation-delay: 0.5s;
}

.decoration-icon:nth-child(3) {
  animation-delay: 1s;
}

.footer-note {
  margin-top: 30px;
  font-size: 0.9em;
  color: var(--text-light);
  opacity: 0.8;
}

/* 搜索区域 */
.search-section {
  max-width: 600px;
  margin: 0 auto 40px;
  padding: 0 20px;
  animation: fadeInUp 1s ease-out 0.3s both;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 15px 50px 15px 20px;
  border: 2px solid rgba(135, 206, 235, 0.4);
  border-radius: 50px;
  font-size: 1em;
  background: var(--white);
  box-shadow: 0 4px 15px var(--shadow);
  transition: all 0.3s ease;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 6px 20px rgba(135, 206, 235, 0.4);
}

.search-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0.5;
}

/* 班主任寄语区域 */
.teacher-message-section {
  max-width: 1200px;
  margin: 0 auto 50px;
  padding: 0 20px;
  animation: fadeInUp 1s ease-out 0.5s both;
}

.teacher-message-card {
  background: linear-gradient(135deg, #FFF9E6 0%, #FFF5E6 100%);
  border: 2px dashed #FFD700;
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(255, 215, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.teacher-message-card::before {
  content: '✉';
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 3em;
  opacity: 0.2;
}

.teacher-message-title {
  font-size: 1.8em;
  color: #D4AF37;
  margin-bottom: 20px;
  font-weight: bold;
}

.teacher-message-content {
  font-size: 1.1em;
  color: var(--text-light);
  font-style: italic;
  line-height: 1.8;
}

/* 卡片容器 */
.cards-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 30px;
  animation: fadeInUp 1s ease-out 0.7s both;
  align-items: start;
}

/* 明信片卡片 - 稳定翻转方案 */
.postcard {
  position: relative;
  height: 380px;
  width: 100%;
  cursor: pointer;
  display: block;
}

.postcard-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.postcard-front,
.postcard-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* 卡片正面 - 默认显示 */
.postcard-front {
  background: linear-gradient(135deg, var(--card-color-1) 0%, var(--card-color-2) 100%);
  z-index: 2;
  opacity: 1;
  transform: scale(1) rotateY(0deg);
}

/* 卡片背面 - 默认隐藏 */
.postcard-back {
  background: #FFFFFF;
  z-index: 1;
  opacity: 0;
  transform: scale(0.9) rotateY(0deg);
  text-align: left;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

/* 翻转状态 */
.postcard.flipped .postcard-front {
  opacity: 0;
  transform: scale(0.9) rotateY(0deg);
  z-index: 1;
}

.postcard.flipped .postcard-back {
  opacity: 1;
  transform: scale(1) rotateY(0deg);
  z-index: 2;
}

/* 正面闪烁效果 */
.postcard-front::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  animation: shimmer 3s ease-in-out infinite;
}

.student-name {
  font-size: 2.2em;
  font-weight: bold;
  color: var(--white);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1;
  letter-spacing: 3px;
}

.card-decoration {
  position: absolute;
  font-size: 2em;
  opacity: 0.3;
  animation: twinkle 2s ease-in-out infinite;
}

.card-decoration.top-left {
  top: 15px;
  left: 15px;
}

.card-decoration.bottom-right {
  bottom: 15px;
  right: 15px;
  animation-delay: 1s;
}

.flip-hint {
  position: absolute;
  bottom: 20px;
  font-size: 0.85em;
  color: var(--white);
  opacity: 0.7;
  z-index: 1;
}

.back-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.blessing-section,
.message-section {
  margin-bottom: 15px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.section-label {
  font-size: 0.9em;
  color: #5DADE2;
  font-weight: bold;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.section-text {
  font-size: 0.95em;
  line-height: 1.6;
  color: var(--text-dark);
  font-family: 'KaiTi', 'STKaiti', serif;
  overflow-y: auto;
  max-height: 120px;
  padding-right: 5px;
}

.create-time {
  font-size: 0.8em;
  color: var(--text-light);
  text-align: right;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* 浮动按钮 */
.fab-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #87CEEB 0%, #5DADE2 100%);
  border: none;
  box-shadow: 0 6px 20px rgba(135, 206, 235, 0.5);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2em;
  color: var(--white);
  transition: all 0.3s ease;
  z-index: 100;
  animation: pulse 2s ease-in-out infinite;
}

.fab-button:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 8px 25px rgba(135, 206, 235, 0.7);
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: 25px;
  padding: 40px;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s ease;
}

.modal-header {
  text-align: center;
  margin-bottom: 30px;
}

.modal-title {
  font-size: 1.8em;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.modal-subtitle {
  color: var(--text-light);
  font-size: 0.95em;
}

.form-group {
  margin-bottom: 25px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dark);
  font-weight: 500;
  font-size: 0.95em;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  font-size: 1em;
  font-family: inherit;
  transition: all 0.3s ease;
  outline: none;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(135, 206, 235, 0.2);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* 颜色选择器 */
.color-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 10px;
}

.color-option {
  width: 100%;
  height: 50px;
  border-radius: 12px;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.color-option:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.color-option.active {
  border-color: #5DADE2;
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: scale(1.05);
}

.form-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
}

.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 25px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #87CEEB 0%, #5DADE2 100%);
  color: var(--white);
  box-shadow: 0 4px 15px rgba(135, 206, 235, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(135, 206, 235, 0.5);
}

.btn-secondary {
  background: #F5F5F5;
  color: var(--text-dark);
}

.btn-secondary:hover {
  background: #E0E0E0;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 4em;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-text {
  font-size: 1.2em;
  margin-bottom: 10px;
}

.empty-hint {
  font-size: 0.9em;
  opacity: 0.7;
}

/* 动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes shimmer {
  0%, 100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  50% {
    transform: translate(-50%, -50%) rotate(180deg);
  }
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(135, 206, 235, 0.5);
  }
  50% {
    box-shadow: 0 6px 30px rgba(135, 206, 235, 0.7);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-title {
    font-size: 1.8em;
  }

  .header-subtitle {
    font-size: 1.1em;
  }

  .cards-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
  }

  .postcard {
    height: 350px;
  }

  .postcard-front,
  .postcard-back {
    padding: 20px;
  }

  .student-name {
    font-size: 1.8em;
  }

  .section-text {
    max-height: 100px;
    font-size: 0.9em;
  }

  .color-picker {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .color-option {
    height: 45px;
  }

  .modal {
    padding: 30px 20px;
    width: 95%;
  }

  .fab-button {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
    font-size: 1.8em;
  }

  .teacher-message-card {
    padding: 30px 20px;
  }

  .teacher-message-title {
    font-size: 1.5em;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 40px 15px 30px;
  }

  .header-title {
    font-size: 1.5em;
  }

  .cards-container {
    grid-template-columns: 1fr;
    padding: 0 15px 40px;
  }

  .postcard {
    height: 320px;
  }

  .section-text {
    font-size: 0.9em;
  }
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #F1F1F1;
  border-radius: 10px;
}

::webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #87CEEB 0%, #5DADE2 100%);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #5DADE2 0%, #3498DB 100%);
}
