@import url('https://fonts.googleapis.com/css2?family=Assistant:wght@200..800&display=swap');

:root {
  --border-color: #ccd5db;
  --border-emphasis-color: #777a7c;
  --selected-color: #d0d7df;
  --link-color: #176eb6;
  --sidebar-module-background-color: #f2f4f5;
}

body.school {
  font-size: 16px;

  .nav-lessons {
    cursor: pointer;
    display: none;
    width: 24px;
    height: auto;
    border: solid 2px var(--lead-color);
    border-radius: 3px;
  }

  .row.page-content {
    padding: 20px 0px;
  }

  .school-container {
    * {
      line-height: 2em;
      font-family: Assistant, sans-serif;
      margin: 0;
      box-sizing: border-box;
      margin: 0;
    }

    ol,
    ul {
      list-style-position: inside;
    }
  }

  .school-container.classroom {
    min-height: 100vh;

    width: 100%;
    display: grid;
    grid-template-columns: 450px 1fr;

    label {
      margin: 0;
    }

    a {
      color: var(--link-color);
      &:hover {
        color: black;
      }
    }

    .school-sidebar {
      height: 100%;
      max-height: 100vh;
      overflow: scroll;

      .sidebar-header {
        top: 0;
        position: sticky;
        z-index: 2;
        background-color: white;
        font-weight: bold;
        padding: 0.8rem;
        border: 1px solid var(--border-color);
        border-right: 0;
        display: flex;
        gap: 10px;
        align-items: center;

        > label, > .course-name {
          flex-grow: 1;
          font-size: 1.2rem;
        }
        .course-duration {
          display: none;
        }
        .back-to-lobby {
          display: flex;
          align-items: center;
          cursor: pointer;
          img {
            width: 20px;
            height: 20px;
          }
          &:hover { opacity: 0.6; }
        }
        .course-options {
          width: 20px;
          height: 20px;
          cursor: pointer;
        }
        .close-sidebar {
          width: 20px;
          height: 20px;
          cursor: pointer;
          display: none;
        }
      }

      .sidebar-module {
        background: var(--sidebar-module-background-color);
        border: 0;
        border-left: 1px solid var(--border-color);
        transition: height 0.1s ease-in-out;

        .sidebar-module-header {
          padding: 1.6rem;
          cursor: pointer;
          display: grid;
          grid-template-columns: 1fr 20px;
          border-bottom: solid 1px var(--border-color);

          align-items: center;
          * {
            cursor: pointer;
          }
          .opener {
            font-size: 1.4rem;
            display: grid;
            align-items: center;
            justify-content: center;
            transition: transform 0.1s ease-in-out;
            transform-origin: center center;
          }
        }

        &:last-child {
          .sidebar-lesson:last-child {
            border-bottom: solid 1px var(--border-color);
          }
        }

        .sidebar-lesson {
          display: none;
          justify-content: space-between;
          align-items: center;
          grid-template-columns: 1fr 20px;
          width: 100%;
          padding: 0.8rem 1.6rem;
          background: white;
          cursor: pointer;

          &:hover,
          &.selected {
            background: var(--selected-color);
          }

          * {
            cursor: pointer;
          }

          > img.play-icon {
            width: 20px;
            height: 20px;
            border-radius: 50%;
          }

          &.locked {
            &,
            * {
              color: #b0b0b0;
              cursor: not-allowed;
            }
            pointer-events: none;
            grid-template-columns: 20px 1fr 20px;

            &::before {
              content: '';
              display: inline-block;
              width: 18px;
              height: 18px;
              background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 1024 1024"><path fill="%23ababab" d="M800 384h-32V261.872C768 115.024 661.744 0 510.816 0C359.28 0 256 117.472 256 261.872V384h-32c-70.592 0-128 57.408-128 128v384c0 70.592 57.408 128 128 128h576c70.592 0 128-57.408 128-128V512c0-70.592-57.408-128-128-128zM320 261.872C320 152.784 394.56 64 510.816 64C625.872 64 704 150.912 704 261.872V384H320V261.872zM864.001 896c0 35.28-28.72 64-64 64h-576c-35.28 0-64-28.72-64-64V512c0-35.28 28.72-64 64-64h576c35.28 0 64 28.72 64 64v384zm-352-320c-35.344 0-64 28.656-64 64c0 23.632 12.96 44.032 32 55.12V800c0 17.664 14.336 32 32 32s32-14.336 32-32V695.12c19.04-11.088 32-31.504 32-55.12c0-35.344-28.656-64-64-64z"/></svg>');
              background-size: contain;
              background-repeat: no-repeat;
              background-position: center;
              color: #ababab;
            }
          }
        }

        &.open {
          height: min-content;

          .sidebar-lesson {
            display: grid;
            gap: 10px;
          }

          .sidebar-module-header {
            .opener {
              transform: rotate(-90deg) translate(-4px, -5px);
            }
          }
        }
      }
    }

    .lesson {
      height: 100vh;
      display: grid;
      grid-template-rows: 450px 1fr;

      &.no-videos {
        grid-template-rows: 1fr;
        .lesson-videos {
          display: none;
        }
        .lesson-materials {
          grid-template-rows: 58px 58px 1fr;

          .lesson-materials-nav {
            height: 60px;
            border: solid 1px var(--border-color);
          }

          .current-lesson-title {
            padding: 0.8rem;
            border-top: solid 1px var(--border-color);
            gap: 4px;
            border-left: 0;
            border-right: 0;
            display: flex;
            align-items: center;

            > .lesson-header {
              flex-grow: 1;
              display: flex;
              justify-content: center;

              .lesson-title {
                font-size: 1rem;
                font-weight: bold;
                white-space: break-spaces;
                line-height: 1.2rem;
              }
            }

            > * {
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
            }
          }
        }
      }

      .lesson-videos {
        padding: 0;
        border-left: 0;
        border-right: 0;

        .current-lesson-title {
          position: relative;
          overflow: visible;
          display: flex;
          width: 100%;
          justify-content: center;

          > .lesson-title {
            flex-grow: 1;
            font-size: 1rem;
            font-weight: bold;
            text-align: center;
            width: min-content;
            white-space: break-spaces;
            line-height: 1.2rem;
          }

          .lesson-header {
            .multiple-video-indication {
              font-size: 0.8rem;
              background: red;
              text-align: center;
              border-radius: 4px;
              color: white;
              width: max-content;
              padding-left: 4px;
              position: absolute;
              left: 50%;
              transform: translate(-50%, 28px);
              background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0,0,256,256' width='16px' height='16px' fill-rule='nonzero'%3E%3Cg fill='%23ffffff' fill-rule='nonzero' stroke='none' stroke-width='1' stroke-linecap='butt' stroke-linejoin='miter' stroke-miterlimit='10' stroke-dasharray='' stroke-dashoffset='0' font-family='none' font-weight='none' font-size='none' text-anchor='none' style='mix-blend-mode: normal'%3E%3Cg transform='scale(5.12,5.12)'%3E%3Cpath d='M25,2c-12.6907,0 -23,10.3093 -23,23c0,12.69071 10.3093,23 23,23c12.69071,0 23,-10.30929 23,-23c0,-12.6907 -10.30929,-23 -23,-23zM25,4c11.60982,0 21,9.39018 21,21c0,11.60982 -9.39018,21 -21,21c-11.60982,0 -21,-9.39018 -21,-21c0,-11.60982 9.39018,-21 21,-21zM25,11c-1.65685,0 -3,1.34315 -3,3c0,1.65685 1.34315,3 3,3c1.65685,0 3,-1.34315 3,-3c0,-1.65685 -1.34315,-3 -3,-3zM21,21v2h1h1v13h-1h-1v2h1h1h4h1h1v-2h-1h-1v-15h-1h-4z'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
              background-repeat: no-repeat;
              background-position: right 4px center;
              padding-right: 26px;

              &.hidden {
                display: none;
              }
            }
          }
        }

        .lesson-videos-nav {
          padding: 0.8rem;
          border: solid 1px var(--border-color);
          gap: 4px;
          border-left: 0;
          border-right: 0;
          display: flex;
          justify-content: space-between;

          .lesson-header {
            flex-grow: 1;
            display: flex;
            justify-content: center;

            .lesson-title {
              font-size: 1rem;
              font-weight: bold;
            }
          }
          > * {
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
          }

          a.hide {
            display: none;
          }
        }

        .video-container {
          background: black;
          display: grid;
          justify-items: center;

          &.no-videos-available {
            background-color: white;
            color: black;
          }

          iframe {
            height: 400px;
            width: calc(400px * 1.88235);
            max-width: 100vw;
          }

          video {
            width: 100%;
            height: auto;
            max-height: 400px;
            object-fit: contain;
          }
        }
      }

      .lesson-materials {
        display: grid;
        grid-template-rows: 58px 1fr;
        overflow: scroll;

        .current-lesson-title {
          display: none;
        }

        .lesson-materials-nav {
          list-style: none;
          display: flex;
          gap: 1.6rem;
          padding: 0.8rem 0 0 0;
          border-bottom: 2px solid var(--border-color);

          li {
            display: grid;
            align-items: center;
            line-height: 1rem;
            padding: 0.8rem;
            padding-top: 0;
            padding-bottom: 0;
            cursor: pointer;

            &.selected {
              font-weight: bold;
              border-bottom: solid 2px var(--border-emphasis-color);
              position: relative;
              padding-bottom: 2px;
              top: 2px;
            }

            &:last-child {
              margin-right: auto;
              cursor: pointer;
              img {
                width: 20px;
                height: 20px;
                transition: transform 0.2s ease-in-out;
              }

              &.rotated {
                img {
                  transform: rotate(180deg);
                }
              }
            }
          }
        }

        .lesson-content-viewer {
          padding: 0.8rem;
          line-height: 1.4rem;
          height: 100%;
          overflow: scroll;

          pre {
            line-height: 1.4rem;
          }

          img {
            max-width: 100%;
            height: auto;
          }

          .notebook-container {
            position: relative;
            width: 100%;
            height: 300px;
            overflow: auto;
            border: 1px solid #ccc;
            font-family: monospace;
            font-size: 1.2rem;
            line-height: 24px;

            .notebook-lines {
              position: absolute;
              top: 0;
              left: 0;
              right: 0;
              height: 2000px; /* long enough */
              background: repeating-linear-gradient(to bottom, #ffff001a, #ffff001a 23px, #e0e0e0 24px);
              pointer-events: none;
              z-index: 0;
            }

            .student-notes {
              position: relative;
              z-index: 1;
              padding: 0 8px; /* no vertical padding */
              min-height: 100%;
              outline: none;
              white-space: pre-wrap;
              line-height: 24px;
            }
            .student-notes * {
              line-height: 24px;
            }
          }

          .wp-block-table {
            td {
              border: solid 1px #656f74;
              padding: 4px 6px;
            }
          }
        }
      }
    }
  }

  .personal-container {
    padding: 20px 50px;

    .class-header {
      h1 {
        font-size: 1.6rem;
      }
      h2 {
        font-size: 1.3rem;
      }
      margin: 20px 0;
    }
    .school-content {
      .message {
        width: 100%;
        border: solid 1px #59c359;
        background: rgba(0, 128, 0, 0.18);
        padding: 10px;
      }

      .form-content {
        padding-top: 30px;

        .row {
          display: grid;
          grid-gap: 10px;
          padding: 10px;
          grid-template-columns: 100px 1fr;
          align-items: center;

          label {
            margin-bottom: 0;
          }

          input {
            border: solid 1px #e0e0e0;
            padding: 4px;
          }

          button {
            color: #404040;
            background: #fafafa;
            border: solid 1px #808080;
            cursor: pointer;
          }

          .description {
            grid-column: 2;
            font-size: 0.85em;
          }
        }
      }
    }
  }

  .school-container.lobby {
    min-height: 100vh;

    margin: 0 auto;

    .school-header {
      padding: 0 20px;
      display: flex;
      justify-content: space-between;
      flex-direction: row;
      align-items: center;
      gap: 10px;
      .tabs {
        display: flex;
        > a {
          &.selected {
            background-color: #efefef;
          }
          padding: 5px 10px;
          &:hover {
            text-decoration: none;
            background-color: #e0e0e0;
          }
        }

        .divider {
          width: 1px;
          border-left: solid 1px white;
        }
      }
    }

    .school-courses {
      padding: 20px;
      padding-top: 2px;
      display: grid;
      gap: 20px;

      .welcome-back {
        background-image: none;
        background-size: cover;
        background-color: rgba(255, 255, 255, 0.5);
        padding: 20px 40px;
        background: #fafafa;
        border-radius: 10px;
        display: grid;
        grid-template-areas:
          'slogan'
          'about';
        row-gap: 20px;
        justify-content: start;

        .welcome-about {
          grid-area: about;
          font-size: 1.2rem;
          line-height: 1.6rem;
          font-weight: bold;
          color: black;
          background: linear-gradient(90deg, transparent, white);
          padding: 4px 8px;
          display: inline-block;
          border-radius: 20px;
          height: fit-content;
          align-self: end;
          justify-self: end;
        }

        .welcome-slogan {
          grid-area: slogan;
          font-size: 3rem;
          line-height: 1.6rem;
          font-weight: bold;
          color: black;
          justify-self: end;
          align-self: center;
          height: fit-content;
          text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5), -1px 1px 0 rgba(255, 255, 255, 0.5),
            1px -1px 0 rgba(255, 255, 255, 0.5), -1px -1px 0 rgba(255, 255, 255, 0.5);
        }
      }

      .courses-header {
        padding: 5px 20px;
        color: #494949;
        background: #e6f1f9;
        border-radius: 5px;
      }

      .course-list {
        box-sizing: border-box;
        display: grid;
        width: 100%;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        grid-gap: 10px;
        overflow: hidden;
        * {
          box-sizing: border-box;
        }

        > .course-card {
          width: 100%;
          background: #f6f6f6;
          display: grid;
          align-content: start;
          gap: 6px;
          grid-template-rows: max-content 1fr;
          position: relative;

          &.featured {
            border: solid 2px #b908b9;

            &::after {
              content: 'Popular';
              position: absolute;
              top: 10px;
              left: 10px;
              background: #b908b9;
              color: white;
              font-weight: bold;
              padding: 0px 6px;
              border-radius: 4px;
              box-shadow: 0px 0px 10px white;
            }
          }

          .course-icon {
            max-width: 100%; /* Make sure the image does not exceed the parent's width */
            max-height: 100%; /* Make sure the image does not exceed the parent's height */
            object-fit: contain; /* Ensure the image is contained within the box while keeping its aspect ratio */
            width: auto;
            height: auto;
          }

          .course-details {
            padding: 0 10px 10px 10px;
            position: relative;
            display: flex;
            flex-direction: column;
            > * {
              margin: 0;
              line-height: 1.3rem;
            }

            .course-name {
              font-weight: bold;
              font-size: 1.1rem;
            }

            .course-author {
              font-weight: 100;
              font-size: 0.9rem;
            }

            .read-more-indicator {
              background: #186ff9;
              cursor: pointer;
              width: max-content;
              padding: 0 7px;
              border-radius: 7px;
              color: white;
              font-weight: bold;
              font-size: 1rem;
              margin: 0;
              height: 16px;
              display: flex;
              align-items: end;
              position: relative;
              top: -7px;
            }

            &:has(.read-more-indicator:hover) .course-short-desc {
              overflow: auto;

              .course-read-more {
                display: block;
              }
              .read-more-arrow {
                display: block;
              }
            }

            .course-short-desc {
              margin: 10px 0;
              font-size: 0.95rem;
              max-height: calc(1.2rem * 4);
              text-overflow: ellipsis;
              overflow: hidden;

              &,
              * {
                line-height: 1.2rem;
              }

              &:has(.course-read-more:hover) {
                overflow: auto;

                .course-read-more {
                  display: block;
                }
                .read-more-arrow {
                  display: block;
                }
              }

              .course-read-more {
                display: none; /* Hidden by default */
                position: absolute;
                bottom: 60px;
                background-color: #fff;
                color: #333;
                padding: 10px;
                width: calc(100% - 20px);
                max-height: calc(1.2rem * 15); /* Limit balloon height to 10 rows */
                overflow-y: auto; /* Make it scrollable if the content is too long */
                box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* Drop shadow */
                border-radius: 5px;
                z-index: 9998;
              }
              .read-more-arrow {
                display: none;
                position: absolute;
                width: 10px;
                height: 10px;
                background-color: white;
                bottom: 55px;
                left: 50%;
                transform: translate(50%) rotate(45deg);
                z-index: 9999;
              }
            }
          }
        }
      }

      .course-details {
        .course-details {
          display: flex;
          flex-direction: column;
          > * {
            margin: 0;
            line-height: 1.3rem;
          }
          .course-icon {
            width: 100%;
            max-height: 200px;
            object-fit: cover;
            overflow: hidden;
          }

          .course-name {
            margin-top: 14px;
            font-size: 1.2rem;
            font-weight: bold;
          }
          .course-author {
            font-weight: 100;
          }
          .course-short-desc {
            background: #f8f8f8;
            padding: 10px;
            margin: 10px 0;
          }

          .course-price {
            font-weight: bold;
            margin-bottom: 8px;
          }

          .buy-now {
            border: 0;
            cursor: pointer;
            background: #b908b9;
            color: white;
            line-height: 2rem;
            padding: 5px 10px;
            font-weight: bold;
            width: 100%;
            max-width: 200px;
            text-align: center;
          }
        }
      }

      .my-courses {
        .course-card {
          .course-details {
            margin-top: 10px;
          }
          .course-short-desc {
            margin-bottom: 10px;
          }

          .course-progress {
            flex-grow: 1;
            align-content: end;

            .course-progress-bar {
              line-height: 2rem;
              border-radius: 1rem;
              padding: 0 1rem;
              margin-bottom: 10px;
              border: solid 1px #46da9c;
              display: block;
              width: 100%;
            }
          }

          .enter-course {
            border: 0;
            cursor: pointer;
            background: #b908b9;
            color: white;
            line-height: 2rem;
            padding: 5px 10px;
            font-weight: bold;
            width: 100%;
          }

          .diploma-download {
            display: block;
            text-align: center;
            border: 2px solid #b08d57;
            color: #b08d57;
            line-height: 2rem;
            padding: 5px 10px;
            font-weight: bold;
            width: 100%;
            margin-top: 6px;
            text-decoration: none;
            box-sizing: border-box;
            &:hover {
              background: #b08d57;
              color: white;
              text-decoration: none;
            }
          }
        }
      }

      .available-courses {
        .course-card {
          .course-details {
            .course-price {
              font-weight: bold;
              flex-grow: 1;
              align-content: end;
            }

            .add-to-cart {
              background-color: #b908b9;
              border: 0;
              line-height: 2rem;
              color: white;
              text-align: center;
              text-decoration: none;
              padding: 5px 10px;
              font-weight: bold;
              margin-top: 10px;
              display: flex;
              width: 100%;
              align-items: center;
              justify-content: center;
              cursor: pointer;
              gap: 10px;
              > img {
                width: 20px;
                height: 20px;
              }
            }
          }

          .course-icon {
            max-width: 100%; /* Make sure the image does not exceed the parent's width */
            max-height: 100%; /* Make sure the image does not exceed the parent's height */
            object-fit: contain; /* Ensure the image is contained within the box while keeping its aspect ratio */
            width: auto;
            height: auto;
          }
        }
      }
    }
  }
}

