/* Auth screens (login, signup, no-host), app tabs, and settings. Mobile-first. */

.auth-screen {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 100vh;
  background: #f8fafc;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
}

.auth-title {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}

.auth-text {
  margin: 8px 0;
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.45;
}

.auth-text a {
  color: #2563eb;
  text-decoration: none;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.auth-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-top: 8px;
}

.auth-input {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  background: #ffffff;
  color: #0f172a;
}

.auth-input:focus {
  outline: 2px solid #2563eb;
  outline-offset: -1px;
}

.auth-button {
  margin-top: 14px;
  padding: 11px 12px;
  border: none;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.auth-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.auth-error {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #dc2626;
}

.auth-link-button {
  margin-top: 14px;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  color: #64748b;
  text-decoration: underline;
  cursor: pointer;
}

/* Role picker (signup) */

.auth-role-picker {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.auth-role {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.auth-role.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.auth-role-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: #64748b;
}

/* App nav (top bar + drawer) */

.app-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.app-nav-burger {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #475569;
  padding: 6px 8px;
  cursor: pointer;
}

.app-nav-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
}

.app-nav-host {
  font-size: 0.8rem;
  color: #64748b;
}

/* Admin dashboard: the host list a sysadmin picks a view from */
.admin-host-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-host-enter {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.admin-host-enter:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.admin-host-enter.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.app-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
}

.app-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 80vw);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  box-shadow: 2px 0 16px rgba(15, 23, 42, 0.15);
}

.app-drawer-user {
  font-size: 0.8rem;
  color: #64748b;
  padding: 4px 14px 12px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 8px;
}

.app-drawer-link {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  text-decoration: none;
}

.app-drawer-link.active {
  background: #eff6ff;
  color: #2563eb;
}

.app-drawer-spacer {
  flex: 1;
}

.app-drawer-signout {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.9rem;
  color: #475569;
  cursor: pointer;
}

/* Settings */

.settings-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  /* This is a flex child of <body>; without min-width:0 a wide child (e.g. the
     MUI DataGrid's intrinsic column width) forces it past the viewport. */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.settings-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin: 8px 0 16px;
}

.settings-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 12px;
}

.settings-members {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Same row pattern as .settings-property (grid, 1fr column shrinks): the
   name·email cell truncates instead of pushing the row past the viewport. */
.settings-member {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #334155;
}

.settings-member-info {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-member-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.settings-member-role {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 0.8rem;
  color: #475569;
}

.settings-member-remove {
  background: none;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.settings-add-member {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-section + .settings-section {
  margin-top: 16px;
}

.settings-new-token {
  border: 1px solid #fbbf24;
  background: #fffbeb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.settings-token-value {
  display: block;
  word-break: break-all;
  font-size: 0.85rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  user-select: all;
}

@media (min-width: 640px) {
  .settings-add-member {
    flex-direction: row;
  }

  .settings-add-member .auth-input {
    flex: 1;
  }
}


/* ---- Properties (M3.5-E) — mobile-first ------------------------------- */

.settings-properties {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-property {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px 10px;
  font-size: 0.9rem;
  color: #334155;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

/* The subscribe link sits under the property, spanning the full row. */
.settings-property-feed {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
}

.settings-property-feed-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #94a3b8;
  flex: 0 0 auto;
}

.settings-property-feed-url {
  flex: 1 1 200px;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: #475569;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-property-feed-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.settings-property.is-inactive {
  opacity: 0.55;
}

.settings-property-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.settings-property-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.settings-property-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-property-meta {
  font-size: 0.75rem;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-property-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.settings-property-action {
  background: none;
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.settings-property-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.settings-property-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
  margin-bottom: 12px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
}

/* Inputs default to an intrinsic ~20ch minimum and won't shrink with their
   field — two side-by-side would overflow a phone viewport. */
.settings-field .auth-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.settings-field > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

.settings-field-row {
  display: flex;
  gap: 10px;
}

.auth-button.is-secondary {
  background: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Profile page */
.profile-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: #334155;
}

.profile-facts li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.profile-fact-label {
  flex: 0 0 72px;
  font-size: 0.78rem;
  color: #64748b;
}

/* Admin Users list: per-row set-password form */
.admin-user + .admin-user {
  margin-top: 8px;
}

.admin-user-password {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.admin-user-password .auth-input {
  flex: 1;
  min-width: 0;
}

.admin-user-password .auth-button {
  margin-top: 0;
  flex: 0 0 auto;
}

/* Neutral (non-danger) per-row action in member/user lists. */
.settings-member-neutral {
  background: none;
  border: 1px solid #cbd5e1;
  color: #475569;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Change-password form on the profile page (always stacked). */
.profile-password-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Admin blocks rendered directly under another section. */
.settings-page.is-flush {
  padding-top: 0;
}

/* Profile facts shown below the editable details form. */
.profile-facts-below {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

/* Admin Users: per-row edit form (stacked inputs) + disabled-row dimming. */
.admin-user-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.admin-user.is-disabled .settings-member-info {
  color: #94a3b8;
  text-decoration: line-through;
}
