/* Drawing plugin over the shared screen (static/js/meetings/draw.js, Excalidraw). */
.meet-draw-host {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.meet-draw-host .excalidraw {
  --color-surface-lowest: transparent;
  background: transparent !important;
}

.meet-tile-screen:not(.is-drawing) .meet-draw-host .layer-ui__wrapper,
.meet-tile-screen:not(.is-drawing) .meet-draw-host .App-bottom-bar,
.meet-tile-screen:not(.is-drawing) .meet-draw-host .App-toolbar-container,
.meet-tile-screen:not(.is-drawing) .meet-draw-host .scroll-back-to-content,
.meet-draw-host .default-sidebar-trigger,
.meet-draw-host .sidebar-trigger,
.meet-draw-host .help-icon,
.meet-draw-host .HelpDialog__header {
  display: none !important;
}

.meet-tile-screen.is-drawing .meet-draw-host {
  pointer-events: auto;
}

.meet-tile-screen.is-board .meet-screen-video {
  visibility: hidden;
}

.meet-tile-screen.is-drawing .meet-screen-name,
.meet-tile-screen.is-drawing .meet-screen-view {
  display: none;
}

.meet-draw-ctl {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 5;
  display: flex;
  gap: 6px;
}

/* With the tools open, Excalidraw's bars take the top and the corners. */
.meet-tile-screen.is-drawing .meet-draw-ctl {
  left: auto;
  top: auto;
  right: 10px;
  bottom: 70px;
}

.meet-draw-ctl button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

.meet-draw-ctl button:hover {
  background: rgba(0, 0, 0, 0.88);
}



@media (max-width: 640px) {
  .meet-tile {
    border-radius: 8px;
  }

  .meet-tile-pin {
    width: 26px;
    height: 26px;
    font-size: 12px;
    opacity: 0.85;
  }

  .meet-tile-hand {
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
  }

  .meet-tile-admin button {
    width: 26px;
    height: 26px;
    font-size: 11px;
  }
}

/* Bottom bar while the provider joins. The kit's control bar only appears
 * after joining; this keeps the call from opening with no controls. */
#meetWaitBar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px 8px;
  background: rgba(8, 8, 8, 0.96);
  color: #e7e5e4;
}

#meetWaitBar.hidden {
  display: none;
}

.meet-wait-note {
  font-size: 12px;
  font-weight: 700;
}

.meet-wait-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meet-wait-actions .meet-bar-btn,
.meet-wait-actions .meet-hang-icon {
  opacity: 0.5;
  cursor: default;
}

/* --- controls we build in the RealtimeKit control bar -------------------- */

.meet-bar-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 9999px;
  background: #292524;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.meet-bar-btn:hover {
  background: #44403c;
}

.meet-bar-btn.meet-off {
  color: #ef4444;
}

.meet-bar-btn.meet-raised {
  background: #f59e0b;
  color: #451a03;
}

.meet-bar-icon {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
}

.meet-bar-group {
  row-gap: 8px;
  column-gap: 8px;
  flex-wrap: nowrap;
}

.meet-bar-group.meet-phone {
  flex-wrap: nowrap;
}

/* When sharing on phone: share + draw on a top row, the rest below, separated
 * by a 2px gray line, all inside the same group. */
.meet-bar-group.meet-phone.meet-share-top {
  flex-wrap: wrap;
  overflow: visible;
  align-content: flex-start;
  height: auto;
  max-height: none;
}

