/* Modals and toasts */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 480px;
  margin-top: 64px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

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

.modal-search-input {
  margin: 16px 20px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font);
}

.modal-search-input:focus {
  outline: none;
  border-color: var(--accent-teal);
}

.modal-results-list {
  overflow-y: auto;
  padding: 12px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 12px;
}

.modal-result-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-result-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-teal);
}

.modal-result-thumb,
.modal-result-thumb-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.modal-result-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card-hover);
  font-size: 1.1rem;
}

.modal-result-name {
  flex: 1;
  min-width: 0;
}

.modal-result-year {
  color: var(--text-muted);
  font-size: 0.85em;
}

.modal-result-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(61, 217, 179, 0.15);
  color: var(--accent-teal);
  font-size: 0.75rem;
  font-weight: 600;
}

.modal-footer {
  padding: 4px 20px 20px;
}

.btn-modal-secondary {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-modal-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-teal);
  color: var(--accent-teal);
}

.modal-content.modal-wide { max-width: 560px; overflow-y: auto; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--bg-surface); border: 1px solid var(--border-accent); color: var(--text-primary);
  padding: 12px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  font-size: 0.9rem; max-width: 90vw; animation: slideUp 0.25s ease;
}

.push-invite {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 1900;
  width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--bg-surface); border: 1px solid var(--border-accent); border-radius: var(--radius-md);
  padding: 14px 16px; box-shadow: var(--shadow-card); animation: slideUp 0.25s ease;
}
.push-invite-text { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; color: var(--text-secondary); flex: 1 1 260px; }
.push-invite-text strong { color: var(--text-primary); font-size: 0.95rem; }
.push-invite-actions { display: flex; gap: 8px; }

.toast.err { border-color: rgba(239, 68, 68, 0.6); color: #fca5a5; }

/* Confirmation before adding a fresh RAWG game to the catalogue */
.modal-confirm { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; text-align: center; }
.modal-confirm-text { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--text-secondary); }
.modal-confirm-text strong { color: var(--text-primary); font-size: 1rem; }

/* A bottom sheet on a phone (openModal(..., { sheet: true })); a normal modal on a wide screen */
@media (max-width: 640px) {
  .modal-sheet { align-items: flex-end; padding: 0; }
  .modal-sheet .modal-content {
    margin-top: 0; max-width: none; max-height: 75vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
