/* Download Center v578: automatic compatibility playback without a manual button */

/* Native dialogs must remain centered across desktop browsers and themes. */
dialog[open] {
  position: fixed !important;
  inset: 0 !important;
  margin: auto !important;
  max-width: calc(100vw - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  box-sizing: border-box !important;
  overflow: auto !important;
}

/*
  Keep the action controls above legacy themes that stretch .file-link across
  the row. These rules only affect hit testing; they do not block any clicks.
*/
#fileRows .actions {
  position: relative !important;
  z-index: 4 !important;
  pointer-events: auto !important;
}

#fileRows .file-menu {
  position: relative !important;
  z-index: 5 !important;
  pointer-events: auto !important;
}

#fileRows .menu-pop {
  z-index: 6 !important;
  pointer-events: auto !important;
  background: #fff !important;
  color: #171a20 !important;
  opacity: 1 !important;
}

/* Escape table/card overflow on mobile browsers via the native top layer. */
#fileRows .menu-pop.menu-top-layer {
  display: block !important;
  position: fixed !important;
  width: 190px !important;
  min-width: 190px !important;
  margin: 0 !important;
  max-width: calc(100vw - 20px) !important;
  max-height: calc(100dvh - 20px) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  box-sizing: border-box !important;
  transform: none !important;
  z-index: 2147483647 !important;
}

#fileRows .menu-pop.menu-top-layer > button,
#fileRows .menu-pop.menu-top-layer > a {
  display: flex !important;
  width: 100% !important;
  box-sizing: border-box !important;
  white-space: nowrap !important;
}

/* In-browser player for native video and FFmpeg compatibility streams. */
#videoDialog {
  width: min(960px, calc(100vw - 32px));
  padding: 18px;
  border: 1px solid #d9e0e8;
  border-radius: 18px;
  background: #fff;
  color: #171a20;
}

#videoDialog .video-dialog-header,
#videoDialog .video-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#videoDialog .video-dialog-header {
  margin-bottom: 14px;
}

#videoDialog .video-close-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #d85555;
  border-radius: 10px;
  background: #fff1f1;
  color: #b52323;
  font-weight: 800;
  cursor: pointer;
}

#videoDialog .video-close-btn:hover {
  border-color: #b52323;
  background: #ffe2e2;
}

#videoDialog .video-dialog-header h2 {
  max-width: min(680px, 65vw);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#videoDialog #videoStatus {
  margin: 0;
  color: #667180;
  font-size: 13px;
}

#videoDialog .video-stage {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
}

#videoDialog #videoPlayer {
  display: block;
  width: 100%;
  max-height: min(68dvh, 700px);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #000;
  object-fit: contain;
}

#videoDialog .video-tracks-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgb(255 255 255 / 45%);
  border-radius: 10px;
  background: rgb(15 20 27 / 82%);
  color: #fff;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

#videoDialog .video-tracks-btn.hidden {
  display: none !important;
}

#videoDialog .video-track-controls {
  position: absolute;
  top: 60px;
  right: 12px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px 12px;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 72px);
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 12px;
  background: rgb(15 20 27 / 92%);
  box-shadow: 0 16px 38px rgb(0 0 0 / 45%);
  backdrop-filter: blur(16px);
  box-sizing: border-box;
}

#videoDialog .video-track-controls.hidden {
  display: none !important;
}

#videoDialog .video-track-controls label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #d9e2ee;
  font-size: 12px;
  font-weight: 700;
}

#videoDialog .video-track-controls select {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid #536072;
  border-radius: 9px;
  background: #222a35;
  color: #fff;
}

#videoDialog #videoTrackHint {
  grid-column: 1 / -1;
  color: #bac5d2;
}

#videoDialog .video-dialog-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

#videoDialog .video-download-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #4f91e8;
  border-radius: 10px;
  background: #eaf4ff;
  color: #0968cf;
  font-weight: 700;
  text-decoration: none;
}

#videoDialog::backdrop {
  background: rgb(0 0 0 / 68%);
}

html[data-theme="dark"] #videoDialog {
  border-color: #394250;
  background: #171c24;
  color: #f2f5f8;
}

html[data-theme="dark"] #videoDialog #videoStatus {
  color: #aeb8c5;
}

html[data-theme="dark"] #videoDialog .video-close-btn {
  border-color: #a94444;
  background: #3b2024;
  color: #ff9b9b;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #videoDialog {
    border-color: #394250;
    background: #171c24;
    color: #f2f5f8;
  }

  html:not([data-theme="light"]) #videoDialog #videoStatus {
    color: #aeb8c5;
  }

  html:not([data-theme="light"]) #videoDialog .video-close-btn {
    border-color: #a94444;
    background: #3b2024;
    color: #ff9b9b;
  }

}

