/* ═══════════════════════════════════════════════════════════
   Bloom — Dark Dating Chat Theme
   ═══════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --pink:         #E91E63;
  --pink-dark:    #C2185B;
  --pink-light:   #F8BBD0;
  --accent:       #FF6090;
  --bg:           #0d0d14;
  --surface:      #16162a;
  --card:         #1e1e38;
  --card-hover:   #282848;
  --input-bg:     #1e1e38;
  --text:         #f0f0f8;
  --text-muted:   #8888aa;
  --text-dim:     rgba(255,255,255,0.55);
  --online:       #4CAF50;
  --border:       rgba(255,255,255,0.06);
  --shadow:       rgba(0,0,0,0.4);
  --bubble-me:    #E91E63;
  --bubble-other: #1e1e38;
  --system-msg:   #6666aa;
  --danger:       #ef4444;
  --radius:       12px;
  --radius-lg:    20px;
  --sidebar-w:    280px;
  --header-h:     56px;
  --transition:   0.2s ease;
}

html, body {
  height: 100%;
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden  { display: none !important; }
.visible { display: flex !important; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.flex-1 { flex: 1; }

/* ── Overlay ───────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Login Card ────────────────────────────────────────────── */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: min(420px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow);
  animation: slideUp 0.35s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-logo { font-size: 3.5rem; text-align: center; margin-bottom: 0.5rem; }
.login-title {
  text-align: center; font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* ── Form Fields ───────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.85rem; color: var(--text-muted);
  margin-bottom: 4px; font-weight: 500;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; padding: 10px 14px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: 'Heebo', sans-serif; font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(233,30,99,0.15);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-dim); }
.form-row { display: flex; gap: 0.75rem; }
.form-row.three-col { gap: 0.5rem; }

.error-msg {
  color: var(--danger); font-size: 0.9rem; text-align: center;
  padding: 8px; margin-bottom: 0.5rem;
  background: rgba(239,68,68,0.1); border-radius: var(--radius);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  display: block; width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: #fff; border: none; border-radius: var(--radius);
  font-family: 'Heebo', sans-serif; font-size: 1.1rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  padding: 10px 20px; background: var(--card);
  color: var(--text-muted); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: 'Heebo', sans-serif;
  cursor: pointer; transition: all var(--transition);
}
.btn-secondary:hover { background: var(--card-hover); color: var(--text); }

.btn-icon {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; padding: 6px;
  border-radius: 8px; transition: all var(--transition);
  line-height: 1;
}
.btn-icon:hover { background: var(--card); color: var(--text); }

.btn-close {
  position: absolute; top: 12px; left: 12px;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
  border-radius: 8px; transition: all var(--transition);
}
.btn-close:hover { background: var(--card); color: var(--text); }

.badge {
  background: var(--card); color: var(--text-muted);
  font-size: 0.75rem; padding: 2px 8px; border-radius: 10px;
  font-weight: 500;
}

/* ── App Layout ────────────────────────────────────────────── */
#app {
  display: flex; height: 100vh; width: 100vw;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
}
.sidebar-header {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 1.3rem; font-weight: 700;
  background: linear-gradient(135deg, var(--pink), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  transition: background var(--transition);
}
.dot.online  { background: var(--online); box-shadow: 0 0 6px var(--online); }
.dot.offline { background: var(--danger); }

.sidebar-section { padding: 12px 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 8px; font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
}

.nav-list { list-style: none; }
.nav-list li {
  padding: 8px 20px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: background var(--transition);
  font-size: 0.93rem; position: relative;
}
.nav-list li:hover { background: var(--card); }
.nav-list li.active { background: var(--card); color: var(--pink); font-weight: 600; }
.nav-list li .dot { width: 8px; height: 8px; flex-shrink: 0; }
.nav-list li .unread-badge {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  background: var(--pink); color: #fff; font-size: 0.7rem;
  padding: 1px 6px; border-radius: 10px; font-weight: 600;
  transition: opacity var(--transition);
}
.nav-list li:hover .unread-badge {
  opacity: 0; pointer-events: none;
}
.nav-list li .btn-close-dm-item {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  background: transparent; color: var(--text-muted); border: none;
  font-size: 0.95rem; padding: 4px; cursor: pointer;
  opacity: 0; transition: opacity var(--transition), color var(--transition);
  z-index: 5;
}
.nav-list li:hover .btn-close-dm-item {
  opacity: 0.6;
}
.nav-list li .btn-close-dm-item:hover {
  opacity: 1; color: var(--danger);
}
.nav-list li .room-icon { font-size: 1.1rem; flex-shrink: 0; }
.nav-list li .user-initial {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--pink-dark); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; flex-shrink: 0;
}

/* ── Main Area ─────────────────────────────────────────────── */
#main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0;
}

