/*
 * Queue - A Queueing system that can be used to handle labs in higher education
 * Copyright (C) 2016-2020  Delft University of Technology
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
@import "variables";

/**
 * Class for the get-next buttons on the requests page.
 */
.btn-get-next {
    /* Default colouring when not disabled or hovered over */
    & {
        background-color: $primary !important;
        border-color: $primary !important;
    }

    /* Make the get-next button gray if it is disabled */
    &.disabled {
        background-color: $primary-disabled !important;
        border-color: $primary-disabled !important;
    }

    /* When hovering, use a different colour too */
    &:hover {
        background-color: $primary-hover !important;
        border-color: $primary-hover !important;
    }
}

.btn.disabled {
    background-color: $primary-disabled !important;
    border-color: $primary-disabled !important;
}

.btn-outline-info.disabled {
    color: white !important;
}

/**
 * A class for the progress bar used to signify capacity leftover on time slots.
 */
.timeslot-progress {
    display: inline-flex;
    left: -0.63rem;
    width: 115%;
    height: 8px;
    position: relative;
}

/**
 * A class used for showing a radio button as though it is a full div.
 */
.div-radio {
    /* Disallow showing the radio button when the div is the button */
    & > input {
        visibility: hidden;
        position: absolute;
    }

    /* Make the cursor a pointer when aiming at the target radio div */
    & > input + div {
        cursor: pointer;
        text-align: center;
    }

    /* When the input is hovered over, color the div */
    & > input + div:hover:enabled {
        color: #fff;
        background-color: $primary-hover;
    }

    /* When the input is checked, make it a slightly different colour */
    & > input:checked + div {
        color: #fff;
        background-color: $timeslot-checked;
        border-color: $timeslot-checked;
    }
}

.pagination {
    .active span {
        background-color: $pagination-bg-active !important;
        border-color: $pagination-bg-active !important;
    }

    .disabled span {
        background-color: $pagination-bg-disabled !important;
        border-color: $pagination-bg-disabled !important;
        color: $text-color-primary;
    }
}

/**
 * Boxed group
 */
