/* The Family App — Shared styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1c2030;
  --surface2: #272d3e;
  --border: #3a4058;
  --text: #f0f0f3;
  --text-muted: #a0a3b4;
  --primary: #818cf8;
  --primary-dim: #6366f1;
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.2);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.2);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.2);
  --yellow: #facc15;
  --yellow-dim: rgba(250, 204, 21, 0.2);
  --pink: #f472b6;
  --pink-dim: rgba(244, 114, 182, 0.2);
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font: -apple-system-body;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.hidden { display: none !important; }

/* Update banner */
#update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: var(--primary-dim);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Shared button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--surface2); border-color: var(--primary-dim); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary); }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--text); }

/* Version hash display in header */
#version-hash { font-size: 0.55rem; font-weight: 400; color: var(--text-muted); opacity: 0.5; vertical-align: middle; }

/* Auto-refresh update banner */
#update-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--primary-dim);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.hidden { display: none !important; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* Input */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* Standardized app header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  gap: 8px;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.app-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-switcher-btn:hover {
  background: var(--surface2);
  border-color: var(--primary-dim);
  color: var(--primary);
}

.app-switcher-btn:active {
  transform: scale(0.93);
}

.app-switcher-btn svg {
  width: 18px;
  height: 18px;
}

.app-header-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.app-header-suite {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.app-header-right #user-name {
  color: var(--text-muted);
  font-weight: 600;
}

/* Backup health warning banner (admin-only, shown when backups are stale) */
.backup-warning-banner {
  background: var(--orange, #f59e0b);
  color: #fff;
  text-align: center;
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* Shared header menu (hamburger dropdown) */
.header-menu-container {
  position: relative;
}
.header-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.header-menu-btn:hover { background: var(--surface2); color: var(--primary); border-color: var(--primary-dim); }
.header-menu-btn svg { width: 18px; height: 18px; }
.header-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 140px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}
.header-menu-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.header-menu-item:last-child { border-bottom: none; }
.header-menu-item:hover, .header-menu-item:active { background: var(--surface2); }