@media screen and (max-width: 1350px) {
  body.school {
    .school-container.classroom {
      grid-template-columns: 300px 1fr;
    }
  }
}

@media screen and (max-width: 991px) {
  body.school {
    font-size: 14px;

    nav.navbar {
      justify-content: flex-end;
      padding: 8px;
      min-height: 68px;
    }

    .school-container.lobby .school-courses {
      .welcome-back {
        row-gap: 10px;

        .welcome-title {
          height: 180px;
          width: 180px;
          font-size: 1.6rem;
          line-height: 1.8rem;
        }
        .welcome-slogan {
          font-size: 2.5rem;
        }
        .welcome-about {
          font-size: 1rem;
          font-weight: normal;
        }
      }
    }
  }
}

@media screen and (max-width: 900px) {
  body.school {
    .school-container.classroom {
      .nav-lessons {
        display: block;
        position: relative;
      }
    }

    .school-container.lobby .school-courses {
      .welcome-back {
        padding: 6px 12px;

        .welcome-title {
          height: 120px;
          width: 120px;
          font-size: 1.3rem;
          box-shadow: 8px 2px 0px #43aaff;
          line-height: 1.4rem;
        }
        .welcome-slogan {
          font-size: 1.8rem;
          line-height: 1.8rem;
          text-align: center;
        }
        .welcome-about {
          font-size: 0.9rem;
          font-weight: normal;
        }
      }
    }

    .school-container.classroom {
      grid-template-columns: 1fr;

      .school-sidebar {
        display: none;
        width: 100%;
        z-index: 2;

        &.show {
          display: block;
          position: fixed;
          top: 0;
          height: 100vh;
          left: 0;
          overflow: scroll;
          background: white;
        }

        .sidebar-header {
          .close-sidebar {
            display: block;
            cursor: pointer;
            width: 20px;
            height: 20px;
          }
        }
      }
    }
  }
}