.boxed-group {
    margin-bottom: 20px;

    h3 {
        display: block;
        padding: 9px 10px 10px;
        margin: 0;
        font-size: 14px;
        line-height: 17px;
        background-color: $background-secondary;
        border: 1px solid $border-primary;
        color: $text-color-primary;
        border-bottom: 0;
        border-radius: 3px 3px 0 0;
    }

    .boxed-group-inner {
        padding: 10px;
        font-size: 13px;
        border: 1px solid $border-primary;
        border-bottom-right-radius: 3px;
        border-bottom-left-radius: 3px;
    }

    .list-group-item:first-child {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .list-group-item li {
        line-height: 2em;
    }
}

.select-menu-button {
    padding-right: 15px;
    padding-left: 15px;
}

.table-list {
    display: table;
    width: 100%;
    color: $text-color-ternary;
    table-layout: fixed;
    border-bottom: 1px solid $border-inverse;
    padding-left: 0;
}

.table-list-item {
    position: relative;
    display: table-row;
    list-style: none;
}

.table-list-cell {
    position: relative;
    display: table-cell;
    padding: 8px 10px;
    font-size: 12px;
    vertical-align: top;
    border-top: 1px solid $border-inverse;

    &.status {
        width: 90px;
    }

    &:first-child {
        border-left: 1px solid $border-inverse;
    }

    &:last-child {
        border-right: 1px solid $border-inverse;
    }
}

a.filters-reset {
    color: $text-color-ternary;

    &:hover {
        color: $primary;
        text-decoration: none;
    }
}

.filters button {
    background-color: $button-background;
    color: $button-color;
}

/**
 * Panel box
 */
.mini-box {
    min-height: 120px;
    padding: 25px;

    .btn-icon {
        margin: 0 15px 0 0;
        font-size: 32px;
    }

    .box-info {
        display: inline-block;
        vertical-align: top;
    }
}

.panel {
    margin-bottom: 20px;
    background-color: $background-secondary;
    border: 1px solid transparent;
    border-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.btn-icon {
    display: inline-block;
    text-align: center;
    border-radius: 2px;
    height: 35px;
    width: 35px;
    line-height: 35px;
}

.btn-icon-round {
    border-radius: 50%;
}

.btn-icon-lg-alt {
    height: 70px;
    width: 70px;
    line-height: 70px;
}

.bg-info {
    background-color: $primary;
    color: $text-color-primary;
}

/**
 * Misc
 */
.table td.fit,
.table th.fit {
    white-space: nowrap;
    width: 1%;
}

dl.dl-horizontal dd {
    margin-bottom: 10px;
}

#queueGraph {
    width: 100%;
    height: 300px;
}

.input-daterange .input-group-addon {
    border-left: none;
    border-right: none;
}

div.row-xs {
    padding: 15px;

    &:nth-of-type(odd) {
        background-color: $background-primary;
    }
}

.time {
    font-size: 12px;
    color: $text-color-ternary;
    margin: 5px 0 0;
}

/**
 * Timeline
 */
.info-offset-left {
    margin-left: 50px;
}

.timeline-header {
    text-transform: uppercase;
    font-size: 12px;
    color: $text-color-ternary;
}

.timeline {
    clear: both;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;

    li {
        padding-bottom: 24px;
        margin-left: 50px;
        position: relative;

        &::before {
            top: 0;
            bottom: 0;
            position: absolute;
            content: " ";
            width: 1px;
            background-color: $border-primary;
            left: -40px;
            margin-left: 1px;
        }

        &:first-child::before {
            top: 10px;
        }

        &:last-child:before {
            top: 0;
            bottom: 0;
            height: 10px;
        }
    }

    .timeline-icon {
        position: absolute;
        top: 6px;
        left: -46px;
        z-index: 100;
        margin: 0;
        padding: 0;

        &::before {
            content: " ";
            position: absolute;
            display: block;
            width: 15px;
            height: 15px;
            border-radius: 50%;
            border: 3px solid $background-primary;
            margin: 0;
            top: 0;
            left: 0;
        }

        // Request Colours
        &.request-created::before {
            background-color: $background-pending;
        }

        &.request-revoked::before {
            background-color: $background-revoked;
        }

        &.request-approved::before {
            background-color: $background-approved;
        }

        &.request-selected::before {
            background-color: $background-approved;
        }

        &.request-taken::before {
            background-color: $background-processing;
        }

        &.request-forwarded::before {
            background-color: $background-forwarded;
        }

        &.request-rejected::before {
            background-color: $background-rejected;
        }

        &.request-not-selected::before {
            background-color: $background-rejected;
        }

        &.request-notfound::before {
            background-color: $background-notfound;
        }
    }

    .timeline-description {
        color: $text-color-secondary;
    }

    .timeline-time {
        color: $text-color-ternary;
    }
}

/**
 * Table
 */
.table-body {
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12);
}

.table-group {
    .table-row {
        border-bottom: 1px solid #e5e5e5;
        border-left: 1px solid #bfbfc1;
        border-right: 1px solid #bfbfc1;
        line-height: 44px;
        font-size: 15px;
        position: relative;
        word-wrap: break-word;

        &:first-child {
            border-top: 1px solid #bfbfc1;
        }

        &:first-child,
        &:first-child a,
        &:last-child {
            border-top-right-radius: 4px;
            border-top-left-radius: 4px;
        }

        &:last-child {
            border-bottom: 1px solid $border-primary;
        }
    }
}

/**
 * Unread indicator as overlay on hamburger menu
 */
.unread-indicator {
    position: absolute;
    display: block;
    width: 14px;
    height: 14px;
    background-color: $primary;
    border: 2px solid #333;
    border-radius: 50%;
}

.navbar-inverse {
    background-color: $navbar-background;
    border-color: $border-inverse;
    color: $navbar-text;

    .navbar-brand,
    .navbar-nav li a {
        color: $navbar-text;
    }
}

.navbar-header .unread-indicator {
    top: 0;
    right: 0;
}