@media (max-width: 640px) {
  #videoDialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px) !important;
    padding: 12px;
    border-radius: 14px;
  }

  #videoDialog .video-dialog-header h2 {
    max-width: 56vw;
    font-size: 18px;
  }

  #videoDialog #videoPlayer {
    max-height: 60dvh;
  }

  #videoDialog .video-track-controls {
    grid-template-columns: 1fr;
    top: 56px;
    right: 8px;
    width: calc(100% - 16px);
    max-height: calc(100% - 64px);
    padding: 10px;
  }

  #videoDialog .video-tracks-btn {
    top: 8px;
    right: 8px;
    min-height: 36px;
    font-size: 12px;
  }

  #videoDialog #videoTrackHint {
    grid-column: 1;
  }

  #videoDialog .video-dialog-actions > * {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Fallback for browsers without the Popover API. */
#fileRows .menu-pop.open-up {
  top: auto !important;
  bottom: calc(100% + 8px) !important;
}

/*
  A menu extends over later table rows. Raise its complete row/cell stacking
  context so later action cells cannot paint over it or steal its clicks.
*/
#fileRows tr.menu-open {
  position: relative !important;
  z-index: 1000 !important;
}

#fileRows .actions.menu-open {
  z-index: 1001 !important;
}

#fileRows .file-menu.menu-open,
#fileRows .file-menu.menu-open .menu-pop {
  z-index: 1002 !important;
}

html[data-theme="dark"] #fileRows .menu-pop {
  background: #171c24 !important;
  color: #f2f5f8 !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #fileRows .menu-pop {
    background: #171c24 !important;
    color: #f2f5f8 !important;
  }
}

#fileRows [data-menu],
#fileRows [data-action],
#fileRows [data-share],
#fileRows .menu-pop a {
  pointer-events: auto !important;
}

#usersList button,
#clearAuditBtn,
#sharesList button {
  background: #242a32;
  color: #eef3f8;
  border: 1px solid #4a5360;
}

#usersList button:hover:not(:disabled),
#clearAuditBtn:hover:not(:disabled),
#sharesList button:hover:not(:disabled) {
  background: #303741;
  color: #fff;
  border-color: #626d7c;
}

#usersList button[data-user-password] {
  background: #3b2f17 !important;
  color: #ffd27a !important;
  border-color: #9a752a !important;
}

#usersList button[data-user-roots] {
  background: #17345a !important;
  color: #9dccff !important;
  border-color: #376da7 !important;
}

#usersList button[data-user-roots]:hover:not(:disabled) {
  background: #204572 !important;
  color: #c8e2ff !important;
  border-color: #4b87c8 !important;
}

#usersList .user-root-label {
  color: #9dccff;
  font-weight: 700;
}

#usersList button[data-user-password]:hover:not(:disabled) {
  background: #4a3a1c !important;
  color: #ffe3a4 !important;
  border-color: #c3983d !important;
}

#manageDialog button.ui-primary {
  background: #2679e8 !important;
  color: #fff !important;
  border-color: #70adff !important;
}

#manageDialog button.ui-primary:hover:not(:disabled) {
  background: #3488f4 !important;
  color: #fff !important;
  border-color: #8bbcff !important;
}

#manageDialog button.ui-danger,
#manageDialog button.clear-revoked-btn {
  background: #3a1f25 !important;
  color: #ff9da8 !important;
  border-color: #9d4651 !important;
}

#manageDialog button.ui-danger:hover:not(:disabled),
#manageDialog button.clear-revoked-btn:hover:not(:disabled) {
  background: #512830 !important;
  color: #ffc0c7 !important;
  border-color: #c95a68 !important;
}

#manageDialog button.clear-revoked-btn {
  color: #ffabb4 !important;
  border-color: #a44752 !important;
}

#manageDialog button.clear-revoked-btn:hover:not(:disabled) {
  color: #ffd0d5 !important;
}

#manageDialog button:disabled,
#manageDialog button.clear-revoked-btn:disabled {
  background: #252a30 !important;
  color: #8e98a5 !important;
  border-color: #3e4650 !important;
  opacity: .72;
  cursor: not-allowed;
}

#clearAuditBtn,
#clearRevokedBtn {
  width: auto !important;
  min-width: 0 !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 14px !important;
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
}

.clear-revoked-row {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
}

.clear-revoked-row .user-actions {
  margin-left: auto;
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  #clearAuditBtn,
  #clearRevokedBtn {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 12px !important;
  }

  .clear-revoked-row {
    flex-wrap: wrap;
  }
}
