/* ChapterBox App Styles - Matches landing page design language */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=DM+Sans:wght@400;500;600&display=swap');

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

:root {
  --cream: #FDF6EC;
  --warm-white: #FFFBF5;
  --forest: #2D4A3E;
  --forest-light: #3D6B5A;
  --gold: #C8A45C;
  --gold-light: #E8D5A8;
  --charcoal: #2C2C2C;
  --muted: #7A7A6E;
  --paper: #F5EDE0;
  --red: #C75050;
  --green: #4A8B6E;
}

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--charcoal);
  background: var(--warm-white);
  min-height: 100vh;
}

/* ==================== LAYOUT ==================== */

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--cream);
  border-bottom: 1px solid var(--gold-light);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--forest);
  text-decoration: none;
  font-weight: 700;
}

.app-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.app-nav-links a:hover,
.app-nav-links a.active {
  color: var(--forest);
}

.app-nav-links .nav-btn {
  background: var(--forest);
  color: var(--cream) !important;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.app-nav-links .nav-btn:hover {
  background: var(--forest-light);
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.app-container.wide {
  max-width: 1100px;
}

/* ==================== TYPOGRAPHY ==================== */

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--forest);
  margin-bottom: 8px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 32px;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--forest);
  margin-bottom: 16px;
}

/* ==================== CARDS ==================== */

.card {
  background: var(--cream);
  border: 1px solid var(--gold-light);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-date {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.card-prompt {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: var(--forest-light);
  font-size: 1.05rem;
  margin-bottom: 12px;
  padding-left: 16px;
  border-left: 3px solid var(--gold);
}

.card-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--charcoal);
}

.card-photos {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.card-photo {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--gold-light);
  cursor: pointer;
  transition: transform 0.2s;
}

.card-photo:hover {
  transform: scale(1.05);
}

.card-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--gold-light);
}

/* ==================== BUTTONS ==================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--forest);
  color: var(--cream);
}

.btn-primary:hover {
  background: var(--forest-light);
}

.btn-secondary {
  background: transparent;
  color: var(--forest);
  border: 1px solid var(--gold-light);
}

.btn-secondary:hover {
  background: var(--cream);
  border-color: var(--gold);
}

.btn-gold {
  background: var(--gold);
  color: white;
}

.btn-gold:hover {
  background: #B89344;
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  font-size: 0.82rem;
  padding: 6px 14px;
}

.btn-danger:hover {
  background: var(--red);
  color: white;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== FORMS ==================== */

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--forest);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gold-light);
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  background: var(--warm-white);
  color: var(--charcoal);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15);
}

.form-textarea {
  width: 100%;
  min-height: 200px;
  padding: 16px;
  border: 1px solid var(--gold-light);
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  background: var(--warm-white);
  color: var(--charcoal);
  resize: vertical;
  transition: border-color 0.2s;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15);
}

/* ==================== STATS ==================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--cream);
  border: 1px solid var(--gold-light);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--forest);
  font-weight: 700;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ==================== PHOTO UPLOAD ==================== */

.photo-upload-area {
  border: 2px dashed var(--gold-light);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  background: var(--cream);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.photo-upload-area:hover,
.photo-upload-area.dragover {
  border-color: var(--gold);
  background: var(--paper);
}

.photo-upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.photo-upload-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.photo-upload-text strong {
  color: var(--forest);
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.photo-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--gold-light);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ==================== QR CODE ==================== */

.qr-display {
  text-align: center;
  padding: 32px;
}

.qr-display img {
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.qr-url {
  font-size: 0.82rem;
  color: var(--muted);
  word-break: break-all;
  margin-top: 12px;
}

/* ==================== AUTH PAGE ==================== */

.auth-container {
  max-width: 420px;
  margin: 60px auto;
  padding: 0 24px;
}

.auth-card {
  background: var(--cream);
  border: 1px solid var(--gold-light);
  border-radius: 20px;
  padding: 40px 32px;
}

.auth-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  color: var(--forest);
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-toggle a {
  color: var(--forest);
  font-weight: 600;
  text-decoration: none;
}

.auth-toggle a:hover {
  color: var(--gold);
}

/* ==================== EMPTY STATE ==================== */

.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.empty-state-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--forest);
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ==================== MODAL ==================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--warm-white);
  border-radius: 20px;
  padding: 32px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--forest);
  margin-bottom: 20px;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
}

/* ==================== LIGHTBOX ==================== */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
}

/* ==================== GALLERY ==================== */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid var(--gold-light);
  cursor: pointer;
  transition: transform 0.2s;
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
  font-size: 0.78rem;
}

/* ==================== ALERTS ==================== */

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(199, 80, 80, 0.1);
  border: 1px solid rgba(199, 80, 80, 0.3);
  color: var(--red);
}

.alert-success {
  background: rgba(74, 139, 110, 0.1);
  border: 1px solid rgba(74, 139, 110, 0.3);
  color: var(--green);
}

/* ==================== LOADING ==================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gold-light);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 14px 8px;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .app-container {
    padding: 20px 16px 60px;
  }

  .page-title {
    font-size: 1.6rem;
  }

  .card {
    padding: 20px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .app-nav {
    padding: 12px 16px;
  }

  .app-nav-links {
    gap: 12px;
  }

  .app-nav-links a {
    font-size: 0.82rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .photo-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}
