/* ============================================================
   Bonsai Social — App Stylesheet
   Premium organic design for a plant social network
   ============================================================ */

:root {
  --green-deep: #1a3a2a;
  --green-rich: #2d5a3f;
  --green-mid: #4a8c6a;
  --green-light: #7bc4a0;
  --green-pale: #c8edda;
  --cream: #faf8f2;
  --cream-warm: #f5f0e6;
  --brown-warm: #8b6d4f;
  --brown-light: #c4a67d;
  --text-dark: #1a2b1f;
  --text-mid: #4a5d50;
  --text-light: #7a8f80;
  --accent-coral: #e87c6a;
  --danger: #dc3545;
  --shadow-sm: 0 1px 3px rgba(26,58,42,0.06);
  --shadow-md: 0 4px 12px rgba(26,58,42,0.08), 0 2px 4px rgba(26,58,42,0.04);
  --shadow-lg: 0 12px 32px rgba(26,58,42,0.1), 0 4px 8px rgba(26,58,42,0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --nav-height: 64px;
}

/* ─── Reset & Base ─────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-weight: 400;
  line-height: 1.25;
  color: var(--text-dark);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }
a { color: var(--green-rich); text-decoration: none; }
a:hover { color: var(--green-deep); }
img { max-width: 100%; display: block; }

/* ─── Nav ─────────────────────────────────────── */
.app-nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  height: var(--nav-height);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(250, 248, 242, 0.88);
  border-bottom: 1px solid rgba(45, 90, 63, 0.08);
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--green-deep);
  text-decoration: none;
}
.nav-logo svg { width: 28px; height: 28px; }
.nav-logo:hover { color: var(--green-deep); }
.nav-center {
  display: flex;
  gap: 0.25rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-mid);
  text-decoration: none;
  transition: all 150ms ease;
}
.nav-link:hover { background: rgba(45, 90, 63, 0.06); color: var(--green-rich); }
.nav-link.active { background: var(--green-pale); color: var(--green-deep); font-weight: 600; }
.nav-right { display: flex; gap: 0.5rem; align-items: center; }

/* ─── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 200ms ease;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: var(--green-rich);
  color: white;
  box-shadow: 0 2px 8px rgba(45, 90, 63, 0.25);
}
.btn-primary:hover { background: var(--green-deep); color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(45, 90, 63, 0.3); }
.btn-secondary {
  background: transparent;
  color: var(--green-rich);
  border: 1.5px solid var(--green-rich);
}
.btn-secondary:hover { background: var(--green-rich); color: white; }
.btn-ghost {
  background: transparent;
  color: var(--text-mid);
}
.btn-ghost:hover { background: rgba(45, 90, 63, 0.06); color: var(--green-rich); }
.btn-danger { color: var(--accent-coral) !important; }
.btn-danger:hover { background: rgba(232, 124, 106, 0.08) !important; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ─── Forms ───────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input,
.form-group textarea,
.form-group select {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid rgba(45, 90, 63, 0.15);
  border-radius: var(--radius-md);
  background: white;
  color: var(--text-dark);
  transition: all 200ms ease;
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(74, 140, 106, 0.12);
}
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-light);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { cursor: pointer; }
.form-group small { font-size: 0.75rem; color: var(--text-light); }
.input-disabled { opacity: 0.6; cursor: not-allowed; background: var(--cream-warm) !important; }
.form-row { display: flex; gap: 1rem; }
.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.char-count {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: right;
}

/* ─── Main Layout ─────────────────────────────── */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 1.5rem) 1rem 3rem;
}

/* ─── Auth Pages ──────────────────────────────── */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: calc(var(--nav-height) + 4rem);
  min-height: 80vh;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: white;
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header h1 { margin-bottom: 0.5rem; }
.auth-header p { color: var(--text-mid); font-size: 0.95rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form .btn { margin-top: 0.5rem; }
.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-mid);
}
.auth-switch a { font-weight: 600; }
.auth-prompt {
  text-align: center;
  padding: 1rem;
  color: var(--text-mid);
  font-size: 0.9rem;
}

/* ─── Feed ────────────────────────────────────── */
.feed-page { max-width: 680px; }
.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.feed-posts { display: flex; flex-direction: column; gap: 1rem; }