#chat-header {
  height: var(--header-h); min-height: var(--header-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h2 { font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-actions { display: flex; gap: 4px; }

/* ── Messages ──────────────────────────────────────────────── */
.messages-area {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  scroll-behavior: smooth;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; }

/* ── Message Bubbles ───────────────────────────────────────── */
.msg { max-width: 75%; padding: 10px 14px; border-radius: 16px; position: relative; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.msg.me {
  align-self: flex-end; background: var(--bubble-me); color: #fff;
  border-bottom-left: 4px;
  border-radius: 16px 16px 4px 16px;
}
.msg.other {
  align-self: flex-start; background: var(--bubble-other);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.msg .msg-sender {
  font-size: 0.8rem; font-weight: 600; color: var(--accent);
  margin-bottom: 2px; cursor: pointer;
}
.msg .msg-sender:hover { text-decoration: underline; }
.msg .msg-text { font-size: 0.95rem; line-height: 1.5; word-break: break-word; }
.msg .msg-time { font-size: 0.72rem; color: rgba(255,255,255,0.5); margin-top: 4px; text-align: left; }
.msg.me .msg-time { color: rgba(255,255,255,0.7); }

.msg.system {
  align-self: center; max-width: 90%;
  background: rgba(100,100,150,0.15); color: var(--system-msg);
  font-size: 0.85rem; font-style: italic; text-align: center;
  padding: 6px 16px; border-radius: var(--radius);
}

/* ── Message Input ─────────────────────────────────────────── */
.message-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.message-input-bar input {
  flex: 1; padding: 12px 18px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 24px;
  font-family: 'Heebo', sans-serif; font-size: 0.95rem;
  outline: none; transition: border-color var(--transition);
}
.message-input-bar input:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(233,30,99,0.12);
}
.message-input-bar input::placeholder { color: var(--text-dim); }

.btn-send {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: #fff; border: none; font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
  transform: scaleX(-1); /* flip arrow for RTL */
}
.btn-send:hover { filter: brightness(1.15); transform: scaleX(-1) scale(1.05); }

/* ── Video Call ────────────────────────────────────────────── */
.call-container {
  background: var(--bg); border-radius: var(--radius-lg);
  width: min(800px, 95vw); height: min(600px, 85vh);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
.call-header {
  padding: 16px 20px; background: var(--surface);
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
#call-status { font-weight: 600; }
#call-peer-name { color: var(--accent); }

.video-grid {
  flex: 1; position: relative; background: #000;
  overflow: hidden; min-height: 350px;
}
.video-wrapper {
  position: absolute; border-radius: var(--radius);
  overflow: hidden; background: #111;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.video-wrapper video {
  width: 100%; height: 100%; object-fit: cover;
}
.video-wrapper.focused {
  width: 100%; height: 100%; top: 0; left: 0; z-index: 1;
}
.video-wrapper.floating {
  width: 140px; height: 190px; top: 16px; left: 16px;
  z-index: 10; cursor: pointer; border: 2px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.video-wrapper.floating:hover {
  transform: scale(1.05); border-color: var(--primary);
}
.video-label {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: #fff;
  font-size: 0.8rem; padding: 3px 10px; border-radius: 8px;
  z-index: 2;
}

.call-controls {
  padding: 16px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.btn-call {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--card); color: #fff; border: none;
  font-size: 1.3rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-call:hover { background: var(--card-hover); transform: scale(1.08); }
.btn-call.btn-hangup { background: var(--danger); }
.btn-call.btn-hangup:hover { background: #dc2626; }
.btn-call.btn-accept { background: var(--online); }
.btn-call.btn-accept:hover { background: #45a049; }
.btn-call.muted { background: var(--danger); }

/* ── Incoming Call ─────────────────────────────────────────── */
.incoming-call-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2.5rem; text-align: center;
  box-shadow: 0 20px 60px var(--shadow);
  animation: slideUp 0.35s ease;
}
.incoming-call-icon { font-size: 3rem; margin-bottom: 1rem; }
.incoming-call-text { font-size: 1.2rem; margin-bottom: 1.5rem; }
.incoming-call-actions { display: flex; gap: 20px; justify-content: center; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.pulse { animation: pulse 1.5s ease infinite; }

/* ── Profile Popup ─────────────────────────────────────────── */
.profile-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2rem; width: min(380px, 90vw); position: relative;
  box-shadow: 0 20px 60px var(--shadow);
  animation: slideUp 0.3s ease;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--accent));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; margin: 0 auto 12px;
}
.profile-card h3 { text-align: center; font-size: 1.3rem; margin-bottom: 12px; }
.profile-details { display: flex; flex-direction: column; gap: 8px; }
.profile-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--text-muted);
}
.profile-row .label { min-width: 70px; font-weight: 500; }
.profile-row .value { color: var(--text); }

/* ── Dialog Card ───────────────────────────────────────────── */
.dialog-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 1.5rem; width: min(360px, 90vw);
  box-shadow: 0 20px 60px var(--shadow);
  animation: slideUp 0.3s ease;
}
.dialog-card h3 { margin-bottom: 1rem; font-size: 1.1rem; }
.dialog-card input {
  width: 100%; padding: 10px 14px;
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: 'Heebo', sans-serif; font-size: 0.95rem;
  outline: none; margin-bottom: 1rem;
}
.dialog-card input:focus { border-color: var(--pink); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Mobile ────────────────────────────────────────────────── */
.mobile-only { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .mobile-only { display: flex; }
  #sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 500; transform: translateX(100%);
  }
  #sidebar.open { transform: translateX(0); }
  .video-wrapper.local { flex: 0 0 120px; max-width: 120px; }
}

/* 🦽 accessibility focus visibility & skip link styles */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-icon:focus-visible,
.btn-close:focus-visible,
.btn-call:focus-visible,
.dialog-card input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 10px;
  background: var(--pink);
  color: white;
  padding: 10px 20px;
  z-index: 2000;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: bold;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 10px;
  outline: 2px solid white;
}
