/* ==========================================================================
   Website members (shared/site-auth.js): Google login button, member menu,
   role picker, landlord listing form & lists. Uses the tokens in styles.css
   so it follows the dark header / light dialog look of the rest of the site.
   ========================================================================== */

/* ---------- header slot ---------- */
.auth-slot { display: flex; align-items: center; }

.sa-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 14px 6px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.sa-login-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.3); transform: translateY(-1px); }
.sa-login-btn:focus-visible,
.sa-user-btn:focus-visible,
.sa-menu-item:focus-visible,
.sa-role-card:focus-visible,
.sa-btn:focus-visible,
.sa-close:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

.sa-google-icon {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 3px;
  border-radius: 50%;
  background: #fff;
}
.sa-login-btn--block { width: 100%; min-height: 46px; font-size: 0.9rem; border-radius: var(--radius-md); }
.sa-login-btn--light { background: #fff; color: var(--text-dark); border-color: var(--border-light); box-shadow: var(--shadow-card); min-height: 46px; padding: 8px 18px 8px 10px; font-size: 0.9rem; }
.sa-login-btn--light:hover { background: #fafafa; border-color: #d5d3cc; }

/* ---------- avatar + dropdown ---------- */
.sa-user { position: relative; }
.sa-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 3px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 220px;
}
.sa-user-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sa-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-caret { flex: none; opacity: 0.7; transition: transform 0.2s; }
.sa-user-btn[aria-expanded="true"] .sa-caret { transform: rotate(180deg); }

.sa-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-gradient);
}
.sa-avatar--initial { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.85rem; }
.sa-avatar--lg { width: 42px; height: 42px; font-size: 1.05rem; }

