/* Shared page frame (CAR-93): base, top bar, page card, forms, buttons,
   messages. Reuses the look login.html and the dashboard already have —
   structure only, not a new visual design. Every page links this file;
   page-specific layout stays in each page's own <style>. */

/* ── Base ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: #f0f4f8;
  color: #2d3748;
}
[hidden] { display: none !important; }

/* ── Top bar: app name + one action (back or logout) ──── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  padding: 12px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.topbar-name { font-size: 1.2rem; font-weight: 700; color: #1a202c; }
.topbar-action {
  background: none;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.9rem;
  color: #1a202c;
  text-decoration: none;
  cursor: pointer;
}
.topbar-action:hover { background: #f1f5f9; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Profile menu (built by menu.js) ──────────────────── */
/* Space kept for the icon before menu.js fills it, so nothing in the top bar jumps. */
.profile { position: relative; text-align: start; z-index: 10; min-width: 40px; min-height: 40px; }
.profile-btn {
  position: relative;
  width: 40px; height: 40px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}
.profile-btn:hover { background: #e2e8f0; }
.profile-btn .count {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #dc2626;
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
}
.profile-menu {
  position: absolute;
  top: 48px;
  inset-inline-end: 0;
  width: 260px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px 0;
}
.profile-menu .who {
  padding: 8px 14px 10px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
  font-size: 0.8rem;
  color: #64748b;
  overflow-wrap: anywhere;
}
.profile-menu .who strong { display: block; color: #1a202c; font-size: 0.9rem; }
.profile-menu a, .profile-menu button, .profile-menu label {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.9rem;
  color: #1a202c;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.profile-menu a:hover, .profile-menu button:hover { background: #f1f5f9; }
.profile-menu .logout { border-top: 1px solid #e2e8f0; margin-top: 4px; color: #dc2626; }

/* ── Page card ────────────────────────────────────────── */
.page {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.10);
  max-width: 560px;
  margin: 24px auto;
  padding: 28px 24px;
}
.page.narrow { max-width: 480px; }
@media (max-width: 600px) {
  .page { margin: 16px; padding: 22px 16px; }
}
.page h1 { font-size: 1.5rem; font-weight: 700; color: #1a202c; margin-bottom: 10px; }
.page h2 { font-size: 1.15rem; font-weight: 600; color: #1a202c; margin: 4px 0 10px; }
.page p { margin: 8px 0; line-height: 1.5; }
.page a { color: #0ea5e9; }
.muted { color: #64748b; }

/* ── Forms ────────────────────────────────────────────── */
.page label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin: 16px 0 6px;
}
.page input, .page select, .page textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 0.95rem;
  color: #1a202c;
  outline: none;
}
.page input:focus, .page select:focus, .page textarea:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14,165,233,0.12);
}

/* ── Field errors + date boxes (datefield.js, CAR-88) ─── */
/* Red border on a field with a problem (markInvalid, Form.mark, DateField).
   !important: some pages style their inputs more specifically (login, signup). */
input.invalid, select.invalid, textarea.invalid { border-color: #dc2626 !important; }
.field-error { color: #b91c1c; font-size: 0.85rem; margin-top: 4px; }
/* iPhone Safari zooms in when a box with text under 16px is tapped, and stays
   zoomed (the page then slides sideways). 16px on phones prevents that.
   !important: page styles such as the dashboard's .cell-input are smaller. */
@media (max-width: 640px) {
  input, select, textarea { font-size: 16px !important; }
}
/* Required field marker on labels, and the "* required" hint above a form */
.req { color: #b91c1c; }
.req-hint { color: #64748b; font-size: 0.8rem; margin: -6px 0 12px; }
.date-field { display: flex; align-items: center; gap: 8px; }
.date-field > input { flex: 1 1 auto; min-width: 0; max-width: 11em; }
.date-cal {
  position: relative;
  flex: none;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  cursor: pointer;
}
.date-cal:hover { background: #f1f5f9; }
/* The real (native) date input, invisible, covering the button. */
.date-cal input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0; border: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────────── */
.button {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 13px;
  background: #0ea5e9;
  color: #fff;
  border: 1.5px solid #0ea5e9;
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.button:hover { background: #0284c7; border-color: #0284c7; }
.button:disabled { background: #94a3b8; border-color: #94a3b8; cursor: not-allowed; }
.button.secondary { background: #fff; color: #1a202c; border-color: #cbd5e1; font-weight: 500; }
.button.secondary:hover { background: #f1f5f9; }
.button.secondary:disabled { color: #94a3b8; }
.button.small { display: inline-block; width: auto; margin: 10px 0 0; margin-inline-end: 8px; padding: 8px 16px; font-size: 0.9rem; }

/* ── Messages: hidden while empty ─────────────────────── */
.msg {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin: 16px 0 0;
}
.msg:empty { display: none; }
.msg.error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.msg.success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }

/* ── List boxes (invites, join requests) ──────────────── */
.item {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 0;
}
.item.highlight { border: 2px solid #0ea5e9; }
.item p { margin: 4px 0; overflow-wrap: break-word; }

/* Larger text on phones (CAR-95 phone test). Last in the file so it wins. */
@media (max-width: 640px) {
  .page label { font-size: 0.95rem; }
  .req-hint { font-size: 0.9rem; }
  .button { font-size: 1.05rem; }
}