/* Keep the host from clipping the taller two-row bar. */
.meet-bar-group.meet-phone.meet-share-top,
rtk-controlbar {
  overflow: visible;
}
.meet-bar-group.meet-phone.meet-share-top #meetShareBtn,
.meet-bar-group.meet-phone.meet-share-top #meetDrawBtn {
  order: 0;
}
.meet-bar-group.meet-phone.meet-share-top #meetDivider {
  order: 1;
  display: block;
  flex-basis: 100%;
  width: 100%;
  height: 2px;
  background: #9ca3af;
  margin: 2px 0 4px;
  border: 0;
}
.meet-bar-group.meet-phone.meet-share-top .meet-bar-btn:not(#meetShareBtn):not(#meetDrawBtn),
.meet-bar-group.meet-phone.meet-share-top .meet-hang-phone,
.meet-bar-group.meet-phone.meet-share-top :host(rtk-controlbar-button[data-meet-more]) {
  order: 2;
}

/* Desktop bar: left controls, camera/mic group and participants spread over
 * the full width. */
@media (min-width: 769px) {
  rtk-controlbar,
  :host(rtk-controlbar) {
    justify-content: space-between;
  }
}

.meet-divider {
  display: none;
}

.meet-hang-phone {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
}

.meet-hang-icon {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.meet-hang-phone:hover,
.meet-hang-icon:hover {
  background: #ef4444;
}

/* The bar stays invisible until our buttons are in it, so the kit's text
 * labels never flash on screen. */
:host(.meet-bar-waiting) rtk-controlbar:not(:has(#meetMicBtn)) {
  visibility: hidden !important;
}

/* --- third-party controls we skin as site buttons ------------------------ */

/* A controlbar button that shows the site's icon font instead of the kit's
 * icon and label. :host(rtk-controlbar-button) keeps these rules inside the
 * control's own shadow root, so they never touch the menu rows or other
 * components. The rules target the stable part="button", so the kit can
 * re-render the button without losing the skin; the glyph is read from
 * data-meet-icon with ::before (no extra element to lose). */
:host(rtk-controlbar-button) button[part="button"] {
  position: relative;
  background: #292524;
  border: 0;
  border-radius: 12px;
  color: #fff;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

:host(rtk-controlbar-button) button[part="button"]:hover {
  background: #44403c;
}

:host(rtk-controlbar-button) button[part="button"] rtk-icon,
:host(rtk-controlbar-button) button[part="button"] .label {
  display: none !important;
}

:host(rtk-controlbar-button) button[part="button"]::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  color: #fff;
  content: attr(data-meet-icon);
}

/* The "…" menu keeps its own menu; only its button is restyled round. */
:host(rtk-controlbar-button) button[part="button"][aria-label="More"],
:host(rtk-controlbar-button[data-meet-more]) button[part="button"] {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 9999px;
  padding: 0;
}

/* Pending counts (unvoted polls on "...", unread chat on the chat button):
 * rtk_skin.js sets the attribute only while there is something pending. */
:host(rtk-controlbar-button) button[part="button"][data-meet-badge]::after {
  content: attr(data-meet-badge);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: 9999px;
  background: #dc2626;
  color: #fff;
  font-family: sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

/* The chat count is ours (rtk_skin.js), so the kit's own badge is hidden. */
:host(rtk-chat-toggle) .unread-count {
  display: none !important;
}

/* The kit anchors the "..." menu 96px right of its own button. On a phone the
 * button already sits near the edge, so the menu opened partly off-screen;
 * align it to the button and keep it inside the viewport. */
@media (max-width: 768px) {
  :host(rtk-more-toggle) .more-menu {
    right: 0;
    width: min(256px, calc(100vw - 24px));
    max-height: 50vh;
  }
}

/* RealtimeKit gives every controlbar button a min-width of 80px (and a
 * background on the host). The "…" button must be the same 48px square as
 * the bar buttons next to it, so shrink the host itself. */
:host(rtk-controlbar-button[data-meet-more]) {
  width: 48px;
  height: 48px;
  min-width: 0;
  background-color: transparent;
}

/* Narrow phones: seven round buttons (mic, camera, share, hand, reactions,
 * "…", leave) must fit in one row. */
@media (max-width: 420px) {
  .meet-bar-group.meet-phone {
    column-gap: 5px;
  }

  .meet-bar-group.meet-phone .meet-bar-btn,
  .meet-bar-group.meet-phone .meet-hang-phone,
  :host(rtk-controlbar-button[data-meet-more]) {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }
}

/* Excalidraw mobile toolbar: lift it 20px so it doesn't hug the bottom edge. */
.meet-draw-host .App-bottom-bar {
  padding-bottom: 20px !important;
}

:host(.meet-no-header) rtk-header {
  display: none !important;
}

:host(.meet-no-header-right) #header-right {
  display: none !important;
}

.meet-people-more {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
}

/* Avatar per-letter color (default purple); video bg matches the call bg */
.meet-tile-ui {
  --rtk-colors-brand-500: 139 92 246;
  --rtk-colors-text-on-brand-1000: 255 255 255;
  --rtk-colors-video-bg: 41 37 36;
  --rtk-colors-background-700: 41 37 36;
}

/* inset the avatar initials so they don't touch the circle edge */
.meet-tile-ui rtk-avatar::part(initials) {
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cloudflare's own "Plugins" control: the drawing plugin has its own button. */
rtk-plugins-toggle {
  display: none !important;
}