.navbar-collapse .unread-indicator {
    top: 10px;
    right: 9px;
}

/**
 * List group
 */
.list-group .item-icon {
    padding-left: 3em;

    span.icon {
        position: absolute;
        top: 25px;
        left: 1em;
    }
}

.course-filter {
    margin-bottom: 20px;

    .count {
        float: right;
        font-weight: bold;
    }
}

/**
 * Truncation
 */
.truncate {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/**
 * Icon
 */
.icon.unread {
    width: 12px;
    height: 12px;
    color: $text-color-inverse;
    text-align: center;
    background-image: -webkit-linear-gradient(lighten($primary, 20%), $primary);
    background-image: linear-gradient(lighten($primary, 20%), $primary);
    background-clip: padding-box;
    border-radius: 50%;
}

/**
 * Pagehead
 */
.pagehead {
    position: relative;
    padding-top: 20px;
    margin-top: -20px;
    margin-bottom: 20px;
    padding-bottom: 0;
    background-color: $background-primary;
    border-bottom: 1px solid $border-primary;
    color: $text-color-primary;

    .nav-tabs {
        border-bottom: 0;
    }
}

/**
 * Page
 */
.page-sub-header {
    padding-bottom: 9px;
    margin: 20px 0 20px;
}

.nav {
    color: $navbar-text;
}

.nav-tabs {
    border-color: $navbar-tabs-border;

    .nav-link {
        color: $navbar-tabs-color;

        &:hover,
        &:focus-visible {
            border-color: $navbar-tabs-border;
        }

        &.active {
            color: $navbar-tabs-color;
            border-color: $navbar-tabs-border;
            background-color: $navbar-tabs-background;
        }
    }

    .fa {
        margin-right: 5px;
    }
}

/**
 * Lab list
 */
.list-group-item {
    background-color: $background-primary;
    border-color: $border-primary;

    &.lab-item {
        line-height: 30px;
    }
}

/**
 * Badge
 */
.badge {
    color: #fff;
}

/**
 * Blankslate
 */
.blankslate {
    position: relative;
    padding: 30px;
    text-align: center;
    color: $text-color-primary;
    background-color: $background-secondary;
    border: 1px solid $border-primary;
    border-radius: 3px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);

    h3 {
        margin-top: 0;
        margin-bottom: 0;
        font-size: 1.5em;
        line-height: 1.43;
    }

    p {
        margin: 0;
    }
}

.breadcrumbs {
    padding-top: 1em;
}

.breadcrumb {
    background: $background-secondary;
}

.breadcrumb-item {
    a {
        color: $text-color-secondary;
    }

    &.active {
        color: $text-color-primary;
    }
}

.container-alert {
    padding-top: 1em;
}

.page-header {
    margin-top: 1em;
    margin-bottom: 1em;
}

.bootstrap-datetimepicker-widget.dropdown-menu {
    display: block;
    margin: 2px 0;
    padding: 4px;
    width: 300px !important;
}

.nav-pills .menu-link.active {
    background: $navbar-selected !important;
}

.nav-pills,
.show > .nav-pills .nav-link {
    background: none;
}

.no-border-top th {
    border-top: none !important;
}

.sort-open {
    display: flex;
}

.lab-closed {
    order: 1;
}

.lab-open {
    order: 0;
}

/**
 * Tables
 */
.table {
    background-color: $background-primary;
    color: $text-color-primary;

    th,
    td {
        border-color: $background-secondary !important;
    }
}

/*
 * Cards
 */
