/* ============================================
   Chat Modals - Responsive Modal Styles
   Enhanced Glassmorphism Design
   ============================================ */

/* --- Modal Overlay --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
  animation: fadeIn 0.3s ease-out;
}

/* --- Modal Content --- */
.modal-content {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  animation: slideUpBounce 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  position: relative;
}

/* Glassmorphism light reflection */
.modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  pointer-events: none;
}

.modal-profile {
  max-width: 30rem;
}

/* --- Modal Header --- */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
  z-index: 1;
}

.modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* --- Modal Body --- */
.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

/* --- Profile Avatar Section --- */
.profile-avatar-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

/* --- Form Elements --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.form-group label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: var(--transition-smooth);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
}

.form-input-sm {
  width: 4.5rem;
}

/* --- Birthday Inputs --- */
.birthday-inputs {
  display: flex;
  gap: 0.5rem;
}

.birthday-inputs .form-input:first-child {
  flex: 1;
}

/* --- Checkbox --- */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.form-checkbox input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

.form-checkbox label {
  color: var(--text-primary);
  font-size: 0.9375rem;
  cursor: pointer;
  margin: 0;
}

/* --- Search Input --- */
.search-input-wrapper {
  margin-bottom: 1rem;
}

/* --- Search Results --- */
.search-results {
  max-height: 18.75rem;
  overflow-y: auto;
}

.search-result-item {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-username {
  font-size: 0.8125rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Contact List --- */
.contact-list {
  max-height: 22.5rem;
  overflow-y: auto;
}

.contact-item {
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition-smooth);
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.contact-info {
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-tags {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.contact-tag {
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  font-size: 0.8125rem;
  font-weight: 500;
}

.contact-families {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Empty State --- */
.empty-state {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* --- Button Block --- */
.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

/* --- Responsive Adjustments --- */

/* Tablet */
@media (max-width: 1024px) {
  .modal-content {
    max-width: 28rem;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-content {
    max-width: 100%;
    max-height: 95vh;
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-header h3 {
    font-size: 1.125rem;
  }

  .modal-body {
    padding: 1.25rem;
  }

  .search-results,
  .contact-list {
    max-height: 60vh;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .modal-header {
    padding: 0.875rem 1rem;
  }

  .modal-header h3 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 1rem;
  }

  .birthday-inputs {
    flex-wrap: wrap;
  }

  .birthday-inputs .form-input:first-child {
    width: 100%;
  }

  .form-input-sm {
    flex: 1;
    width: auto;
  }

  .contact-item,
  .search-result-item {
    padding: 0.625rem 0.5rem;
  }

  .contact-name,
  .search-result-name {
    font-size: 0.875rem;
  }

  .contact-tag {
    font-size: 0.75rem;
    padding: 0.0625rem 0.375rem;
  }
}

/* --- Animations --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(1.25rem) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideUpBounce {
  0% {
    opacity: 0;
    transform: translateY(2rem) scale(0.9);
  }
  60% {
    transform: translateY(-0.25rem) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal-content {
    animation: fadeIn 0.01ms;
  }

  .form-input:focus,
  .form-select:focus {
    transform: none;
  }
}