@media screen and (max-width: 500px) {
  body.school {
    font-size: 12px;

    .personal-container {
      .school-content .form-content .row {
        grid-template-columns: 80px 1fr;
      }
    }

    .school-container {
      &.lobby {
        .school-courses {
          .welcome-back {
            padding: 6px 12px;

            .welcome-title {
              height: 100px;
              width: 100px;
              font-size: 0.95rem;
              box-shadow: 6px 2px 0px #43aaff;
            }
            .welcome-slogan {
              font-size: 2rem;
              line-height: 1.8rem;
            }
            .welcome-about {
              display: none;
            }
          }

          .courses-header {
            font-size: 1.4rem;
            padding: 5px 20px;
            color: #494949;
            background: #e6f1f9;
            border-radius: 40px;
          }
        }
      }

      &.classroom {
        .lesson {
          .lesson-videos .lesson-videos-nav {
            font-size: 0.8rem;
          }
          .lesson-materials .lesson-materials-nav {
            gap: 0.2rem;
            font-size: 0.8rem;
          }

          textarea.student-notes {
            font-size: 0.8rem;
          }
        }
      }
    }
  }
}

@media screen and (max-height: 800px) {
  body.school {
    .school-container.classroom {
      .lesson {
        grid-template-rows: 350px 1fr;

        .lesson-videos {
          .video-container {
            iframe,
            video {
              height: 300px;
            }
          }
        }
      }
    }
  }
}

@media screen and (max-height: 580px) {
  body.school {
    .school-container.classroom {
      .lesson {
        grid-template-rows: 280px 1fr;

        .lesson-videos {
          .video-container {
            iframe,
            video {
              height: 240px;
            }
          }
        }
      }
    }
  }
}
