/* HearthSync — Main Stylesheet */
:root {
  --brand:       #6366f1;
  --brand-dark:  #4f46e5;
  --brand-light: #e0e7ff;
  --accent:      #f59e0b;
  --success:     #10b981;
  --danger:      #ef4444;
  --warn:        #f59e0b;

  --bg:          #f8fafc;
  --surface:     #ffffff;
  --surface2:    #f1f5f9;
  --border:      #e2e8f0;

  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;

  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.12);

  --sidebar-w:   240px;
  --font:        'Inter', sans-serif;
  --font-display:'Fraunces', serif;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-icon { font-size: 22px; }
.logo-text { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--brand); }
.household-name { font-size: 12px; color: var(--text-3); font-weight: 500; padding-left: 32px; }

.nav-links { list-style: none; padding: 12px 12px; flex: 1; }
.nav-links a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-links a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-links a:hover { background: var(--surface2); color: var(--text); }
.nav-links a.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: 1; padding: 8px; border-radius: var(--radius-sm); transition: background .15s; }
.user-chip:hover { background: var(--surface2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-3); transition: background .15s, color .15s; }
.logout-btn:hover { background: #fee2e2; color: var(--danger); }
.logout-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Mobile topbar ── */
.mobile-topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  align-items: center; padding: 0 16px; gap: 12px; z-index: 101;
}
.hamburger { background: none; border: none; cursor: pointer; color: var(--text); display: flex; }
.hamburger svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 99; }

/* ── Main layout ── */
body.has-nav .main-content { margin-left: var(--sidebar-w); }
body.no-nav .main-content { min-height: 100vh; }
.page-content { padding: 32px; max-width: 1100px; }

/* ── Page header ── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--text); }
.page-header p { color: var(--text-2); margin-top: 4px; font-size: 14px; }
.header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 16px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Auth pages ── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 60%, #fef9c3 100%);
  padding: 24px;
}
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 40px; box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 36px; display: block; margin-bottom: 6px; }
.auth-logo .logo-text { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--brand); }
.auth-logo p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.auth-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { font-size: 14px; color: var(--text-2); margin-bottom: 24px; }
.auth-footer { text-align: center; font-size: 13px; color: var(--text-3); margin-top: 20px; }
.auth-footer a { color: var(--brand); font-weight: 600; text-decoration: none; }

/* ── Alert / Flash ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info { background: var(--brand-light); color: var(--brand-dark); border: 1px solid #a5b4fc; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-num { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--brand); line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-2); margin-top: 4px; font-weight: 500; }

/* ── Chore cards ── */
.chore-list { display: flex; flex-direction: column; gap: 10px; }
.chore-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  transition: box-shadow .15s;
}
.chore-item:hover { box-shadow: var(--shadow-lg); }
.chore-check { width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 6px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.chore-check.done { background: var(--success); border-color: var(--success); }
.chore-check.done svg { display: block; }
.chore-check svg { display: none; width: 14px; height: 14px; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chore-info { flex: 1; min-width: 0; }
.chore-title { font-size: 15px; font-weight: 600; color: var(--text); }
.chore-title.done-text { text-decoration: line-through; color: var(--text-3); }
.chore-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.chore-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 100px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.badge-low { background: #f0fdf4; color: #16a34a; }
.badge-medium { background: #fffbeb; color: #b45309; }
.badge-high { background: #fef2f2; color: #dc2626; }
.badge-pending { background: var(--surface2); color: var(--text-2); }
.badge-in_progress { background: #eff6ff; color: #2563eb; }
.badge-done { background: #f0fdf4; color: #16a34a; }

/* ── Room cards ── */
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.room-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 20px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: box-shadow .15s, transform .15s; text-align: center;
}
.room-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.room-icon { font-size: 36px; }
.room-name { font-size: 15px; font-weight: 700; color: var(--text); }
.room-chore-count { font-size: 12px; color: var(--text-3); }
.room-actions { display: flex; gap: 6px; margin-top: 4px; }

/* ── Members list ── */
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface2); border-radius: var(--radius-sm); }
.member-info { flex: 1; }
.member-name { font-size: 14px; font-weight: 600; }
.member-email { font-size: 12px; color: var(--text-3); }
.member-role { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 100px; }
.role-admin { background: var(--brand-light); color: var(--brand-dark); }
.role-member { background: var(--surface2); color: var(--text-3); border: 1px solid var(--border); }

/* ── Modal ── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; padding: 28px;
  width: 100%; max-width: 480px; box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--text-3); line-height: 1; }

/* ── Activity feed ── */
.activity-feed { display: flex; flex-direction: column; gap: 2px; }
.activity-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex-shrink: 0; margin-top: 5px; }
.activity-text { font-size: 13px; color: var(--text-2); flex: 1; }
.activity-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Onboarding ── */
.onboard-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 100%); padding: 24px; }
.onboard-card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px; padding: 40px; box-shadow: var(--shadow-lg); }
.step-indicator { display: flex; gap: 8px; margin-bottom: 28px; }
.step-dot { height: 4px; flex: 1; border-radius: 2px; background: var(--border); transition: background .3s; }
.step-dot.active { background: var(--brand); }
.onboard-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.onboard-option {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 20px 16px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.onboard-option:hover, .onboard-option.selected { border-color: var(--brand); background: var(--brand-light); }
.onboard-option .opt-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.onboard-option .opt-label { font-size: 14px; font-weight: 600; color: var(--text); }
.invite-code-display {
  background: var(--surface2); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center; margin: 16px 0;
}
.invite-code { font-family: monospace; font-size: 28px; font-weight: 700; letter-spacing: 4px; color: var(--brand); }

/* ── Color picker ── */
.color-options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.color-swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: transform .15s; }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-2); }
.empty-state .empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 14px; }

/* ── Divider ── */
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--surface2); padding: 4px; border-radius: var(--radius-sm); width: fit-content; margin-bottom: 20px; }
.tab { padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; background: none; color: var(--text-2); transition: all .15s; }
.tab.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar.open ~ .sidebar-overlay,
  .sidebar-overlay:not([style]) { pointer-events: auto; }
  .mobile-topbar { display: flex; }
  body.has-nav .main-content { margin-left: 0; padding-top: 56px; }
  .page-content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .rooms-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .onboard-options { grid-template-columns: 1fr 1fr; }
  .header-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 420px) {
  .auth-card, .onboard-card { padding: 28px 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
