/* ============================================================
   Photo Cropper Modal
   ============================================================ */
.crop-upload-state {
  padding: 16px;
}

.crop-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-light);
}
.crop-dropzone:hover,
.crop-dropzone.drag-over {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}
.crop-dropzone p {
  margin: 0;
  font-size: var(--text-base);
}
.crop-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.crop-area {
  padding: 16px;
}

.crop-viewport {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: #111;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.crop-viewport:active {
  cursor: grabbing;
}

#crop-canvas {
  position: absolute;
  top: 0;
  left: 0;
}

.crop-circle-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Radial transparent circle in center, dark edges */
  background: radial-gradient(circle at center, transparent 46%, rgba(0,0,0,0.6) 47%);
}
.crop-circle-mask::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 92%;
  height: 92%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255,255,255,0.4);
  border-radius: 50%;
  pointer-events: none;
}

.crop-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 0 8px;
}

.crop-zoom-label {
  color: var(--text-light);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.crop-zoom-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.crop-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.crop-zoom-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ============================================================
   Profile Tab
   ============================================================ */
.profile-section {
  max-width: 900px;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}

.profile-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border);
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar .placeholder {
  font-size: 48px;
  opacity: 0.4;
}

/* Avatar im Profil-Edit-Modal: einziger Eintrittspunkt zum Foto-Wechsel,
   nachdem der separate Pencil-Btn am Profil-Avatar entfernt wurde. */
