/* ============================================================
   css/call.css — Free Global Calls UI
   ============================================================ */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: #334155;
  --radius: 14px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }

/* ── LOBBY ── */
.call-screen { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
.call-header {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.5rem;
}
.call-header h1, .call-header h2 { font-size: 1.4rem; }
.back-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back-link:hover { color: var(--primary); }

.lobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}
.lobby-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
}
.lobby-card-wide { grid-column: 1 / -1; }
.lobby-card h2 {
  font-size: 1.05rem; margin-bottom: 1rem;
  display: flex; gap: .5rem; align-items: center;
}
.lobby-card label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--muted); margin: .6rem 0 .25rem;
}
.lobby-card input, .lobby-card select {
  width: 100%; padding: .65rem .9rem;
  background: #0b1220; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text);
  font-size: .95rem; font-family: inherit;
  transition: border-color .15s;
}
.lobby-card input:focus, .lobby-card select:focus {
  outline: none; border-color: var(--primary);
}

/* ── BUTTONS ── */
.call-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; padding: .7rem 1.2rem;
  border: none; border-radius: 10px;
  font-weight: 600; cursor: pointer;
  font-size: .9rem; transition: all .2s;
  font-family: inherit; color: #fff;
  background: var(--panel-2);
}
.call-btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.call-btn:active { transform: translateY(0) scale(.98); }
.call-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  width: 100%; margin-top: 1rem;
}
.call-btn-danger { background: var(--danger); }

/* ── MEETING LIST ── */
.meeting-list {
  display: flex; flex-direction: column; gap: .5rem;
}
.meeting-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  background: #0b1220; border: 1px solid var(--border);
  border-radius: 10px; padding: .7rem 1rem;
  transition: border-color .15s;
}
.meeting-row:hover { border-color: var(--primary); }
.meeting-row .meta { font-size: .85rem; color: var(--muted); }
.meeting-row .code {
  font-family: monospace; font-weight: 700;
  color: var(--primary); letter-spacing: 1px;
}

/* ── ROOM ── */
.call-screen#callRoom {
  padding: 0; max-width: none;
  display: flex; flex-direction: column; height: 100vh;
}
.call-header-room {
  margin: 0; padding: .8rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.call-header-room h2 { font-size: 1.05rem; }
.call-header-actions {
  display: flex; align-items: center;
  gap: .5rem; margin-left: auto;
}
.icon-btn {
  background: #0b1220; border: 1px solid var(--border);
  color: var(--text); width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer;
  transition: all .2s;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--primary); }

.room-layout { flex: 1; display: flex; min-height: 0; }

.video-grid {
  flex: 1; display: grid; gap: .6rem; padding: .6rem;
  overflow: auto;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-content: start;
  background: #0b1220;
}

.video-tile {
  position: relative; background: #000;
  border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 2px solid transparent;
  transition: border-color .2s;
}
.video-tile.speaking { border-color: var(--success); }
.video-tile video {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.video-tile .name-tag {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; padding: .15rem .55rem;
  border-radius: 8px; backdrop-filter: blur(4px);
}
.video-tile .badges {
  position: absolute; right: 8px; top: 8px;
  display: flex; gap: .25rem;
}
.video-tile .badges i {
  background: rgba(0,0,0,.65); color: #fff;
  font-size: .7rem; padding: .25rem;
  border-radius: 6px;
}
.video-tile .badges i.off { color: var(--danger); }

/* ── CHAT PANEL ── */
.chat-panel {
  width: 320px; display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
}
.chat-panel h3 {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.chat-log {
  flex: 1; overflow-y: auto; padding: .8rem;
  display: flex; flex-direction: column;
  gap: .4rem; font-size: .85rem;
}
.chat-log .msg {
  padding: .35rem .6rem; border-radius: 8px;
  background: #0b1220; word-break: break-word;
}
.chat-log .msg.self {
  background: rgba(79,70,229,.25);
  align-self: flex-end; max-width: 85%;
}
.chat-log .msg .who {
  font-weight: 600; color: var(--primary);
  font-size: .75rem; display: block;
}
.chat-form {
  display: flex; gap: .4rem; padding: .6rem;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1; padding: .5rem .7rem;
  background: #0b1220; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: inherit;
}
.chat-form button {
  background: var(--primary); border: none;
  color: #fff; width: 38px; border-radius: 8px;
  cursor: pointer;
}

/* ── CALL CONTROLS ── */
.call-controls {
  display: flex; justify-content: center; gap: .6rem;
  padding: .7rem; flex-wrap: wrap;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.ctrl-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: .15rem;
  background: #0b1220; border: 1px solid var(--border);
  color: var(--text); padding: .5rem 1rem;
  border-radius: 12px; cursor: pointer;
  transition: all .2s; font-size: .7rem;
  min-width: 72px; font-family: inherit;
}
.ctrl-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.ctrl-btn i { font-size: 1.15rem; }
.ctrl-btn.off {
  background: rgba(239,68,68,.2);
  border-color: var(--danger);
  color: #fecaca;
}
.ctrl-btn.off i { color: var(--danger); }
.ctrl-danger { background: var(--danger); border-color: var(--danger); }
.ctrl-danger:hover { background: #dc2626; }
.only-mobile { display: none; }

/* ── MODAL / TOAST ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 5000; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel); border-radius: var(--radius);
  padding: 1.5rem; max-width: 520px; width: 100%;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-box h2 { margin-bottom: 1rem; font-size: 1.1rem; }
.modal-box video {
  width: 100%; border-radius: 12px;
  background: #000; aspect-ratio: 16 / 10;
  object-fit: cover; margin-bottom: .7rem;
}
.modal-actions {
  display: flex; gap: .6rem;
  justify-content: flex-end; margin-top: 1rem;
}
.call-toast {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: #0b1220; border: 1px solid var(--border);
  color: var(--text); padding: .6rem 1.2rem;
  border-radius: 30px; opacity: 0;
  pointer-events: none; transition: all .3s;
  font-size: .85rem; z-index: 6000;
  max-width: 92%;
}
.call-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── ANIMATIONS ── */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.85); }
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .only-mobile { display: flex; }
  .chat-panel {
    position: fixed; inset: auto 0 0 0;
    height: 55vh; width: 100%; z-index: 4000;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  }
  .video-grid {
    grid-template-columns: 1fr;
    padding: .4rem; gap: .4rem;
  }
  .video-tile { aspect-ratio: 4 / 3; }
  .call-controls { gap: .4rem; padding: .5rem; }
  .ctrl-btn {
    min-width: 60px; padding: .45rem .6rem;
    font-size: .65rem;
  }
  .call-header-room { padding: .6rem .7rem; }
  .call-header-room h2 { font-size: .95rem; }
}

@media (max-width: 420px) {
  .ctrl-btn span { display: none; }
  .ctrl-btn { min-width: 48px; padding: .55rem; }
}