/*
 * SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
 *
 * SPDX-License-Identifier: AGPL-3.0-only
 */

.conversejs {
  livechat-converse-muc-poll {
    background-color: var(--peertube-main-background);
    color: var(--peertube-main-foreground);

    & > div {
      border: 1px solid var(--peertube-menu-background);
      margin: 5px;
      padding: 5px;

      .livechat-poll-toggle {
        background: unset;
        border: 0;
        padding-left: 0.25em;
        padding-right: 0.25em;
      }

      .livechat-poll-close {
        background: unset;
        border: 0;
        float: right;
      }

      p.livechat-poll-question {
        text-align: center;
        font-weight: bold;

        span {
          cursor: pointer; // because a click toggles
        }
      }

      p.livechat-poll-instructions {
        text-align: right;
      }

      p.livechat-poll-end {
        text-align: right;
      }

      table {
        text-align: left;
        vertical-align: middle;
        width: 100%;

        td:first-child {
          padding-right: 0.5rem;
          white-space: nowrap;
        }

        td.livechat-poll-choice-label {
          width: 100%;
        }

        td:last-child {
          white-space: nowrap;
          width: 120px;
        }
      }

      .livechat-progress-bar {
        background-color: var(--peertube-menu-background);
        border: 1px solid var(--peertube-menu-background);
        color: var(--peertube-menu-foreground);
        height: 1.25rem;
        font-size: 0.75rem;
        margin: 0;
        position: relative;
        width: 100px;

        div {
          background-color: var(--peertube-button-background);
          float: left;
          height: 100%;
          position: absolute;
          z-index: 1;
        }

        p {
          display: inline;
          height: 100%;
          text-align: center;
          position: absolute;
          white-space: nowrap;
          width: 100%;
          z-index: 2;
        }
      }
    }
  }

  &[livechat-converse-root-height="small"],
  &[livechat-converse-root-height="medium"] {
    /* stylelint-disable-next-line no-descending-specificity */
    livechat-converse-muc-poll > div {
      max-height: 150px;
      overflow-y: scroll;
    }
  }
}

body[livechat-viewer-mode="on"] {
  livechat-converse-muc-poll {
    /* Dont display the poll before user choose a nickname */
    display: none !important;
  }
}

.livechat-readonly {
  .conversejs {
    /* stylelint-disable-next-line no-descending-specificity */
    livechat-converse-muc-poll > div {
      // In readonly mode, dont impose max-height
      max-height: initial !important;
      overflow-y: visible !important;

      &.livechat-poll-over {
        // stop showing poll when over in readonly mode
        display: none !important;
      }

      p.livechat-poll-instructions {
        // No need for instruction in readonly mode
        display: none !important;
      }
    }
  }
}