.profile-edit-avatar-section {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}
.profile-edit-avatar {
  position: relative;
  width: 110px;
  height: 110px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
}
.profile-edit-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-edit-avatar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-edit-avatar-img .placeholder {
  font-size: 40px;
  opacity: 0.4;
}
.profile-edit-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity var(--transition);
}
.profile-edit-avatar:hover .profile-edit-avatar-overlay,
.profile-edit-avatar:focus-visible .profile-edit-avatar-overlay {
  opacity: 1;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.profile-name {
  font-size: var(--title-card-l);
  font-weight: 700;
  color: var(--text);
}

.profile-edit-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.profile-edit-btn:hover {
  background: var(--primary);
  color: #fff;
}

.profile-user-title {
  font-size: var(--text-base);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.profile-dienst {
  font-size: var(--text-sm);
  color: var(--text-light);
  font-style: italic;
}

.profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.profile-stat {
  font-size: var(--text-sm);
  color: var(--text-light);
}
.profile-stat strong {
  color: var(--text);
}

.profile-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profile-title-input {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--bg-card);
  color: var(--text);
}
.profile-title-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* Favorites Section */
.profile-favorites-section {
  margin-top: 24px;
}

.profile-favorites-section h3 {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.profile-fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.profile-fav-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.profile-fav-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.profile-fav-card .fav-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-fav-card .fav-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-fav-card .fav-avatar .placeholder {
  font-size: 18px;
  opacity: 0.4;
}

.profile-fav-card .fav-info {
  min-width: 0;
}
.profile-fav-card .fav-name {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.profile-fav-card .fav-sub {
  font-size: var(--text-xs);
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-fav-empty {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Profile Shared Notes */
.profile-shared-section {
  margin-top: 24px;
}
.profile-shared-section h3 {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.profile-shared-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.profile-shared-card {
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border-left: 3px solid var(--primary);
}
.profile-shared-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.profile-shared-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.profile-shared-preview {
  font-size: var(--text-sm);
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.profile-shared-date {
  font-size: var(--text-xs);
  color: var(--text-light);
}

/* ============================================================
   Friends Tab
   ============================================================ */
.friends-section {
  margin-top: 24px;
}

.friends-section > h3 {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.friends-search-bar {
  position: relative;
  margin-bottom: 16px;
}

/* Invite Button in Search Bar */
.friends-invite-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  z-index: 2;
}
.friends-invite-btn:hover {
  background: var(--primary-dark, #3a5f95);
}

/* Invite Modal */
.invite-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.invite-description {
  font-size: var(--text-base);
  color: var(--text-light);
  text-align: center;
  margin: 0;
}

.invite-link-row {
  display: flex;
  gap: 8px;
  width: 100%;
}
.invite-link-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.invite-qr-container {
  display: flex;
  justify-content: center;
  padding: 8px;
}
.invite-qr-container canvas {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.invite-share-row {
  display: flex;
  justify-content: center;
}

.friends-search-bar input {
  width: 100%;
  padding: 10px 50px 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--bg-card);
  color: var(--text);
}
.friends-search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.friends-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: default;
}
.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item .sr-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.search-result-item .sr-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-result-item .sr-info {
  flex: 1;
  min-width: 0;
}
.search-result-item .sr-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.search-result-item .sr-title {
  font-size: var(--text-sm);
  color: var(--text-light);
}

.search-result-item .btn {
  flex-shrink: 0;
}

/* Friends Sub-Tabs */
.friends-tabs-inner {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.friends-sub-tab {
  padding: 8px 20px;
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
  position: relative;
}
.friends-sub-tab:hover {
  color: var(--text);
}
.friends-sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.friends-sub-tab .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  margin-left: 6px;
}

.friends-sub-content {
  display: none;
}
.friends-sub-content.active {
  display: block;
}

/* Friend Cards Grid */
.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.friend-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.friend-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.friend-card .friend-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.friend-card .friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.friend-card .friend-avatar .placeholder {
  font-size: 22px;
  opacity: 0.4;
}

.friend-card .friend-clickable {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.friend-card .friend-info {
  flex: 1;
  min-width: 0;
}
.friend-card .friend-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.friend-card .friend-title {
  font-size: var(--text-sm);
  color: var(--text-light);
}

.friend-card .friend-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Request Cards */
.request-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}
.request-card .friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.request-card .friend-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.request-card .friend-info {
  flex: 1;
  min-width: 0;
}
.request-card .friend-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
}
.request-card .friend-title {
  font-size: var(--text-sm);
  color: var(--text-light);
}
.request-card .request-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================
   Network Graph (Church Detail)
   ============================================================ */
.network-section {
  margin-top: 24px;
  margin-bottom: 24px;
}

.network-container {
  width: 100%;
  height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
  position: relative;
}

#network-svg {
  width: 100%;
  height: 100%;
}

.network-node text {
  font-size: var(--text-xs);
  fill: var(--text);
  pointer-events: none;
  text-anchor: middle;
}

.network-tooltip {
  position: absolute;
  padding: 6px 10px;
  background: var(--bg-dark);
  color: var(--text-inverse);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s;
}
.network-tooltip.visible {
  opacity: 1;
}

/* ============================================================
   Network Profile Popup
   ============================================================ */
.network-profile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  gap: 8px;
}

.network-profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--border);
  margin-bottom: 8px;
}
.network-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.network-profile-avatar .placeholder {
  font-size: 32px;
  opacity: 0.4;
}

.network-profile-name {
  font-size: var(--title-card-s);
  font-weight: 700;
  color: var(--text);
}

.network-profile-user-title {
  font-size: var(--text-sm);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.network-profile-dienst {
  font-size: var(--text-sm);
  color: var(--text-light);
  font-style: italic;
}

.network-profile-stat {
  font-size: var(--text-sm);
  color: var(--text-light);
  margin-top: 4px;
}

.network-profile-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* ============================================================
   Friend Profile Modal
   ============================================================ */
.friend-profile-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
  gap: 8px;
}

.friend-profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.friend-profile-notes-section {
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.friend-profile-notes-section h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

/* ============================================================
   Shared helpers
   ============================================================ */
/* .btn-sm canonical definition lives in style.css — removed duplicate here. */

.btn-accept {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-accept:hover {
  opacity: 0.9;
}

.btn-reject {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.btn-reject:hover {
  opacity: 0.9;
}

.btn-pending {
  background: var(--border);
  color: var(--text-light);
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: default;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  /* Mobile-Profil: Avatar und Name zentriert untereinander, Edit-Btn
     wandert oben rechts in den Header — sonst ist die name-row durch
     den nebenstehenden Edit-Btn nicht echt zentriert. */
  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: 16px;
    position: relative;
  }
  .profile-avatar {
    width: 100px;
    height: 100px;
  }
  .profile-name-row {
    justify-content: center;
  }
  .profile-edit-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
  }
  .profile-stats {
    justify-content: center;
  }
  .profile-fav-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .friends-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
  }
  .network-container {
    height: 300px;
  }
}

@media (max-width: 480px) {
  .profile-header {
    padding: 16px;
  }
  .profile-avatar {
    width: 80px;
    height: 80px;
  }
  .profile-name {
    font-size: var(--title-card-s);
  }
  .profile-edit-btn {
    top: 8px;
    right: 8px;
  }
  .friends-sub-tab {
    padding: 6px 12px;
    font-size: var(--text-sm);
  }
  .friends-grid {
    max-width: none;
  }
}
