/* ============================================================
   main.css — FamilyHub base styles
   Dark-first, Skylight-inspired clean design
============================================================ */

/* ── Global mobile overflow guard ───────────────────────── */
html,
body {
  overflow-x: hidden;
  max-width: 100%;
}

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1f2937;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #4A90D9;
  --accent-hover: #5ba3f5;
  --danger: #E74C3C;
  --success: #27AE60;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: 'Inter', system-ui, sans-serif;
  --nav-h: 44px;
}

[data-theme="light"] {
  --bg: #f0f4f8;
  --bg-card: #ffffff;
  --bg-hover: #e8edf2;
  --border: #d0d7de;
  --text: #1c1e21;
  --text-muted: #656d76;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

button {
  cursor: pointer;
  font-family: var(--font);
}

input,
textarea,
select {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
}

/* ── Top Nav ─────────────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  z-index: 100;
  gap: 0;
  overflow: hidden;
  /* never let nav overflow on any device */
  white-space: nowrap;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  margin-right: 28px;
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.nav-tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-tab:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-tab.active {
  background: var(--accent)18;
  color: var(--accent);
  font-weight: 600;
}

.nav-right {
  margin-left: auto;
  flex-shrink: 0;
}

.nav-icon-btn {
  font-size: 1.2rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.15s;
  white-space: nowrap;
}

.nav-icon-btn:hover {
  background: var(--bg-hover);
}

/* ── Mobile: collapse nav tab labels ────────────────────── */
@media (max-width: 540px) {
  .nav-logo {
    margin-right: 12px;
    font-size: 1rem;
  }

  .nav-tab {
    padding: 6px 10px;
    font-size: 0.82rem;
  }

  .nav-logout-btn span {
    display: none;
  }

  /* hide text, keep icon */
}

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* allow settings/meal-planner pages to scroll */
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger-sm {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-connect-sm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ── Modal overlay ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(480px, 94vw);
  box-shadow: var(--shadow);
  animation: fadeIn 0.18s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.modal-body label input,
.modal-body label textarea {
  margin-top: 2px;
  width: 100%;
}

.modal-row {
  display: flex;
  gap: 12px;
}

.modal-row label {
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

/* ── Event detail popup ──────────────────────────────────── */
.event-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(360px, 92vw);
  box-shadow: var(--shadow);
  z-index: 400;
  animation: fadeIn 0.15s ease;
}

.event-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
}

.event-popup-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.popup-location-link {
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent);
  transition: border-color 0.15s, opacity 0.15s;
}

.popup-location-link:hover {
  opacity: 0.8;
  border-bottom-style: solid;
}

.popup-location-link::after {
  content: "↗";
  font-size: 0.75em;
  opacity: 0.7;
}

/* ── Setup page ──────────────────────────────────────────── */
.setup-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
}

.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 44px;
  max-width: 440px;
  text-align: center;
  box-shadow: var(--shadow);
}

.setup-logo {
  font-size: 3rem;
  margin-bottom: 12px;
}

.setup-card h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.setup-subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
}

.setup-features {
  text-align: left;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

.setup-feature {
  color: var(--text-muted);
}

.setup-instruction {
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.setup-instruction small {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.btn-connect {
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #333;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: box-shadow 0.15s, transform 0.1s;
}

.btn-connect:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  color: #333;
}

.btn-connect:active {
  transform: scale(0.98);
}

.setup-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}