/* ─── Post Cards ──────────────────────────────── */
.post-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 250ms ease;
}
.post-card:hover { box-shadow: var(--shadow-md); }
.post-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.post-author {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
}
.post-author:hover .post-username { color: var(--green-rich); }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-light), var(--green-mid));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.post-username {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dark);
  transition: color 150ms;
}
.post-badge {
  font-size: 0.68rem;
  background: var(--green-pale);
  color: var(--green-rich);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 500;
  margin-left: 0.35rem;
}
.post-time {
  display: block;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}
.post-content { margin-bottom: 0.75rem; }
.post-content p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-dark);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.post-content a { color: var(--green-mid); text-decoration: underline; }
.post-image {
  margin: 0.5rem -0.5rem 0.75rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.post-image img {
  width: 100%;
  max-height: 450px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 300ms ease;
}
.post-image img:hover { transform: scale(1.01); }
.post-actions {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(45, 90, 63, 0.06);
}
.post-action {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: 'Outfit', sans-serif;
  transition: all 200ms ease;
}
.post-action:hover { background: rgba(45, 90, 63, 0.06); color: var(--text-mid); }
.like-btn.liked { color: var(--accent-coral); }
.like-btn.liked svg { fill: var(--accent-coral); stroke: var(--accent-coral); }
.like-pop { animation: likePop 300ms ease; }
@keyframes likePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ─── Create Post / Card Form ─────────────────── */
.create-post-page, .plants-page, .settings-page, .post-detail-page, .profile-page {
  max-width: 680px;
}
.create-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}
.create-card h2 { margin-bottom: 1.5rem; }
.create-card form { display: flex; flex-direction: column; gap: 1rem; }

/* ─── Image Upload ────────────────────────────── */
.image-upload-section { display: flex; flex-direction: column; gap: 1rem; }
.upload-area {
  border: 2px dashed rgba(45, 90, 63, 0.2);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 200ms ease;
  overflow: hidden;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--green-mid);
  background: rgba(200, 237, 218, 0.15);
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
}
.upload-placeholder p { font-size: 0.9rem; color: var(--text-mid); }
.upload-placeholder span { font-size: 0.75rem; color: var(--text-light); }
#upload-preview { position: relative; }
#upload-preview img {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
}
#upload-preview .btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.5);
  color: white;
}

/* ─── Post Detail ────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--text-mid);
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--green-rich); }

/* ─── Comments ────────────────────────────────── */
.comments-section {
  background: white;
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-top: 1rem;
}
.comments-section h3 { margin-bottom: 1rem; }
.comment-form { margin-bottom: 1.25rem; }
.comment-input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.comment-input-row input {
  flex: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid rgba(45, 90, 63, 0.15);
  border-radius: var(--radius-full);
  outline: none;
  background: var(--cream);
  transition: all 200ms ease;
}
.comment-input-row input:focus {
  border-color: var(--green-mid);
  box-shadow: 0 0 0 3px rgba(74, 140, 106, 0.12);
  background: white;
}
.comments-list { display: flex; flex-direction: column; gap: 0.75rem; }
.no-comments { text-align: center; color: var(--text-light); padding: 1rem; font-size: 0.9rem; }
.comment {
  display: flex;
  gap: 0.6rem;
}
.comment-author { flex-shrink: 0; text-decoration: none; }
.comment-body {
  background: var(--cream);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  flex: 1;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.comment-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-dark);
  text-decoration: none;
}
.comment-name:hover { color: var(--green-rich); }
.comment-time { font-size: 0.7rem; color: var(--text-light); }
.comment-body p { font-size: 0.88rem; line-height: 1.5; }

