/* ============================================================
   FamilyList — Clean Minimal Stylesheet
   ============================================================ */

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

:root {
  --bg:         #ffffff;
  --surface:    #f8f9fa;
  --border:     #e2e8f0;
  --text:       #1a202c;
  --muted:      #718096;
  --accent:     #3b82f6;
  --accent-dk:  #2563eb;
  --danger:     #ef4444;
  --success:    #10b981;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

/* ── Layout ───────────────────────────────────────────────── */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 660px;
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  padding: .3rem .55rem;
  border-radius: var(--radius);
  transition: color .15s;
}
nav a:hover { color: var(--accent); }
.nav-form { display: inline; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .875rem;
  font-family: inherit;
  padding: .3rem .55rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-link:hover { color: var(--accent); }

.container {
  max-width: 660px;
  margin: 0 auto;
  padding: 1.5rem 1rem 5rem;
}

.site-footer {
  text-align: center;
  padding: 1.25rem 1rem;
  color: var(--muted);
  font-size: .8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
  line-height: 1.4;
}
.flash--info    { background: #eff6ff; color: #1d4ed8; }
.flash--success { background: #f0fdf4; color: #15803d; }
.flash--error   { background: #fef2f2; color: #b91c1c; }

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

/* ── Typography helpers ───────────────────────────────────── */
.page-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  line-height: 1.2;
}
.section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2.5rem 0;
  font-size: .95rem;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .3rem;
}
input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .6rem 1.2rem;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, filter .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { filter: brightness(.93); }
.btn-primary { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-sm   { padding: .35rem .75rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── Dashboard — list grid ────────────────────────────────── */
.list-grid { display: grid; gap: .6rem; }

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.list-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}
.list-card-body { flex: 1; min-width: 0; }
.list-card-name {
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-card-meta {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}

/* ── Shopping list page ───────────────────────────────────── */
.add-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}
.add-form .field-name { flex: 1; min-width: 0; }
.add-form .field-qty  { width: 85px; flex-shrink: 0; }

.items-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.item-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--surface); }

/* Circular check button */
.item-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color .15s, background .15s;
  padding: 0;
}
.item-check:hover { border-color: var(--accent); }
.item-check.is-done {
  background: var(--success);
  border-color: var(--success);
}
.item-check.is-done::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-50%, -60%);
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -1px;
}

.item-body { flex: 1; min-width: 0; }
.item-name {
  font-size: .95rem;
  word-break: break-word;
}
.item-name.is-done {
  text-decoration: line-through;
  color: var(--muted);
}
.item-qty {
  font-size: .8rem;
  color: var(--muted);
  margin-left: .35rem;
}
.item-meta {
  font-size: .75rem;
  color: var(--muted);
  margin-top: .1rem;
}

.item-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: .25rem .4rem;
  border-radius: 4px;
  opacity: .35;
  transition: opacity .15s, color .15s;
  flex-shrink: 0;
}
.item-delete:hover { opacity: 1; color: var(--danger); }

/* Done section */
.done-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  margin-bottom: .4rem;
  padding: 0 .1rem;
}
.done-list { opacity: .75; }

/* Live indicator */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--muted);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

/* ── Admin — user table ───────────────────────────────────── */
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.user-table th,
.user-table td {
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.user-table th {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: var(--surface);
}
.user-table tr:last-child td { border-bottom: none; }
.user-table tbody tr:hover { background: var(--surface); }

.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-admin  { background: #eff6ff; color: #1d4ed8; }
.badge-member { background: #f0fdf4; color: #15803d; }

.table-actions { display: flex; gap: .4rem; justify-content: flex-end; }

/* Edit-in-row form */
.edit-row-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  margin-bottom: .5rem;
}
.edit-row-form input,
.edit-row-form select { font-size: .875rem; padding: .45rem .6rem; }
.edit-row-actions { display: flex; gap: .4rem; margin-top: .3rem; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
  max-width: 360px;
  margin: 3.5rem auto 0;
}
.login-hero {
  text-align: center;
  font-size: 2.75rem;
  margin-bottom: .4rem;
}
.login-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden  { display: none !important; }
.row     { display: flex; align-items: center; gap: .75rem; }
.row-sb  { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.mt-1    { margin-top: .5rem; }
.mt-2    { margin-top: 1rem; }
.mb-1    { margin-bottom: .75rem; }
.mb-2    { margin-bottom: 1.25rem; }

/* ── User dropdown menu ───────────────────────────────────── */
.user-menu { position: relative; }
.user-menu-toggle { white-space: nowrap; }

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  min-width: 170px;
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.dropdown-item {
  display: block;
  width: 100%;
  padding: .6rem 1rem;
  text-align: left;
  background: none;
  border: none;
  font-size: .875rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .1s;
}
.dropdown-item:hover { background: var(--surface); }
.dropdown-item--danger { color: var(--danger); }
.user-dropdown form { margin: 0; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none !important; }
.modal-box {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  padding: 1.5rem;
  width: 100%;
  max-width: 380px;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.1rem;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 500px) {
  .header-inner { padding: .6rem .75rem; }
  .logo { font-size: .95rem; }
  nav a, .btn-link { font-size: .8rem; padding: .25rem .4rem; }
  .page-title { font-size: 1.25rem; }
  .add-form { flex-wrap: wrap; }
  .add-form .field-qty { width: 70px; }
  .add-form .btn { width: 100%; }
  .user-table { font-size: .8rem; }
  .user-table th, .user-table td { padding: .5rem .5rem; }
  .edit-row-form { grid-template-columns: 1fr; }
}
