/* ═══════════════════════════════════════════════
   🤰 豆豆孕期日记 - Styles
   ═══════════════════════════════════════════════ */

:root {
  --pink: #FF6B6B;
  --pink-dark: #ee5a24;
  --pink-light: #FFE0E0;
  --teal: #4ECDC4;
  --teal-dark: #2ecc71;
  --yellow: #FFEAA7;
  --orange: #F39C12;
  --red: #E74C3C;
  --green: #27AE60;
  --bg: #FFF8F8;
  --card: #FFFFFF;
  --text: #2C3E50;
  --text-light: #95A5A6;
  --border: #F0E0E0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading ────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  transition: opacity 0.4s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #FFE0E0 0%, #FFF0F0 50%, #E0F7F4 100%);
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: 24px;
  padding: 40px 32px;
  width: 100%; max-width: 380px;
  box-shadow: 0 8px 40px rgba(255,107,107,0.15);
  text-align: center;
}
.login-card h1 { font-size: 28px; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-light); font-size: 14px; margin-bottom: 32px; }
.login-card .icon { font-size: 48px; margin-bottom: 16px; }
.login-card input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  margin-bottom: 12px;
  outline: none; transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--pink); }
.login-card button {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: white; border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform 0.15s, opacity 0.15s;
}
.login-card button:active { transform: scale(0.98); opacity: 0.9; }
.login-card .error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* ── App Shell ──────────────────────────────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.top-bar {
  background: white;
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.top-bar .title { font-size: 18px; font-weight: 700; }
.top-bar .user-info { display: flex; align-items: center; gap: 12px; }
.top-bar .user-info .name { font-size: 14px; color: var(--text-light); }
.top-bar .logout-btn {
  background: none; border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 20px;
  font-size: 12px; color: var(--text-light); cursor: pointer;
  transition: all 0.2s;
}
.top-bar .logout-btn:hover { border-color: var(--pink); color: var(--pink); }

.app-content {
  flex: 1;
  padding: 16px 16px 24px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* ── Alerts Bar ─────────────────────────────── */
.alert-bar {
  background: #FFF0F0;
  border: 1px solid var(--pink);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500;
  animation: alertPulse 2s ease-in-out infinite;
}
.alert-bar.warning { background: #FFFAF0; border-color: var(--orange); }
.alert-bar.success { background: #F0FFF4; border-color: var(--green); animation: none; }
.alert-bar .icon { font-size: 20px; }
@keyframes alertPulse {
  0%, 100% { background: #FFF0F0; }
  50% { background: #FFE0E0; }
}

/* ── Stats Row ──────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 24px; font-weight: 700; }
.stat-card .label { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* ── Entry Form (Wife) ──────────────────────── */
.entry-form {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.entry-form h3 {
  font-size: 16px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.entry-form .date-display {
  font-size: 13px; color: var(--text-light); margin-bottom: 12px;
}

/* Mood Picker */
.mood-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.mood-option {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  background: #FAFAFA;
}
.mood-option .emoji { font-size: 28px; }
.mood-option .label { font-size: 11px; color: var(--text-light); }
.mood-option.selected {
  border-color: var(--pink);
  background: var(--pink-light);
  transform: scale(1.05);
}

/* Inputs */
.entry-form textarea {
  width: 100%; padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font);
  resize: vertical; min-height: 60px;
  outline: none; transition: border-color 0.2s;
  margin-bottom: 12px;
}
.entry-form textarea:focus { border-color: var(--teal); }
.entry-form textarea::placeholder { color: var(--text-light); }
.entry-form .submit-btn {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--teal), #2ecc71);
  color: white; border: none; border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform 0.15s, opacity 0.15s;
}
.entry-form .submit-btn:active { transform: scale(0.98); opacity: 0.9; }
.entry-form .submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Entry List ─────────────────────────────── */
.entry-list-title {
  font-size: 16px; font-weight: 600;
  margin: 20px 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.entry-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.entry-card:active { transform: scale(0.99); }
.entry-card .header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.entry-card .date { font-weight: 600; font-size: 15px; }
.entry-card .mood { font-size: 24px; }
.entry-card .preview {
  font-size: 13px; color: var(--text-light);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-card .badge {
  display: inline-block;
  font-size: 11px; padding: 2px 10px;
  border-radius: 10px;
  margin-top: 8px;
}
.badge.closed { background: #E8F8E8; color: var(--green); }
.badge.pending { background: #FFF8E0; color: var(--orange); }
.badge.alert { background: #FFE0E0; color: var(--red); animation: alertPulse 2s infinite; }
.badge.done { background: #E0F0FF; color: #2980B9; }

/* ── Entry Detail ───────────────────────────── */
.detail-view { padding-bottom: 80px; }
.detail-view .back-btn {
  background: none; border: none;
  font-size: 14px; color: var(--pink);
  cursor: pointer; padding: 8px 0;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
}
.detail-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.detail-card .header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.detail-card .header .date { font-size: 18px; font-weight: 700; }
.detail-card .header .mood { font-size: 36px; }
.detail-card section { margin-bottom: 16px; }
.detail-card section:last-child { margin-bottom: 0; }
.detail-card section .label {
  font-size: 12px; font-weight: 600; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.detail-card section .content {
  font-size: 15px; line-height: 1.6;
  padding: 10px 14px;
  background: #FAFAFA;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}

/* ── Messages / Chat ────────────────────────── */
.chat-section {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.chat-section h4 { font-size: 14px; margin-bottom: 12px; color: var(--text-light); }
.chat-msg {
  display: flex; gap: 10px;
  margin-bottom: 12px;
}
.chat-msg .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
  flex-shrink: 0;
}
.chat-msg.wife .avatar { background: var(--pink-light); color: var(--pink); }
.chat-msg.husband .avatar { background: #E0F0FF; color: #2980B9; justify-content: center; }
.chat-msg .bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px; line-height: 1.4;
}
.chat-msg.wife .bubble {
  background: var(--pink-light);
  border-bottom-left-radius: 4px;
}
.chat-msg.husband .bubble {
  background: #E8F4FD;
  border-bottom-right-radius: 4px;
}
.chat-msg.husband { flex-direction: row-reverse; }
.chat-msg .sender { font-size: 11px; color: var(--text-light); margin-bottom: 2px; }
.chat-msg .time { font-size: 10px; color: var(--text-light); margin-top: 4px; text-align: right; }
.chat-input {
  display: flex; gap: 8px; margin-top: 12px;
}
.chat-input input {
  flex: 1; padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  font-size: 14px; outline: none;
}
.chat-input input:focus { border-color: var(--teal); }
.chat-input button {
  background: var(--teal); color: white;
  border: none; border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
}
.chat-input button:active { transform: scale(0.9); }

/* ── Closure Section ────────────────────────── */
.closure-section {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.closure-section h4 {
  font-size: 14px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.closure-section .husband-form textarea {
  width: 100%; padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--font);
  resize: vertical; min-height: 80px;
  outline: none; margin-bottom: 10px;
}
.closure-section .husband-form textarea:focus { border-color: #2980B9; }
.closure-section .husband-form button {
  padding: 10px 24px;
  background: #2980B9; color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s;
}
.closure-section .husband-form button:active { transform: scale(0.98); }

.closure-status {
  display: flex; flex-direction: column; gap: 12px;
}
.closure-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #FAFAFA;
}
.closure-step .check { font-size: 20px; }
.closure-step.done { background: #F0FFF4; }
.closure-step .info { flex: 1; }
.closure-step .info .step-title { font-size: 13px; font-weight: 600; }
.closure-step .info .step-detail { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.closure-step .info .step-note { font-size: 13px; color: var(--text); margin-top: 2px; font-style: italic; }
.closure-section .confirm-btn {
  padding: 12px 24px;
  background: var(--green); color: white;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s;
  margin-top: 8px;
}
.closure-section .confirm-btn:active { transform: scale(0.98); }
.closure-section .unconfirm-btn {
  padding: 8px 16px;
  background: none; border: 1px solid var(--orange);
  color: var(--orange); border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; cursor: pointer;
  margin-top: 6px;
}

/* ── Pregnancy Info Card ────────────────────── */
.pregnancy-card {
  background: linear-gradient(135deg, #FFF0F5 0%, #FFF5F5 30%, #F0FFF4 100%);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid rgba(255,107,107,0.15);
}
.preg-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.preg-greeting {
  font-size: 15px;
  font-weight: 700;
  color: var(--pink);
}
.preg-date {
  font-size: 12px;
  color: var(--text-light);
}
.preg-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.preg-week {
  text-align: center;
}
.preg-week-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--pink);
  line-height: 1.2;
}
.preg-week-unit {
  font-size: 16px;
  font-weight: 600;
  color: var(--pink-dark);
  margin: 0 2px;
}
.preg-week-label {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 2px;
}
.preg-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,107,107,0.2), transparent);
}
.preg-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.preg-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.7);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.preg-stat-icon {
  font-size: 22px;
}
.preg-stat-info {
  flex: 1;
  min-width: 0;
}
.preg-stat-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.preg-stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 1px;
}
.preg-return-today {
  color: var(--pink);
  animation: alertPulse 1.5s ease-in-out infinite;
}

/* ── Calendar Module ───────────────────────── */
.calendar-module {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.cal-header {
  text-align: center;
  margin-bottom: 12px;
}
.cal-month {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.cal-nav-btn:hover {
  background: var(--pink-light);
  border-color: var(--pink);
  color: var(--pink);
}
.cal-nav-btn:active {
  transform: scale(0.9);
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}
.cal-wd {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  padding: 4px 0;
}
.cal-wd:first-child { color: var(--pink); }
.cal-wd:last-child { color: #2980B9; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #FAFAFA;
  padding: 2px;
  min-height: 48px;
  transition: background 0.15s;
}
.cal-cell.cal-empty {
  background: transparent;
}
.cal-cell.cal-today {
  border: 2px solid var(--pink);
  background: var(--pink-light);
}
.cal-cell.cal-has-entry {
  cursor: pointer;
}
.cal-cell.cal-has-entry:hover {
  background: #F0E8E8;
}
.cal-day {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.cal-mood {
  font-size: 16px;
  line-height: 1;
  margin-top: 1px;
}
.cal-today .cal-day {
  color: var(--pink);
}

/* Unhappy streak highlight */
.cal-unhappy-streak {
  background: #FFF0F0;
  box-shadow: inset 0 0 0 1.5px var(--pink);
  border-radius: 8px;
}
.cal-unhappy-streak .cal-mood {
  filter: saturate(1.3);
}
.cal-unhappy-streak:hover {
  background: #FFE0E0 !important;
}

/* Mood legend */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  justify-content: center;
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-light);
}
.cal-legend-emoji {
  font-size: 14px;
  line-height: 1;
}
.cal-legend-label {
  white-space: nowrap;
}
.cal-legend-streak .cal-legend-emoji {
  font-size: 10px;
}

/* ── Empty State ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Error Toast ────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: white;
  padding: 12px 24px; border-radius: 20px;
  font-size: 14px;
  z-index: 1000;
  animation: toastIn 0.3s ease-out;
  max-width: 90%;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 480px) {
  .app-content { padding: 12px 12px 20px; }
  .mood-picker { grid-template-columns: repeat(4, 1fr); }
  .mood-option .emoji { font-size: 24px; }
  .mood-option .label { font-size: 10px; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .top-bar { padding: 12px 16px; }
  .top-bar .title { font-size: 16px; }
  .detail-card { padding: 16px; }
}
