/* ============================================
   MEMBERSHIP COMMON STYLES
   Shared components: cards, badges, tables,
   forms, buttons, modals, pagination, grid
   ============================================ */

/* --- Base overrides for membership pages --- */
main {
  text-align: left;
  font-family: 'Segoe UI', Arial, sans-serif;
}

/* --- Default page containers --- */
.chat-container,
.profile-container,
.settings-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

@media (max-width: 768px) {
  .chat-container,
  .profile-container,
  .settings-container {
    padding: 1.25rem 0.75rem;
  }
}

/* --- Cards --- */
.membership-card {
  background: var(--nav-submenu-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 1.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.membership-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.membership-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.membership-card-body {
  color: var(--text-color);
  font-size: 0.9rem;
  line-height: 1.5;
}

.membership-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.6em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  line-height: 1;
  white-space: nowrap;
}

.badge-primary {
  background: var(--link-color);
  color: var(--bg-color);
}

.badge-success {
  background: #2ecc71;
  color: #000;
}

.badge-warning {
  background: #f39c12;
  color: #000;
}

.badge-danger {
  background: #e74c3c;
  color: #fff;
}

.badge-moderator {
  background: #1a7a3a;
  color: #fff;
}

.badge-superadmin {
  background: #8e44ad;
  color: #fff;
}

.badge-muted {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
}

/* --- Tables --- */
.membership-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.membership-table th,
.membership-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-color);
}

.membership-table th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.03);
}

.membership-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.membership-table tbody tr:focus-within {
  outline: 2px solid var(--link-color);
  outline-offset: -2px;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--link-color);
  box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.25);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  color-scheme: dark;
}

.form-select option {
  background: #1e1e2e;
  color: #e0e0e0;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-error {
  color: #e74c3c;
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

.form-hint {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--link-color);
  color: var(--bg-color);
  border-color: var(--link-color);
}

.btn-primary:hover {
  background: var(--hover-link-color);
  border-color: var(--hover-link-color);
  color: var(--bg-color);
}

.btn-secondary {
  background: transparent;
  color: var(--link-color);
  border-color: var(--link-color);
}

.btn-secondary:hover {
  background: rgba(77, 171, 247, 0.1);
}

.btn-danger {
  background: #e74c3c;
  color: #fff;
  border-color: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
  border-color: #c0392b;
}

.btn-ghost {
  background: transparent;
  color: var(--text-color);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  min-height: 32px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.modal {
  background: var(--nav-submenu-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-color);
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.modal-close:hover {
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.06);
}

.modal-close:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 0;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--link-color);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  text-decoration: none;
}

.pagination-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.pagination-btn:focus-visible {
  outline: 2px solid var(--link-color);
  outline-offset: 2px;
}

.pagination-btn.active {
  background: var(--link-color);
  color: var(--bg-color);
  border-color: var(--link-color);
  font-weight: 600;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  padding: 0.4rem 0.5rem;
  color: rgba(255, 255, 255, 0.3);
}

/* --- Responsive Grid --- */
.membership-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

/* --- Avatars --- */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-lg {
  width: 64px;
  height: 64px;
}

.avatar-xl {
  width: 96px;
  height: 96px;
}

/* --- Unread Indicator --- */
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--link-color);
  flex-shrink: 0;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e74c3c;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}

/* --- Divider --- */
.membership-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 1rem 0;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255, 255, 255, 0.4);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
}

.empty-state p {
  font-size: 0.95rem;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--link-color);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Responsive Breakpoints --- */
@media (min-width: 769px) {
  .membership-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .membership-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .pagination-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .membership-table {
    font-size: 0.85rem;
  }

  .membership-table th,
  .membership-table td {
    padding: 0.6rem 0.75rem;
  }

  .hide-mobile {
    display: none;
  }
}