.card {
    border-color: $border-primary;

    .card-header,
    .card-footer {
        background-color: $background-primary;
    }

    .card-body {
        background-color: $background-secondary;
    }

    &.queue-info {
        color: $text-color-queue;

        .card-header,
        .card-footer {
            background-color: $background-queue;
        }

        .card-body {
            background-color: $background-queue-secondary;
        }
    }

    &.location-info {
        color: $text-color-location;

        .card-header,
        .card-footer {
            background-color: $background-location;
        }

        .card-body {
            background-color: $background-location-secondary;
        }
    }

    &.lab-info {
        color: $text-color-lab;

        .card-header,
        .card-footer {
            background-color: $background-lab;
        }

        .card-body {
            background-color: $background-lab-secondary;
        }
    }

    &.more-info {
        color: $text-color-more;

        .card-header,
        .card-footer {
            background-color: $background-more;
        }

        .card-body {
            background-color: $background-more-secondary;
        }
    }

    &.approved {
        color: $approved-text;

        .card-header,
        .card-footer {
            background-color: $approved-primary;
        }

        .card-body {
            background-color: $approved-secondary;
        }
    }

    &.not-selected {
        color: $not-selected-text;

        .card-header,
        .card-footer {
            background-color: $not-selected-primary;
        }

        .card-body {
            background-color: $not-selected-secondary;
        }
    }
}

/**
 * Nav Tabs
 */

/**
 * Hacky solution to broken bootstrap styles when upgrading from 4.0.0 to 4.3.1
 */
.btn-buttonface {
    background-color: buttonface;
}

/**
 * Background colours
 */
.bg-processing {
    background-color: $background-processing !important;
}

.bg-rejected {
    background-color: $background-rejected !important;
}

.bg-not-selected,
.bg-notselected {
    background-color: $background-rejected !important;
}

.bg-pending {
    background-color: $background-pending !important;
}

.bg-revoked {
    background-color: $background-revoked !important;
}

.bg-approved {
    background-color: $background-approved !important;
}

.bg-selected {
    background-color: $background-approved !important;
}

.bg-notfound {
    background-color: $background-notfound !important;
}

.bg-notpicked {
    background-color: $background-notpicked !important;
}

.bg-forwarded {
    background-color: $background-forwarded !important;
}

.btn-time-slot {
    position: relative;
    min-height: 50px;
}

.btn-archive {
    font-size: 11px;
    font-weight: bold;
}

.progress-ts {
    position: absolute;
    bottom: 0;
    height: 10px;
    left: 0;
    width: 100%;
}

.table-tst {
    & {
        table-layout: fixed;
    }

    & > thead > tr > td {
        width: 25%;
    }
}

.tst-container {
    position: relative;

    height: 120px;
}

.tst-container-start {
    @extend .empty-content;
    top: 5%;
    left: 0;
    height: 90%;
    width: 0.25rem;

    border-left-width: 1.5px;
    border-left-style: solid;
    border-left-color: #d7d7d7;
}

.tst-container-end {
    @extend .empty-content;
    position: relative !important;
    top: 5%;
    left: 0;
    height: 90%;
    width: 0.25rem;

    border-right-width: 1.5px;
    border-right-style: solid;
    border-right-color: #d7d7d7;
}

.tst-element {
    &::after {
        @extend .empty-content;
        top: 50%;
        left: 0;
        height: 1px;
        width: 100%;
    }

    &:not(:first-of-type)::before {
        @extend .empty-content;
        top: 30%;
        left: 0;
        height: 40%;
        width: 0.1rem;
    }
}

.tst-element-top {
    position: absolute;
    left: 5%;
    top: 2%;
    width: 90%;
}

.tst-element-middle {
    z-index: 1;

    position: absolute;
    left: 10%;
    top: 46.5%;
    height: 10px;
    width: 80%;
}

.tst-element-bottom {
    position: absolute;
    left: 5%;
    bottom: 9%;
    width: 90%;
}

.empty-content {
    content: "";
    position: absolute;
    background-color: #adadad;
}

.text-hidden {
    color: transparent;
}

.active-filter {
    background-color: $primary;
}

dialog {
    border: 1px solid var(--lt-color-gray-400);
}

@mixin horizontal-bar($colour) {
    background-color: $colour;
    content: "";
    height: 1px;
    left: 0;
    position: absolute;
    width: 100%;
}

.tabs {
    border-bottom: 1px solid var(--primary-grey);
    display: flex;
    font-size: var(--regular-size);
    width: 100%;
}

