/* ─── APP SHELL ─── */
.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--cream);
}

.app-sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--black);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 50;
  border-right: var(--border);
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  color: var(--cream);
  text-decoration: none;
  padding: 28px 24px 24px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  display: block;
  line-height: 1.2;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-link.active {
  background: var(--pink);
  color: white;
  font-weight: 700;
}
.sidebar-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-user {
  padding: 20px 24px;
  border-top: 2px solid rgba(255,255,255,0.1);
}
.sidebar-user-name { font-size: 0.85rem; color: rgba(255,255,255,0.5); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.55);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.2s, color 0.2s;
}
.sidebar-logout:hover { border-color: var(--pink); color: var(--pink); }

.app-main {
  margin-left: 240px;
  flex: 1;
  padding: 40px 48px;
  max-width: 1200px;
}

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
  gap: 20px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  line-height: 1;
  color: var(--black);
}
.page-sub { color: #666; font-size: 1rem; margin-top: 6px; }

/* ─── BUTTONS ─── */
.btn-primary {
  background: var(--black);
  color: var(--cream);
  border: var(--border);
  border-radius: 50px;
  padding: 12px 28px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: var(--font-body);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.btn-primary:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 rgba(0,0,0,0.2); }

.btn-sm {
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  border: 2px solid var(--black);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.btn-outline { color: var(--black); }
.btn-outline:hover { background: var(--black); color: var(--cream); }
.btn-delete { border-color: #e74c3c; color: #e74c3c; }
.btn-delete:hover { background: #e74c3c; color: white; }

/* ─── STAT CARDS ─── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 40px; }
.stat-card {
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
}
.stat-pink { background: var(--pink); color: white; box-shadow: var(--shadow-pink); }
.stat-blue { background: var(--blue); color: white; box-shadow: var(--shadow-blue); }
.stat-yellow { background: var(--yellow); color: var(--black); box-shadow: var(--shadow); }
.stat-number { font-family: var(--font-display); font-size: 3rem; line-height: 1; }
.stat-label { font-size: 0.9rem; font-weight: 600; margin-top: 4px; opacity: 0.85; }

/* ─── DASHBOARD SECTIONS ─── */
.dash-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.dash-section { }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-family: var(--font-display); font-size: 1.3rem; }
.section-link { color: var(--pink); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* ─── POLAROID CARDS ─── */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.polaroid-card {
  background: white;
  border: var(--border);
  border-radius: 4px;
  padding: 12px 12px 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  transform: rotate(var(--tilt, 0deg));
}
.polaroid-card:nth-child(odd) { --tilt: -1.5deg; }
.polaroid-card:nth-child(even) { --tilt: 1deg; }
.polaroid-card:hover { transform: rotate(0deg) scale(1.03); box-shadow: 12px 12px 0 rgba(0,0,0,0.12); z-index: 2; }
.polaroid-img {
  width: 100%; aspect-ratio: 1; background: #eee center/cover no-repeat;
  border-radius: 2px; margin-bottom: 10px;
}
.polaroid-placeholder {
  width: 100%; aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: var(--cream);
  border-radius: 2px; margin-bottom: 10px; gap: 8px;
}
.polaroid-placeholder span, .polaroid-placeholder .audio-icon { font-size: 2.5rem; }
.audio-icon { display: block; }
.text-preview { font-size: 0.75rem; color: #555; text-align: center; padding: 0 8px; line-height: 1.5; }
.audio-player { width: 100%; margin-top: 8px; }
.audio-placeholder { gap: 6px; }
.polaroid-caption { font-size: 0.85rem; font-weight: 600; text-align: center; line-height: 1.3; }
.polaroid-tag { font-size: 0.7rem; color: #888; text-align: center; margin-top: 4px; }
.polaroid-meta { padding-top: 8px; }
.polaroid-tags-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; justify-content: center; }
.tag { padding: 2px 8px; border-radius: 50px; font-size: 0.7rem; font-weight: 600; }
.tag-decade { background: var(--yellow); color: var(--black); }
.tag-family { background: var(--pink); color: white; }
.tag-location { background: var(--blue); color: white; }
.memory-delete {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  background: var(--black); color: white; border: none; border-radius: 50%;
  font-size: 0.85rem; cursor: pointer; display: none; line-height: 22px; text-align: center; padding: 0;
}
.polaroid-card:hover .memory-delete { display: block; }

/* ─── FILTER BAR ─── */
.filter-bar { display: flex; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.filter-select { padding: 8px 14px; border: var(--border); border-radius: 50px; background: white; font-family: var(--font-body); font-size: 0.9rem; cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--pink); }

/* ─── FAMILY GRID ─── */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.family-card {
  background: white; border: var(--border); border-radius: var(--radius-lg);
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.family-card:hover { transform: translate(-3px,-3px); box-shadow: 12px 12px 0 rgba(0,0,0,0.12); }
.family-photo {
  width: 80px; height: 80px; border-radius: 50%; background: var(--blue) center/cover no-repeat;
  border: 3px solid var(--black); display: flex; align-items: center; justify-content: center;
}
.family-photo-empty { background: var(--cream); }
.family-initial { font-family: var(--font-display); font-size: 2rem; color: var(--black); }
.family-name { font-family: var(--font-display); font-size: 1.4rem; }
.family-rel { font-size: 0.85rem; color: var(--pink); font-weight: 600; }
.family-years { font-size: 0.8rem; color: #888; }
.family-bio { font-size: 0.85rem; color: #555; line-height: 1.5; }
.family-memory-count { font-size: 0.8rem; font-weight: 600; color: var(--blue); }
.family-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── FUTURE SENDS ─── */
.timeline-header { display: flex; align-items: center; gap: 0; margin-bottom: 36px; background: white; border: var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px 32px; }
.timeline-stat { flex: 1; text-align: center; }
.timeline-num { font-family: var(--font-display); font-size: 3rem; color: var(--pink); display: block; }
.timeline-label { font-size: 0.85rem; color: #888; font-weight: 600; }
.timeline-divider { width: 2px; background: var(--black); height: 60px; }
.sends-section { margin-bottom: 40px; }
.sends-list { display: flex; flex-direction: column; gap: 16px; }
.send-card {
  background: white; border: var(--border); border-radius: var(--radius-lg);
  padding: 20px 24px; display: flex; justify-content: space-between; align-items: center;
  gap: 16px; box-shadow: var(--shadow);
}
.send-pending { border-left: 6px solid var(--pink); }
.send-sent { border-left: 6px solid var(--green); opacity: 0.8; }
.send-card-to { font-size: 0.85rem; color: #888; margin-bottom: 4px; }
.send-card-subject { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.send-card-preview { font-size: 0.85rem; color: #555; line-height: 1.4; }
.send-card-right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.date-label { font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.05em; }
.date-value { font-weight: 700; font-size: 0.95rem; color: var(--black); }
.badge-sent { background: var(--green); color: white; padding: 4px 12px; border-radius: 50px; font-size: 0.8rem; font-weight: 700; }
.send-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(0,0,0,0.08); }
.send-to { font-size: 0.85rem; color: #888; }
.send-subject { font-weight: 600; }
.send-date { font-size: 0.85rem; font-weight: 700; }
.letter-textarea { font-family: 'Georgia', serif; font-size: 1rem; line-height: 1.8; resize: vertical; }
.char-count { font-size: 0.75rem; color: #aaa; text-align: right; margin-top: 4px; }
.form-hint { font-size: 0.8rem; color: #888; margin-top: 4px; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-card {
  background: white; border: var(--border); border-radius: var(--radius-xl);
  box-shadow: 12px 12px 0 rgba(0,0,0,0.15); padding: 40px;
  max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-large { max-width: 680px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.modal-title { font-family: var(--font-display); font-size: 1.8rem; }
.modal-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: #888; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--black); }

/* ─── FORMS (app context) ─── */
.form-group { margin-bottom: 20px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.flex-1 { flex: 1; }
.form-label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.form-input { width: 100%; padding: 12px 16px; border: var(--border); border-radius: 12px; font-size: 1rem; font-family: var(--font-body); background: var(--cream); transition: border-color 0.2s; }
.form-input:focus { outline: none; border-color: var(--pink); box-shadow: 4px 4px 0 rgba(255,107,157,0.12); }
.tab-btns { display: flex; border: var(--border); border-radius: 50px; overflow: hidden; }
.tab-btn { flex: 1; padding: 10px 8px; border: none; background: transparent; font-weight: 600; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body); transition: background 0.2s, color 0.2s; }
.tab-btn.active { background: var(--black); color: var(--cream); }
.upload-zone {
  border: 3px dashed rgba(0,0,0,0.25); border-radius: 16px;
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover { border-color: var(--pink); background: rgba(255,107,157,0.04); }
.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-text { font-weight: 600; color: #444; }
.upload-hint { font-size: 0.8rem; color: #aaa; margin-top: 4px; }
.error-msg { background: #fff0f4; border: 2px solid var(--pink); border-radius: 12px; padding: 12px 16px; font-size: 0.9rem; color: #c0392b; margin-bottom: 8px; display: none; }
.progress-bar { background: #eee; border-radius: 50px; height: 6px; margin-bottom: 12px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--pink); width: 0; transition: width 0.3s; border-radius: 50px; }

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 60px 20px; color: #888; }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.5rem; color: var(--black); margin-bottom: 8px; }
.empty-state a { color: var(--pink); font-weight: 700; }

/* ─── MOBILE ─── */
@media (max-width: 768px) {
  .app-sidebar { width: 100%; min-height: auto; position: relative; flex-direction: row; flex-wrap: wrap; padding: 0; }
  .app-main { margin-left: 0; padding: 20px 16px; }
  .stats-row { grid-template-columns: 1fr; }
  .dash-sections { grid-template-columns: 1fr; }
  .family-grid { grid-template-columns: 1fr; }
  .send-card { flex-direction: column; align-items: flex-start; }
  .send-card-right { align-items: flex-start; }
  .modal-card { padding: 24px 20px; }
  .form-row { flex-direction: column; }
  .page-header { flex-direction: column; }
}
