/*
 * components.css
 * Reusable UI components: card, badge, form elements (input + buttons),
 * user list rows, video cards, and the toast notification.
 * Depends on tokens from base.css.
 */

/* ─── Card ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ─── Connection Status Badge ────────────────────────────────────────────── */

.badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.badge-on   { color: var(--accent); border-color: rgba(94, 234, 212, 0.35); }
.badge-warn { color: #fbbf24; }
.badge-off  { color: var(--muted); }

/* ─── Form: Text Input ───────────────────────────────────────────────────── */

input {
  padding: 12px 14px;
  width: min(100%, 280px);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 17, 31, 0.7);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

button {
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  color: #042f2e;
  background: #cbd5e1;
}

/* Primary CTA — gradient accent. */
button.primary {
  background: linear-gradient(135deg, var(--accent), #2dd4bf);
}

/* Ghost — transparent with border. */
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

/* Danger — soft destructive red. */
button.danger {
  background: rgba(251, 113, 133, 0.18);
  color: #fecdd3;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Icon Buttons (Mic/Video) */
.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  transition: all 0.2s;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

.icon-btn.muted {
  background: rgba(251, 113, 133, 0.18);
  color: #fecdd3;
  /* Option: add a red border or just rely on background/icon change */
}

/* ─── Online User List ───────────────────────────────────────────────────── */

.user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.user-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name small {
  color: var(--muted);
  font-size: 11px;
}

/* Online presence dot. */
.dot { color: #34d399; }

/* Per-user call button inside the sidebar. */
button.call {
  background: rgba(94, 234, 212, 0.16);
  color: var(--accent);
}

/* ─── Video Cards ────────────────────────────────────────────────────────── */

.video-card {
  position: absolute;
  overflow: hidden;
  background: #000;
}

#remoteCard {
  inset: 0; /* Fill the entire .videos container */
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

#localCard {
  width: 120px;
  height: 160px;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  cursor: grab;
  transition: box-shadow 0.2s;
}

#localCard.snapping {
  /* Animate smooth flight to the nearest corner when released */
  transition: right 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), 
              bottom 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.2s;
}

#localCard:active {
  cursor: grabbing;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
}

@media (min-width: 768px) {
  #localCard {
    width: 160px;
    height: 210px;
    bottom: 24px;
    right: 24px;
  }
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ─── Modals ─────────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85); /* Dark slate background */
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  text-align: center;
  min-width: 320px;
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 24px;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Horizontally mirror the local feed so it feels like a mirror. */
video.mirror { transform: scaleX(-1); }

.video-meta {
  position: absolute;
  left: 12px;
  bottom: 12px;
}

/* Label pill (e.g. "You" / "Guest"). */
.pill {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* Placeholder shown inside the remote video card when no peer is connected. */
.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.placeholder.hidden { display: none; }

/* ─── Toast Notification ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 12px;
  z-index: 5;
  box-shadow: var(--shadow);
}