.tab {
    background: none;
    border: none;
    color: var(--primary-dark);
    cursor: pointer;
    display: block;
    padding-top: 1.8rem;
    padding-bottom: 1.2rem;
    position: relative;
    text-align: center;
    text-decoration: none;
    width: 12.5rem;

    &::after {
        @include horizontal-bar(var(--primary-blue));
        bottom: -2px;
        height: 3px;
        transform: scaleX(0);
        z-index: 1;
    }
    &.active::after,
    &:hover::after {
        transform: scaleX(1);
    }
    & + .tab {
        margin-left: 0.5rem;
    }
}

.hidden {
    display: none !important;
}

.table {
    border-collapse: collapse;
    font-size: var(--table-size);
    position: relative;
    text-align: left;
    width: 100%;

    --header-height: 1.4rem;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 25%);

    & > thead {
        background-color: #eaeaea;
        th,
        td {
            border-bottom: 3px solid var(--primary-dark);
            border-top: 1px solid var(--primary-grey);
            padding: var(--header-height) 0.5rem var(--header-height) 0;
        }
        th:first-child,
        td:first-child {
            padding: var(--header-height) 0.5rem var(--header-height) var(--header-height);
        }
        th:last-child,
        td:last-child {
            padding: var(--header-height) var(--header-height) var(--header-height) 0;
        }
    }

    tbody {
        tr {
            border-top: 1.5px solid var(--primary-grey);
            border-radius: 2px;
            gap: 6px;

            td {
                vertical-align: initial;
            }
        }
    }

    &_actions {
        display: flex;
        justify-content: flex-end;
        > * + * {
            margin-left: 2rem;
        }
        > .icon-button + .icon-button {
            margin-left: 0.5rem;
        }
    }

    &_cell-with-buttons {
        display: flex;
        > span {
            align-items: center;
            display: flex;
        }
        > * + * {
            gap: 0.5rem;
        }
    }

    td {
        padding-right: 0.5rem;
    }
    td:first-child {
        padding: 1rem 0.5rem 1rem var(--header-height);
    }
    td:last-child {
        padding: 1rem var(--header-height) 1rem 0;
    }
}
.subtitle + .table {
    margin-top: 1rem;
}

.controls {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.3rem 0 0.3rem 0;

    &_buttons {
        margin-left: auto;
    }
}

.help-tip {
    position: absolute;
    display: inline-block;
    text-align: center;
    background-color: var(--primary-blue);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    line-height: 26px;
    cursor: default;
    transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
    margin-top: 0.4rem;
    margin-left: 0.4rem;
    outline: none;
    &:hover,
    &:focus-visible {
        cursor: pointer;
        background-color: #ccc;
        p {
            cursor: default;
            visibility: visible;
            opacity: 1;
            transform: scale(1);
        }
    }
    .help-icon {
        font-weight: 700;
        color: #fff;
    }
    p {
        visibility: hidden;
        opacity: 0;
        text-align: left;
        background-color: var(--primary-blue);
        padding: 20px;
        width: 300px;
        position: absolute;
        border-radius: 4px;
        right: -4px;
        color: #fff;
        font-size: 13px;
        line-height: normal;
        transform: scale(0.7);
        transform-origin: 100% 0%;
        transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
        z-index: 100;
        &:before {
            position: absolute;
            content: "";
            width: 0;
            height: 0;
            border: 6px solid transparent;
            border-bottom-color: var(--primary-blue);
            right: 10px;
            top: -12px;
        }
        &::after {
            width: 100%;
            height: 40px;
            content: "";
            position: absolute;
            top: -5px;
            left: 0;
        }
    }
    a {
        color: #fff;
        font-weight: 700;
        &:hover,
        &:focus-visible {
            color: #fff;
            text-decoration: underline;
        }
        &:focus,
        &:focus-visible {
            color: #fff;
            text-decoration: underline;
        }
    }
}

/**
 * Fix the button appearance in Safari
 */
button,
[type="button"],
[type="reset"],
[type="submit"] {
    -webkit-appearance: none;
}
