/* ==========================================================================
   Directory Page — Authentication & Directory Styles
   Depends on: css/style.css (for variables, .btn, .container, header styles)
   ========================================================================== */

/* ===== Page base ===== */

.directory-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.directory-page main,
.directory-page .auth-screen {
  flex: 1;
}

/* ===== Nav additions ===== */

.nav-page-title {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.btn-sign-out {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-sign-out:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ===== Auth screens ===== */

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 70px - 120px);
  padding: 3rem 1.5rem;
  background: var(--color-bg);
}

.auth-card {
  background: var(--color-bg-light);
  border: 1px solid rgba(45, 107, 181, 0.12);
  border-radius: 12px;
  box-shadow: 0 4px 32px rgba(45, 107, 181, 0.08);
  padding: 3rem 2.5rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.auth-card--denied {
  border-color: rgba(180, 60, 60, 0.2);
  box-shadow: 0 4px 32px rgba(180, 60, 60, 0.06);
}

.auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(45, 107, 181, 0.08);
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.auth-icon--denied {
  background: rgba(180, 60, 60, 0.08);
  color: #b43c3c;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--color-earth);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.auth-description {
  font-size: 0.95rem;
  color: var(--color-text-dark);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.auth-note {
  font-size: 0.8rem;
  color: #888;
  margin-top: 1.25rem;
  line-height: 1.5;
}

.denied-email {
  font-weight: 700;
  color: var(--color-text-dark);
  word-break: break-all;
}

/* Center the Google sign-in button */
.google-btn-wrap {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

/* ===== Directory hero ===== */

.directory-hero {
  background: var(--color-primary);
  color: #fff;
  padding: 3rem 0 2.5rem;
  text-align: center;
}

.directory-heading {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 900;
  color: #fff;
  margin-bottom: 0.5rem;
}

.directory-subheading {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.75rem;
}

.directory-welcome {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.user-name {
  font-weight: 700;
  color: #fff;
}

/* ===== Directory content ===== */

.directory-content {
  padding: 3rem 0 4rem;
}

.families-summary {
  font-size: 0.9rem;
  color: var(--color-earth);
  font-weight: 600;
  margin-bottom: 2rem;
  text-align: center;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ===== Family grid ===== */

.families-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.family-card {
  background: var(--color-bg-light);
  border: 1px solid rgba(45, 107, 181, 0.12);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(45, 107, 181, 0.06);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.family-card:hover {
  box-shadow: 0 6px 24px rgba(45, 107, 181, 0.13);
  transform: translateY(-2px);
}

.family-card-header {
  background: var(--color-primary);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.family-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  flex-shrink: 0;
}

.family-card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}

.family-card-body {
  padding: 1rem 1.25rem;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.member-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(45, 107, 181, 0.06);
  font-size: 0.9rem;
  color: var(--color-text-dark);
}

.member-item:last-child {
  border-bottom: none;
}

.member-name {
  flex: 1;
  font-weight: 600;
}

.member-role {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-earth);
  background: rgba(140, 90, 56, 0.1);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.member-notes {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}

.member-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.member-details {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  color: #888;
}

.member-detail {
  white-space: nowrap;
}

.member-detail-sep {
  color: #ccc;
  padding: 0 0.15rem;
}

.member-phone {
  color: var(--color-primary);
  text-decoration: none;
}

.member-phone:hover {
  text-decoration: underline;
}

.family-card-count {
  font-size: 0.78rem;
  color: #aaa;
  margin-top: 0.75rem;
  text-align: right;
}

/* ===== Announcements ===== */

.announcements-section {
  background: var(--color-bg);
  border-bottom: 1px solid rgba(45, 107, 181, 0.1);
  padding: 2.5rem 0;
}

.announcements-section .section-heading {
  font-size: 1.4rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.announcements-section .section-heading::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: var(--color-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.announcements-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.announcement-card {
  background: var(--color-bg-light);
  border: 1px solid rgba(217, 160, 48, 0.25);
  border-left: 4px solid var(--color-accent);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.announcement-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.announcement-date {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-earth);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.announcement-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

.announcement-body {
  font-size: 0.95rem;
  color: var(--color-text-dark);
  line-height: 1.6;
  margin: 0;
}

/* ===== Empty state ===== */

.directory-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: #888;
}

.directory-empty h2 {
  color: #aaa;
  font-size: 1.2rem;
}

/* ===== Responsive ===== */

@media (max-width: 640px) {
  .auth-card {
    padding: 2rem 1.5rem;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .nav-page-title {
    display: none;
  }
}

/* ==========================================================================
   Admin Mode — Nav button, family card edit button, announcement buttons
   ========================================================================== */

.btn-admin-mode {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  margin-right: 0.5rem;
}

.btn-admin-mode.btn-admin-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.btn-admin-mode:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btn-admin-edit-family {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  flex-shrink: 0;
}

.btn-admin-edit-family:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ann-admin-bar {
  margin-bottom: 0.75rem;
}

.btn-add-announcement {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.6rem;
  border: 2px dashed var(--color-accent);
  border-radius: 8px;
  background: transparent;
  color: var(--color-earth);
  font-weight: 700;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-add-announcement:hover {
  background: rgba(200, 146, 31, 0.06);
}

.ann-admin-actions {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  flex-shrink: 0;
}

.announcement-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-ann-edit,
.btn-ann-delete {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  border: 1px solid;
  cursor: pointer;
  font-family: var(--font-body);
  background: transparent;
}

.btn-ann-edit {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-ann-delete {
  color: #c0392b;
  border-color: #c0392b;
}

/* ==========================================================================
   Admin Panel — Leaders & Admins section
   ========================================================================== */

.admin-panel {
  background: #fff8ee;
  border-top: 3px solid var(--color-accent);
  padding: 2rem 0;
}

.admin-panel-heading {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.admin-list-card {
  background: var(--color-bg-light);
  border: 1px solid rgba(45, 107, 181, 0.12);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.admin-list-card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-email-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.admin-email-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(45, 107, 181, 0.06);
  gap: 0.5rem;
}

.btn-admin-remove {
  background: none;
  border: none;
  color: #c0392b;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.btn-admin-remove:hover {
  background: rgba(192, 57, 43, 0.08);
}

.admin-add-email {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-email-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid rgba(45, 107, 181, 0.25);
  border-radius: 4px;
  font-family: var(--font-body);
}

.btn-admin-add {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-body);
}

.btn-admin-add:hover {
  background: #1d4e8e;
}

.admin-actions-row {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* ==========================================================================
   Sticky Save All Changes button
   ========================================================================== */

.save-all-container {
  position: sticky;
  bottom: 1.5rem;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 200;
  padding: 0.5rem 0;
}

.btn-save-all {
  pointer-events: all;
  background: #27ae60;
  color: #fff;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  transition: background 0.15s, transform 0.15s;
}

.btn-save-all:hover:not(:disabled) {
  background: #219a52;
  transform: translateY(-2px);
}

.btn-save-all:disabled {
  opacity: 0.7;
  cursor: default;
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-dialog {
  background: var(--color-bg-light);
  border-radius: 12px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-dialog--wide {
  max-width: 820px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(45, 107, 181, 0.1);
  position: sticky;
  top: 0;
  background: var(--color-bg-light);
  z-index: 1;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #aaa;
  padding: 0 0.25rem;
}

.modal-close:hover {
  color: var(--color-text-dark);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(45, 107, 181, 0.1);
  position: sticky;
  bottom: 0;
  background: var(--color-bg-light);
}

/* ==========================================================================
   Form elements (inside modals)
   ========================================================================== */

.form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-earth);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: -0.25rem;
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(45, 107, 181, 0.25);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--color-text-dark);
  background: #fff;
  box-sizing: border-box;
}

.form-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: transparent;
}

.form-textarea {
  resize: vertical;
}

.form-section-heading {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 0.5rem 0 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(45, 107, 181, 0.08);
}

.btn-secondary {
  background: #f0f0f0;
  color: var(--color-text-dark);
  border: 1px solid #ddd;
  padding: 0.55rem 1.2rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-secondary:hover {
  background: #e4e4e4;
}

.btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-danger:hover {
  background: #a93226;
}

/* ==========================================================================
   Members editor (inside family modal)
   ========================================================================== */

.members-editor-labels {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.5fr 0.8fr 0.6fr 1fr 0.5fr 1.6rem;
  gap: 0.4rem;
  padding: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-earth);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.members-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.member-edit-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.5fr 0.8fr 0.6fr 1fr 0.5fr 1.6rem;
  gap: 0.4rem;
  align-items: center;
}

.member-edit-row .form-input {
  padding: 0.35rem 0.45rem;
  font-size: 0.82rem;
}

/* ==========================================================================
   Access emails editor (inside family modal)
   ========================================================================== */

.access-emails-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.access-email-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.access-email-input {
  flex: 1;
}

/* ==========================================================================
   Admin responsive overrides
   ========================================================================== */

@media (max-width: 640px) {
  .admin-panel-grid {
    grid-template-columns: 1fr;
  }

  .members-editor-labels {
    display: none;
  }

  .member-edit-row {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.35rem;
  }

  .member-edit-row .me-name,
  .member-edit-row .me-phone {
    grid-column: span 2;
  }

  .member-edit-row .btn-admin-remove {
    grid-column: 2;
    justify-self: end;
  }

  .modal-dialog--wide {
    max-width: 100%;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .btn-admin-mode {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }
}
