/* ── Tailwind hidden/flex conflict fix ───────────── *
 * Tailwind CDN writes flex's rule after hidden's rule in the stylesheet,
 * so flex (display:flex) overrides hidden (display:none) for any element
 * that carries both classes. ID-level specificity + !important ensures
 * hidden always wins, regardless of stylesheet order.
 * ─────────────────────────────────────────────────── */
#namePrompt.hidden,
#controlRequestModal.hidden,
#sidebar.hidden,
#panelChat.hidden,
#unreadBadge.hidden,
#focusModeBtn.hidden,
#youtubeWidget.hidden {
  display: none !important;
}

/* ── Toolbar buttons ─────────────────────────────── */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  color: #e5e7eb;
  transition: background-color 0.15s, transform 0.1s;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  outline: none;
  position: relative;
}
.toolbar-btn:focus-visible {
  box-shadow: 0 0 0 2px #6366f1;
}
.toolbar-btn.active { /* used for mic/cam when enabled */ }
.toolbar-btn.btn-danger {
  background-color: #b91c1c;
}

/* ── Sidebar tabs ─────────────────────────────────── */
.sidebar-tab {
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
  transition: color 0.15s;
}

/* ── Video tile ───────────────────────────────────── */
.video-tile {
  position: relative;
  background: #111827;
  border-radius: 0.75rem;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 120px;
}
.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-tile .tile-label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  pointer-events: none;
}
.video-tile .tile-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  background: #1f2937;
}
.video-tile .tile-icons {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
}
.tile-icon {
  width: 1.25rem;
  height: 1.25rem;
  background: rgba(0,0,0,0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
}
.tile-icon svg {
  width: 0.75rem;
  height: 0.75rem;
  color: #f87171;
}

/* ── Screen share enlarged layout ───────────────── */
#screenShareView {
  /* flex grow/shrink handled by JS class toggle */
}

#videoArea.screen-sharing-active #screenShareView {
  flex: 1 1 0;
  min-height: 0;
}

#videoArea.screen-sharing-active #videoGrid {
  flex: 0 0 148px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
  grid-auto-rows: 130px !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Fullscreen (focus mode) */
#screenShareView:fullscreen,
#screenShareView:-webkit-full-screen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}
#screenShareView:fullscreen video,
#screenShareView:-webkit-full-screen video {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}
#screenShareView:fullscreen #focusModeBtn,
#screenShareView:-webkit-full-screen #focusModeBtn {
  display: none;
}

/* ── Screen mirror warning overlay ──────────────── */
.screen-mirror-warning {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.screen-mirror-warning.hidden {
  display: none;
}
.mirror-warning-icon {
  width: 3rem;
  height: 3rem;
  background: rgba(251, 191, 36, 0.15);
  border: 1.5px solid rgba(251, 191, 36, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}
.mirror-warning-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: #fbbf24;
}
.mirror-warning-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbbf24;
}
.mirror-warning-body {
  font-size: 0.8rem;
  color: #d1d5db;
  line-height: 1.6;
  max-width: 26rem;
}
.mirror-warning-body strong {
  color: #fff;
}

/* ── Mic level indicator ─────────────────────────── */
.tile-mic-indicator {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.38);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.mic-fill-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: rgba(251, 191, 36, 0.88);
  transition: height 0.07s ease;
}

.tile-mic-indicator svg {
  position: relative;
  z-index: 1;
  width: 58%;
  height: 58%;
  opacity: 0.9;
}

/* ── Chat messages ────────────────────────────────── */
.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.chat-msg .msg-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.chat-msg .msg-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #a5b4fc;
}
.chat-msg .msg-time {
  font-size: 0.65rem;
  color: #6b7280;
}
.chat-msg .msg-body {
  font-size: 0.8rem;
  color: #d1d5db;
  word-break: break-word;
  background: #1f2937;
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
}
.chat-msg.own .msg-name { color: #6ee7b7; }
.chat-msg.own .msg-body { background: #1e3a5f; }
.chat-msg .file-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
}
.chat-msg .file-card svg { color: #6366f1; flex-shrink: 0; }
.chat-msg .file-card a {
  color: #93c5fd;
  text-decoration: underline;
  word-break: break-all;
}

/* ── Participant list item ────────────────────────── */
.participant-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  background: #1f2937;
  font-size: 0.82rem;
}
.participant-item .p-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
}
.participant-item .p-icons {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}
.p-icon { color: #6b7280; width: 1rem; height: 1rem; }
.p-icon.off { color: #ef4444; }

/* ── Toast ────────────────────────────────────────── */
.toast {
  background: #374151;
  color: #f9fafb;
  padding: 0.6rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.8rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  animation: fadeInUp 0.2s ease;
  min-width: 200px;
}
.toast.success { background: #064e3b; }
.toast.error   { background: #7f1d1d; }
.toast.info    { background: #1e3a5f; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 999px; }

/* ── Spinner ──────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid #4b5563;
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ── Mobile layout ────────────────────────────────── */

/* Safe area bottom padding for notched phones */
.mobile-toolbar-safe {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
}

/* Sidebar: full width on mobile, fixed width on desktop */
.sidebar-panel {
  width: 100%;
}
@media (min-width: 640px) {
  .sidebar-panel {
    width: 20rem; /* 320px */
  }
}

/* Screen sharing strip smaller on mobile */
@media (max-width: 639px) {
  #videoArea.screen-sharing-active #videoGrid {
    flex: 0 0 110px;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)) !important;
    grid-auto-rows: 100px !important;
  }

  .video-tile {
    min-height: 80px;
  }
}

/* Toast above mobile bottom bar */
@media (max-width: 639px) {
  #toastContainer {
    bottom: 5.5rem;
  }
}