.sa-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 260;
  width: min(290px, calc(100vw - 24px));
  padding: 8px;
  border-radius: var(--radius-lg);
  background: var(--bg-dark-3);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  color: #fff;
}
.sa-menu[hidden] { display: none; }
.sa-menu-head,
.sa-mobile-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 12px;
}
.sa-menu-head { border-bottom: 1px solid var(--border-dark); margin-bottom: 6px; }
.sa-menu-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sa-menu-id strong { font-family: var(--font-heading); font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-menu-id > span { font-size: 0.74rem; color: var(--on-dark-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sa-role-badge {
  align-self: flex-start;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem !important;
  font-weight: 600;
  color: #fff !important;
  background: rgba(255, 255, 255, 0.12);
}
.sa-role-badge--landlord { background: rgba(255, 190, 11, 0.22); color: #ffd666 !important; }
.sa-role-badge--tenant { background: rgba(138, 99, 248, 0.28); color: #d2c8fd !important; }

.sa-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.sa-menu-item:hover { background: rgba(255, 255, 255, 0.07); }
.sa-menu-item--muted { color: var(--on-dark-muted); border-top: 1px solid var(--border-dark); border-radius: 0 0 var(--radius-md) var(--radius-md); margin-top: 6px; }
.sa-item-icon { display: inline-flex; width: 20px; justify-content: center; opacity: 0.85; }

/* ---------- mobile drawer ---------- */
.mobile-auth-links:empty { display: none; }
.sa-mobile-user { padding: 10px 4px 6px; color: #fff; }
.sa-logout-btn {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- dialog ---------- */
body.sa-lock { overflow: hidden; }
.sa-backdrop {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 3, 5, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.sa-backdrop[hidden] { display: none; }
.sa-dialog {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-xl);
  background: var(--bg-page);
  color: var(--text-dark);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.sa-dialog--wide { max-width: 820px; }
.sa-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-dark-2);
  color: #fff;
}
.sa-dialog-head h2 { margin: 0; font-family: var(--font-heading); font-size: 1.1rem; font-weight: 700; }
.sa-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.sa-close:hover { background: rgba(255, 255, 255, 0.1); }
.sa-dialog-body { padding: 20px; overflow-y: auto; overscroll-behavior: contain; }

.sa-lead { margin: 0 0 16px; color: var(--text-secondary); font-size: 0.92rem; line-height: 1.55; }
.sa-note { margin: 0 0 14px; padding: 10px 12px; border-radius: var(--radius-md); background: #fff; border: 1px solid var(--border-light); color: var(--text-secondary); font-size: 0.82rem; }
.sa-loading,
.sa-empty { padding: 28px 8px; text-align: center; color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }
.sa-empty-small { margin: 0; color: var(--text-muted); font-size: 0.82rem; }

/* role picker */
.sa-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sa-role-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 16px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border-light);
  background: #fff;
  color: var(--text-dark);
  text-align: left;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.sa-role-card:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-accent); transform: translateY(-2px); }
.sa-role-card:disabled { opacity: 0.6; cursor: wait; }
.sa-role-card strong { font-family: var(--font-heading); font-size: 1.05rem; }
.sa-role-card span:last-child { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.45; }
.sa-role-emoji { font-size: 1.8rem; line-height: 1; }

/* buttons */
.sa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-dark);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.sa-btn:hover { border-color: #cfcdc5; background: #fafaf8; }
.sa-btn:disabled { opacity: 0.6; cursor: wait; }
.sa-btn--primary { background: var(--accent-gradient); border-color: transparent; color: #fff; box-shadow: var(--shadow-accent); }
.sa-btn--primary:hover { background: var(--accent-gradient-hover); border-color: transparent; }
.sa-btn--ghost { background: transparent; }
.sa-btn--danger { color: #b42318; }
.sa-btn--danger:hover { background: #fff1f0; border-color: #f4b8b2; }
.sa-btn--sm { min-height: 34px; padding: 6px 12px; font-size: 0.8rem; }
.sa-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.sa-actions--center { justify-content: center; }

/* form */
.sa-form { display: flex; flex-direction: column; gap: 14px; }
.sa-fieldset { margin: 0; padding: 14px 16px 16px; border: 1px solid var(--border-light); border-radius: var(--radius-lg); background: #fff; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sa-fieldset legend { padding: 0 6px; font-family: var(--font-heading); font-weight: 700; font-size: 0.92rem; }
.sa-fieldset legend small { font-family: var(--font-ui); font-weight: 400; color: var(--text-muted); }
.sa-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sa-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.sa-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sa-field > span { font-size: 0.78rem; font-weight: 600; color: var(--text-dark-2); }
.sa-field input,
.sa-field select,
.sa-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-dark);
  font-family: var(--font-ui);
  font-size: 16px; /* no zoom on iOS */
}
.sa-field textarea { resize: vertical; line-height: 1.5; }
.sa-field input:focus,
.sa-field select:focus,
.sa-field textarea:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(138, 99, 248, 0.18); }
.sa-hint { font-size: 0.76rem; color: var(--text-muted); min-height: 1em; }
.sa-checks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; }
.sa-check { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; color: var(--text-dark-2); min-height: 32px; }
.sa-check input { width: 18px; height: 18px; accent-color: var(--accent-secondary); }

.sa-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.sa-photo { position: relative; margin: 0; aspect-ratio: 4 / 3; border-radius: var(--radius-md); overflow: hidden; background: #eee; }
.sa-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sa-photo figcaption { position: absolute; left: 6px; bottom: 6px; padding: 2px 7px; border-radius: var(--radius-pill); background: rgba(3, 3, 5, 0.7); color: #fff; font-size: 0.68rem; font-weight: 600; }
.sa-photo-remove { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(3, 3, 5, 0.72); color: #fff; font-size: 1rem; line-height: 1; cursor: pointer; }
.sa-upload { position: relative; display: inline-flex; align-self: flex-start; align-items: center; justify-content: center; min-height: 42px; padding: 8px 16px; border: 1.5px dashed #c9c6bc; border-radius: var(--radius-md); color: var(--text-dark-2); font-size: 0.86rem; font-weight: 600; cursor: pointer; }
.sa-upload:hover { border-color: var(--accent-primary); color: var(--accent-secondary); }
.sa-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sa-form-error { padding: 10px 12px; border-radius: var(--radius-md); background: #fff1f0; border: 1px solid #f4b8b2; color: #b42318; font-size: 0.86rem; }
.sa-form-error[hidden] { display: none; }

/* lists */
.sa-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; color: var(--text-muted); font-size: 0.85rem; }
.sa-item { display: flex; gap: 14px; padding: 12px; margin-bottom: 10px; border-radius: var(--radius-lg); background: #fff; border: 1px solid var(--border-light); }
.sa-item-thumb { flex: none; width: 132px; height: 99px; border-radius: var(--radius-md); object-fit: cover; background: #ece9e1; }
.sa-item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.sa-item-main h3 { margin: 0; font-family: var(--font-heading); font-size: 0.98rem; font-weight: 700; color: var(--text-dark); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sa-item-meta { font-size: 0.8rem; color: var(--text-muted); }
.sa-item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.sa-chip { display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 0.72rem; font-weight: 700; }
.sa-chip--pending { background: #fff4d6; color: #8a5a00; }
.sa-chip--approved { background: #e3f6ea; color: #17663a; }
.sa-chip--rejected { background: #ffe6e3; color: #b42318; }
.sa-chip--done { background: #eceaf9; color: #4a35d4; }
.sa-reject { padding: 9px 11px; border-radius: var(--radius-md); background: #fff6f5; border: 1px solid #f4c7c1; color: #8f1d14; font-size: 0.82rem; line-height: 1.5; }
.sa-reject span { color: #a8483e; }

.sa-timeline { list-style: none; margin: 0; padding: 0; }
.sa-timeline-item { display: flex; gap: 14px; padding: 12px; margin-bottom: 10px; border-radius: var(--radius-lg); background: #fff; border: 1px solid var(--border-light); }
.sa-timeline-date { flex: none; min-width: 96px; padding: 8px; border-radius: var(--radius-md); background: var(--bg-dark-2); color: #fff; font-family: var(--font-heading); font-weight: 700; font-size: 0.85rem; text-align: center; align-self: flex-start; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .sa-user-name { max-width: 90px; }
}

@media (max-width: 768px) {
  /* Top bar keeps a compact Google / avatar button next to the hamburger, on one line */
  .top-bar .header-actions { flex-wrap: nowrap; flex: none; }
  .top-bar .brand-logo { min-width: 0; }
  .top-bar .brand-text-group,
  .top-bar .brand-domain { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sa-login-btn:not(.sa-login-btn--block):not(.sa-login-btn--light) { padding: 4px; min-height: 36px; min-width: 36px; }
  .sa-login-btn:not(.sa-login-btn--block):not(.sa-login-btn--light) .sa-login-text { display: none; }
  .sa-user-btn { padding: 3px; }
  .sa-user-name,
  .sa-caret { display: none; }
  .sa-avatar { width: 30px; height: 30px; }
  .sa-avatar--lg { width: 42px; height: 42px; }
  .sa-menu { position: fixed; top: 60px; right: 12px; }

  .sa-backdrop { padding: 0; align-items: flex-end; }
  .sa-dialog,
  .sa-dialog--wide { max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .sa-dialog-body { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .sa-role-grid,
  .sa-grid-2 { grid-template-columns: 1fr; }
  .sa-grid-4 { grid-template-columns: 1fr 1fr; }
  .sa-checks { grid-template-columns: 1fr 1fr; }
  .sa-item { gap: 10px; padding: 10px; }
  .sa-item-thumb { width: 96px; height: 72px; }
  .sa-timeline-date { min-width: 76px; font-size: 0.78rem; }
  .sa-actions { position: sticky; bottom: -16px; margin: 18px -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg-page); border-top: 1px solid var(--border-light); }
  .sa-actions .sa-btn { flex: 1; }
}

@media (max-width: 400px) {
  .top-bar .brand-domain .tld { display: none; }
}