/* ─── Profile ─────────────────────────────────── */
.profile-header {
  background: white;
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  position: relative;
}
.profile-avatar-large .avatar {
  width: 80px;
  height: 80px;
  font-size: 2rem;
}
.profile-info { flex: 1; }
.profile-info h1 { font-size: 1.75rem; margin-bottom: 0.15rem; }
.profile-username { color: var(--text-light); font-size: 0.9rem; }
.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  align-items: center;
}
.profile-location {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-mid);
}
.profile-badge {
  font-size: 0.72rem;
  background: var(--green-pale);
  color: var(--green-rich);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.profile-joined { font-size: 0.8rem; color: var(--text-light); }
.profile-bio {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-mid);
}
.profile-header > .btn { position: absolute; top: 1.5rem; right: 1.5rem; }
.profile-stats {
  display: flex;
  gap: 0;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.stat {
  flex: 1;
  text-align: center;
  padding: 1rem;
  border-right: 1px solid rgba(45, 90, 63, 0.06);
}
.stat:last-child { border-right: none; }
.stat-number {
  display: block;
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  color: var(--green-deep);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.profile-section { margin-bottom: 1.5rem; }
.profile-section > h3 { margin-bottom: 1rem; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* ─── Plant Collection ────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.plant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.plant-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 250ms ease;
}
.plant-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.plant-card-image {
  height: 160px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--green-light), var(--green-mid));
}
.plant-card-image img { width: 100%; height: 100%; object-fit: cover; }
.plant-placeholder-lg {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, var(--green-pale), var(--green-light));
}
.plant-card-body { padding: 0.85rem; }
.plant-card-body h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}
.plant-species { font-size: 0.8rem; color: var(--text-mid); font-style: italic; }
.plant-notes {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.plant-date { font-size: 0.72rem; color: var(--text-light); margin-top: 0.3rem; display: block; }
.plant-card-actions {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.85rem;
  border-top: 1px solid rgba(45, 90, 63, 0.06);
}

/* Mini plant grid on profile */
.plant-grid-mini {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.plant-card-mini {
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all 250ms ease;
}
.plant-card-mini:hover { box-shadow: var(--shadow-md); }
.plant-card-mini img {
  width: 100%;
  height: 100px;
  object-fit: cover;
}
.plant-placeholder {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--green-pale), var(--green-light));
}
.plant-card-info { padding: 0.5rem 0.6rem; }
.plant-name { font-weight: 600; font-size: 0.82rem; display: block; }
.plant-card-info .plant-species { font-size: 0.72rem; }

/* ─── Loading & Empty States ──────────────────── */
.loading-skeleton { display: flex; flex-direction: column; gap: 1rem; }
.skeleton-card {
  background: white;
  border-radius: var(--radius-xl);
  height: 180px;
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(74, 140, 106, 0.05), transparent);
  animation: shimmer 1.5s ease infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h3 { margin-bottom: 0.35rem; }
.empty-state p { color: var(--text-mid); font-size: 0.95rem; }

/* ─── Toast Notifications ─────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--green-deep);
  color: white;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 340px;
}
.toast-visible { transform: translateX(0); }
.toast-error { background: var(--accent-coral); }
.toast-success { background: var(--green-rich); }
.toast-info { background: var(--brown-warm); }

/* ─── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
  animation: fadeIn 200ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content { position: relative; cursor: default; max-width: 90vw; max-height: 90vh; }
.image-modal img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-close {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: transform 150ms;
}
.modal-close:hover { transform: scale(1.1); }

/* ─── Responsive ──────────────────────────────── */
@media (max-width: 640px) {
  .app-nav { padding: 0 0.75rem; }
  .nav-center { display: none; }
  .nav-logo span { display: none; }
  main { padding: calc(var(--nav-height) + 1rem) 0.75rem 2rem; }
  .auth-card { padding: 1.5rem; border-radius: var(--radius-lg); }
  .form-row { flex-direction: column; gap: 0.75rem; }
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .profile-header > .btn { position: static; margin-top: 0.5rem; }
  .profile-meta { justify-content: center; }
  .post-card { border-radius: var(--radius-lg); padding: 1.15rem; }
  .plant-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .plant-grid-mini { grid-template-columns: repeat(3, 1fr); }
  .create-card { padding: 1.25rem; }
  .feed-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  .page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
  #toast-container { bottom: 0.75rem; right: 0.75rem; left: 0.75rem; }
  .toast { max-width: 100%; }
}

/* Mobile bottom nav for small screens */
@media (max-width: 640px) {
  .nav-right .btn:not(:last-child) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
