@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&display=swap');

:root {
  --bg-1: #1a1033;
  --bg-2: #2d1b4e;
  --accent-1: #ff6fb0;
  --accent-2: #7c5cff;
  --accent-3: #4fc3f7;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text-1: #f5f3ff;
  --text-2: rgba(245, 243, 255, 0.65);
  --bubble-me: linear-gradient(135deg, #7c5cff, #ff6fb0);
  --bubble-other: rgba(255, 255, 255, 0.1);
  --danger: #ff5b6a;
  --success: #4ade80;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Tajawal', 'Segoe UI', sans-serif;
  color: var(--text-1);
  background: radial-gradient(1200px 800px at 20% 10%, #3a1f66 0%, transparent 60%),
              radial-gradient(1000px 700px at 90% 90%, #1f3a66 0%, transparent 55%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-orbs { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.35; }
.orb.one { width: 320px; height: 320px; background: var(--accent-1); top: -80px; right: -60px; }
.orb.two { width: 280px; height: 280px; background: var(--accent-3); bottom: -60px; left: -60px; }
.orb.three { width: 220px; height: 220px; background: var(--accent-2); top: 40%; left: 50%; }

.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  border-radius: 28px;
  padding: 36px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  text-align: center;
}

.login-title {
  font-size: 26px;
  font-weight: 900;
  margin: 0 0 4px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-sub {
  color: var(--text-2);
  font-size: 14px;
  margin: 0 0 28px;
}

.name-choices {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.name-chip {
  flex: 1;
  padding: 14px 8px;
  border-radius: 16px;
  border: 1.5px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-1);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.name-chip .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #1a1033;
}

.name-chip.hussein .avatar { background: linear-gradient(135deg, #4fc3f7, #7c5cff); color: #fff; }
.name-chip.azraa .avatar { background: linear-gradient(135deg, #ff6fb0, #ffb36f); color: #fff; }

.name-chip.selected {
  border-color: var(--accent-1);
  background: rgba(255, 111, 176, 0.14);
  transform: translateY(-2px);
}

.field {
  text-align: right;
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--text-1);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}

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

.btn-primary {
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-1));
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 10px 30px rgba(124,92,255,0.35);
}

.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  min-height: 18px;
}

.chat-wrap {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
}

.chat-header .avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  position: relative;
}

.status-dot {
  position: absolute;
  bottom: -1px;
  left: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #666;
  border: 2px solid var(--bg-1);
}

.status-dot.online { background: var(--success); }

.chat-header .names { flex: 1; }
.chat-header .partner-name { font-weight: 700; font-size: 16px; }
.chat-header .partner-status { font-size: 12px; color: var(--text-2); }

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s;
}

.icon-btn:hover { background: rgba(255,255,255,0.12); }
.icon-btn svg { width: 20px; height: 20px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-row { display: flex; }
.bubble-row.me { justify-content: flex-start; }
.bubble-row.other { justify-content: flex-end; }

.bubble {
  max-width: 74%;
  padding: 11px 16px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.bubble-row.me .bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-left-radius: 6px;
}

.bubble-row.other .bubble {
  background: var(--bubble-other);
  border: 1px solid var(--glass-border);
  border-bottom-right-radius: 6px;
}

.bubble-time {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 4px;
  text-align: left;
}

.bubble-row.other .bubble-time { text-align: right; }

.typing-indicator {
  font-size: 12px;
  color: var(--text-2);
  padding: 0 18px 6px;
  min-height: 16px;
}

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--glass);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
}

.composer input {
  flex: 1;
  padding: 13px 18px;
  border-radius: 24px;
  border: 1.5px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  color: var(--text-1);
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

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

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-1));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn svg { width: 20px; height: 20px; transform: scaleX(-1); }

.call-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 20, 0.92);
  backdrop-filter: blur(10px);
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.call-overlay.active { display: flex; }

.call-status-text {
  color: var(--text-1);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.call-sub-text { color: var(--text-2); font-size: 13px; margin-bottom: 24px; }

.video-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 3/4;
  max-height: 62vh;
  border-radius: 24px;
  overflow: hidden;
  background: #150c28;
  border: 1px solid var(--glass-border);
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-video {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: 100px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  background: #0f0a1c;
}

.ringing-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  margin-bottom: 20px;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,111,176,0.5); }
  70% { box-shadow: 0 0 0 22px rgba(255,111,176,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,111,176,0); }
}

.call-controls {
  display: flex;
  gap: 18px;
  margin-top: 26px;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
}

.call-btn svg { width: 24px; height: 24px; }
.call-btn.accept { background: var(--success); }
.call-btn.reject, .call-btn.hangup { background: var(--danger); }
.call-btn.mute { background: rgba(255,255,255,0.14); }
.call-btn.mute.active { background: var(--accent-2); }

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 12, 40, 0.95);
  border: 1px solid var(--glass-border);
  color: var(--text-1);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.toast.show { opacity: 1; }
