:root {
    --sidebar-width-open: 320px;
    --sidebar-width-closed: 115px;
    --app-header-size: 5rem;
    --main-header-size: 4.5rem;
}

* {
    font-family: Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/*css framework placeholder*/
.scroll {
    overflow: auto;
}

.notification {
    border-width: 1px;
    border-style: solid;
    border-radius: 2px;
}

html {
    width: 100%;
    height: 100%;
}

form {
    display: grid;
}

/* Screen-reader only: visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    display: grid;
    grid-template-rows: 4rem 1fr;
    grid-template-columns: 100%;
    width: 100%;
    height: 100%;

    grid-template-areas:
    "header"
    "main";

    margin: 0;
    padding: 0;

    gap: var(--spacing-lg);

    place-items: stretch;
    place-content: stretch;

    .disabled {
        opacity: 1;
        filter: contrast(0.25) brightness(1.5) grayscale(1);
        cursor: auto;
    }

    > header {
        grid-area: header;
        display: grid;
        place-content: stretch;

        grid-template-columns: 1fr 1fr;
        grid-template-areas: "search menu";
        gap: var(--spacing-lg);

        padding: var(--spacing-lg) max(var(--spacing-xl), 2%) 0;

        @media (min-width: 850px) {
            .search {
                grid-area: search;
                display: flex;
                justify-content: center;

                align-items: start;
                margin-top: 0.4rem;
                /* we do this+margin-top instead of center because the height of the header changes when
                                                  the dropdown menu to the right is opened */
            }
        }

        @media (max-width: 849.9px) {
            .search {
                grid-area: search;
                display: flex;
                justify-content: center;

                align-items: start;
                margin-top: 0.4rem;
                /* we do this+margin-top instead of center because the height of the header changes when
                                                  the dropdown menu to the right is opened */
            }
        }

        > .menu {
            z-index: 100;
            grid-area: menu;
            justify-self: stretch;
            text-align: right;
            display: flex;
            justify-content: right;

            .ui-overlaypanel-content {
                display: flex;
                flex-direction: column;
                gap: var(--spacing-sm);

                .ui-button {
                    position: relative;
                    z-index: 1;

                    &:hover {
                        z-index: 0;
                    }
                }
            }
        }

    }

    > .rsp-layout {
        > main {
            grid-area: main;
            padding: 0 max(var(--spacing-xl), 2%);
            display: grid;
            grid-template-rows: auto 1fr;
            min-height: fit-content;
            min-width: fit-content;
            gap: var(--spacing-lg);

            header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-wrap: nowrap;

                gap: var(--spacing-md);

                > form {
                    display: flex;
                    align-items: center;
                    gap: var(--spacing-md);
                }

                > .header-group {
                    &:not(.title) {
                        display: grid;
                        align-items: center;
                        justify-items: start;
                    }

                    p {
                        font-size: 1.5rem;
                    }

                    * {
                        line-height: 1;
                        margin: 0;
                    }

                    &.title {
                        display: inline-grid;
                        grid-template-columns: auto auto;
                        gap: var(--spacing-md);
                        align-items: start;
                        max-width: fit-content;
                    }

                    &.actions {
                        display: flex;
                        align-items: center;
                        gap: var(--spacing-md);
                    }
                }
            }
        }
    }

    > aside {
        grid-area: aside;
    }
}

.button-wrapper {
    padding: 3px;
    border-radius: 15px;
}

.button-wrapper-clicked {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    background: conic-gradient(from 90deg, rgb(154, 220, 255), rgb(174, 159, 215), rgb(197, 89, 167), rgb(213, 27, 74), rgb(244, 208, 111), rgb(154, 220, 255));
}

.button-wrapper:hover,
.button-wrapper:focus-within {
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    background: conic-gradient(from 90deg, rgb(154, 220, 255), rgb(174, 159, 215), rgb(197, 89, 167), rgb(213, 27, 74), rgb(244, 208, 111), rgb(154, 220, 255));
    transition: 0.2s;
}

.logo-div {
    position: relative;
    display: grid;
    text-align: center;
    min-height: 80px;

    .logo_container {

        img {
            width: 100%;
            height: 100%;
            object-fit: contain;
        }

        img.logo-full {
            max-width: 220px;
        }

        img.logo-collapsed {
            max-width: 40px;
        }
    }
}

#main-menu {
    display: grid;
}

/* -- Lucene dialog: responsive sizing -------------------------------------- */
#lucenedialog {
    position: fixed !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}

/* Mobile: fullscreen */
@media (max-width: 767px) {
    #lucenedialog {
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 991px) {
    #lucenedialog {
        top: 2% !important;
        left: 2% !important;
        width: 96% !important;
        height: 96% !important;
    }
}

/* Desktop */
@media (min-width: 992px) {
    #lucenedialog {
        top: 5% !important;
        left: 5% !important;
        width: 90% !important;
        height: 90% !important;
    }
}

#lucenedialog .ui-dialog-content {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
}

.lucene-dialog-inner {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

#luceneform {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

#luceneform input {
    border: none;
}

#luceneform #resultpanel,
#luceneform [id$="resultpanel"] {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

#luceneform a {
    color: var(--fontColor);
}

.blur-effect {
    filter: blur(3px);
    transition: filter 0.3s ease;
    cursor: wait;
}

#luceneform .nowrap {
    white-space: nowrap;
}

/* -- Lucene search row ---------------------------------------------------- */
.lucene-search-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    box-sizing: border-box;
    max-width: 100%;
}

#luceneform .lucene-input-wrapper {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

#luceneform .lucene-input-wrapper .ui-inputfield {
    width: 100% !important;
}

#luceneform .lucene-input-wrapper::before {
    content: "";
    position: absolute;
    left: 0.7em;
    top: 50%;
    transform: translateY(-50%);
    font-family: "PrimeIcons";
    font-size: 1.2em;
    color: var(--fontColor);
    pointer-events: none;
    content: "\e908"; /* Unicode für pi-search */
}

#luceneform .lucene-input-wrapper .ui-inputfield {
    padding-left: 2.7em !important;
    border-radius: 12px;
    border-width: 1px;
}

#luceneform .lucene-input-wrapper .ui-inputfield:hover {
    outline: none;
    border-color: transparent;
    box-shadow: none;
}

#luceneform .lucene-input-wrapper .ui-inputfield:focus {
    outline: 2px solid var(--accentColor) !important;
    outline-offset: -3px;
    border-color: transparent;
    box-shadow: none;
}

#luceneform .lucene-clear {
    position: absolute;
    right: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    font-size: 2.0rem;
    line-height: 1;
    cursor: pointer;
    color: var(--accentColor);
    padding: 0;
}

#luceneform .lucene-input-wrapper .lucene-clear:hover {
    color: var(--accentColor);
}

#luceneform .lucene-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    text-decoration: none;
    color: var(--accentColor);
    transition: color 0.2s ease;
}

#luceneform .ui-selectonemenu {
    border: none;
}

#luceneform .lucene-help:hover {
    color: var(--accentColor);
}

#luceneform\:results tr {
    transition: background-color 0.2s ease-in-out;
}

#luceneform\:results tr:hover {
    background-color: color-mix(in srgb, var(--backgroundColor) 40%, transparent);
}

body .ui-datatable thead th.ui-state-active,
body .ui-datatable thead th.ui-state-hover:hover {
    color: var(--fontColor);
}

.debugonly {
    color: color-mix(in srgb, var(--fontColor) 30%, transparent);
}

.pi-power-off {
    color: red;
    font-weight: 600;
}


#sidebar {
    display: grid;
    height: 100%;
    position: fixed;
    background-color: var(--panelBackgroundColor);
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    gap: var(--spacing-md);

    grid-template-rows: auto 1fr;

    transition: var(--duration-xs);

    #sidebar-scroll-wrapper {
        display: grid;
        grid-template-rows: auto 1fr;
        min-height: fit-content;
        gap: var(--spacing-lg);

        .menuForm {
            border-radius: var(--border-radius-xl);

            display: flex;
            flex-direction: column;

            overflow-y: auto;

            padding: var(--spacing-sm);
            gap: var(--spacing-sm);
            background-color: var(--surface-ground);

            .ui-linkbutton a {
                display: block;
                width: 100%;
                height: 100%;
            }

            .navlist-section-heading {
                padding: var(--spacing-md);
            }

            .lvl {
                display: grid;
                grid-template-rows: auto;
                grid-template-columns: 100%;

                place-content: start stretch;
                place-items: start stretch;

                gap: 5px;

                padding: 0 0 15px 1.5rem;

                .ui-button {
                    border-radius: 10px;

                    &.ui-button-text-icon-left .ui-button-text {
                        padding: 0.25rem 0.5rem 0.25rem 2rem;
                    }
                }
            }

            #menu-toggle {
                position: absolute;
                top: calc(1.5rem + 1.75rem - 18px);
                right: -16px;
                border-radius: 50%;
                border: none;
                background-color: var(--surface-ground);
                padding: 6px;
                color: red;

                &:hover, &:focus {
                    outline: 2px solid rgba(1, 1, 1, 0.9);
                }

                i {
                    font-size: 0.75rem;
                    text-align: center;
                    border: 2px solid #999999;
                    border-radius: 50%;
                    height: 25px;
                    width: 25px;
                    display: inline-block;

                    &:before {
                        display: inline-flex;
                        color: #999999;
                        justify-content: center;
                        margin-top: .285rem;
                    }

                    @media screen and (min-width: 1200px) {
                        &.pi-chevron-right {
                            display: none;
                        }
                    }
                    @media screen and (max-width: 1199px) {
                        &.pi-chevron-left {
                            display: none;
                        }
                    }
                }
            }
        }
    }
}

#dashboard_form a.ui-datepicker-prev {
    color: var(--accentColor);
    text-decoration: none;
}

#dashboard_form a.ui-datepicker-next {
    color: var(--accentColor);
    text-decoration: none;
}

#dashboard_form .ui-datepicker-inline {
    border: none;
    border-radius: var(--border-radius-xl);
}

#dashboard_form .ui-datepicker-header {
    border: none;
}

body .ui-button {
    text-align: left;

    a {
        text-decoration: none;
    }
}

#blurBackground {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(0px);
    transition: backdrop-filter var(--duration-xl-fast) ease;
    display: none;
    z-index: 1;
}

/* TODO(Konrad) @kkoch: Ich weiß nicht genau ob das in irgendeiner Form auch in das Theme
    soll. aber das wäre ein typischer sass fall, dass man hier ne loop für die line couns generiert.
    1-5 wäre vermutlich genug. */
.clamp-lines-2 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    clip-path: content-box;
}

body.lw {
    .curr-nav-wrapper {
        .ui-widget-header hr {
            margin-bottom: 0;
            margin-left: var(--spacing-lg);
        }

        .proto-navpanel-heading {
            font-size: 1em;
            display: flex;
            align-items: center;
            gap: var(--spacing-md);
            padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) var(--spacing-lg);
        }

        .ui-widget-content {
            padding: 0;
        }
    }

    .profile-pic-wrapper {
        width: 3.75rem;
        height: 3.75rem;
        border-radius: 100%;
        display: grid;
        overflow: hidden;

        &.rainbow-border {
            padding: 1px;
        }

        .profile-pic {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: top center;
            border-radius: 100%;
        }
    }
}


.pagination-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    box-sizing: border-box;
    max-width: 100%;
}

.pagination-left,
.pagination-right {
    margin-bottom: 1rem;
    min-width: 0;
}

.pagination-left {
    flex: 0 0 70%;
    display: flex;
    flex-wrap: wrap;
    justify-content: left;
    min-width: 0;
    overflow: hidden;
    gap: 0.5rem;
}

.pagination-right {
    flex: 1; /* nimmt restlichen Platz */
    display: flex;
    justify-content: right;
}

.ui-outputlabel-label {
    font-weight: unset !important;
}

/* Responsive: pagination stacking */
@media (max-width: 767px) {
    .pagination-left, .pagination-right {
        flex: 0 0 100%;
    }

    .pagination-left .ui-button {
        margin-right: 0.5rem !important;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .pagination-left {
        flex: 0 0 60%;
    }
}

/* -- Lucene DataTable: constrain to dialog width ------------------------- */
#luceneform .ui-datatable {
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--border-radius-xl);
}

#luceneform .ui-datatable-tablewrapper {
    max-width: 100%;
    overflow-x: auto;
}

#luceneform .ui-datatable-scrollable-body {
    overflow-x: hidden !important;
}

#luceneform .lucene-col-area .lucene-area-label--material {
    display: inline-block;
    max-width: calc(100% - 1.5rem);
    white-space: normal;
    overflow-wrap: anywhere;
    vertical-align: middle;
}

/* -- Lucene DataTable: hide columns on small viewports ------------------- */
@media (max-width: 767px) {
    #luceneform .lucene-col-position,
    #luceneform .lucene-col-score,
    #luceneform .lucene-col-date,
    #luceneform .lucene-col-size {
        display: none !important;
    }

    #luceneform .lucene-col-area {
        width: 1.5rem !important;
        text-align: center;
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    #luceneform .lucene-col-area .lucene-area-label {
        display: none;
    }

    #luceneform .lucene-col-area .pi {
        margin-right: 0 !important;
    }

    #luceneform .lucene-col-area .column-header-actions span {
        display: none;
    }

    #luceneform .lucene-col-area .column-header-actions .sort-buttons {
        display: none;
    }

    #luceneform .ui-datatable colgroup col {
        width: auto !important;
    }

    #luceneform .ui-datatable-scrollable-header-box > table,
    #luceneform .ui-datatable-scrollable-body > table {
        table-layout: auto !important;
        width: 100% !important;
    }

    #luceneform .ui-datatable-scrollable-header-box {
        overflow: hidden !important;
    }

    #luceneform .ui-datatable-scrollable-body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    #luceneform .ui-datatable th,
    #luceneform .ui-datatable td {
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    #luceneform .ui-datatable th.lucene-col-area,
    #luceneform .ui-datatable td.lucene-col-area {
        white-space: nowrap !important;
        word-break: normal;
    }

    #luceneform .ui-datatable-scrollable-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    #luceneform .column-header-actions {
        gap: 0.25rem !important;
    }

    #luceneform .column-header-actions .sort-buttons .ui-button {
        padding: 0.2rem !important;
        min-width: unset !important;
        width: 1.8rem;
        height: 1.8rem;
        cursor: pointer;
    }

    #luceneform .search-link {
        cursor: pointer;
    }

    #luceneform .ui-button {
        cursor: pointer;
    }

    #luceneform .lucene-time-nowrap {
        white-space: nowrap;
    }

    #luceneform .lucene-date-time {
        display: flex !important;
        flex-direction: column !important;
        gap: 0;
    }

    #luceneform .lucene-date {
        display: block !important;
    }

    #luceneform .lucene-col-date,
    #luceneform .ui-datatable td.lucene-col-date {
        white-space: normal !important;
        width: 100px !important;
        max-width: 100px !important;
    }

    #luceneform .search-thumb-container .search-thumb-preview {
        max-width: 60px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    #luceneform .lucene-col-score,
    #luceneform .lucene-col-size {
        display: none !important;
    }

    #luceneform .lucene-col-position {
        width: 40px !important;
    }

    #luceneform .lucene-col-area {
        width: 90px !important;
    }

    #luceneform .lucene-col-date {
        width: 130px !important;
    }

    #luceneform .ui-datatable th,
    #luceneform .ui-datatable td {
        white-space: normal !important;
        word-break: break-word;
    }

    #luceneform .ui-datatable th.lucene-col-area,
    #luceneform .ui-datatable td.lucene-col-area {
        white-space: nowrap !important;
        word-break: normal;
    }

    #luceneform .column-header-actions .sort-buttons .ui-button {
        padding: 0.25rem !important;
        min-width: unset !important;
        width: 2rem;
        height: 2rem;
    }
}

/* -- Lucene dialog inner wrapper ----------------------------------------- */
.lucene-dialog-inner {
    padding: 1rem 0.75rem;
    background: var(--backgroundColor);
    border: 0 !important;
    border-radius: 15px !important;
    text-align: left !important;
    text-decoration: none;
}

/* -- Lucene status/error messages ---------------------------------------- */
.index-status-message,
.search-error-message {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
}

.index-status-message {
    background-color: var(--info-background-color);
    border: 1px solid var(--info-border-color);
    color: var(--info-foreground-color);
}

.search-error-message {
    background-color: var(--error-background-color);
    border: 1px solid var(--error-border-color);
    color: var(--error-foreground-color);
}

.index-status-message .pi,
.search-error-message .pi {
    margin-right: 0.5rem;
}

/* Facet chips inside lucene dialog */
.lucene-facets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
    max-width: 100%;
}

/* -- Lucene facets toggle (mobile only) ---------------------------------- */
.lucene-facets-toggle {
    display: none;
    width: 100%;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: #eef0f4;
    border: 1px solid var(--rsp-color-border, #dee2e6);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: left;
}

.lucene-facets-toggle .pi {
    float: right;
    transition: transform 0.2s;
}

.lucene-facets-toggle[aria-expanded="true"] .pi {
    transform: rotate(180deg);
}

@media (max-width: 767px) {
    .lucene-facets-toggle {
        display: block;
    }

    .lucene-facets {
        display: none;
    }

    .lucene-facets.lucene-facets--open {
        display: flex;
    }
}

.ui-datatable-scrollable-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

.lw.no-scroll,
html.no-scroll {
    overflow: hidden;
}

#luceneform .search-link {
    text-decoration: underline;
    color: var(--fontColor);
}

/* Thumbnail hover preview in search results */
.search-thumb-container {
    display: inline;
}

.search-thumb-container .search-thumb-preview {
    display: none;
}

.search-thumb-floating {
    position: absolute;
    z-index: 999999;
    pointer-events: none;
    object-fit: contain;
    border: none;
    background: var(--backgroundColor);
    width: auto;
}

.attached-file-image {
    height: 10rem;
    width: 100%;
    object-fit: contain;
}

.attached-file-panel {
    width: 12rem;

    .ui-panel-content {
        max-height: 15rem;
    }

    .ui-panel-titlebar {
        .ui-panel-titlebar-icon {
            color: var(--fontColor);
        }
    }
}

.attached-file-name {
    word-break: break-all;
    max-height: 3rem;
    overflow: hidden;
    margin-top: .5rem;
}

.attached-file-image-wrapper {
    height: 10rem;
}

.attached-file-overlay {
    transition: .5s ease;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -150%);
    -ms-transform: translate(-50%, -150%);
    text-align: center;

    .pi {
        font-size: 5rem;
        /*color: black;*/
    }
}

.attached-file-image-container:hover .file-content {
    opacity: 0.1;
}

.attached-file-image-container .file-content .pi-download {
    opacity: 1;
}

.attached-file-image-container:hover .attached-file-overlay {
    opacity: 1;
}

.attached-file-image-container {
    position: relative;
}

.file-content {
    transition: .5s ease;
    backface-visibility: hidden;
}

.image-size {
    min-width: 15rem;
    min-height: 15rem;
    max-width: 40rem;
    max-height: 40rem;
}

.attached-files-wrapper {
    .ui-panel-content {
        border-radius: 15px;
    }
}

.ui-card.folder-dialog-card {
    background: var(--backgroundColor);
}

.control-field {
    display: flex;

    &.top, &.bottom {
        align-items: start;
        gap: var(--spacing-sm);
    }

    &.left, &.right {
        align-items: center;
        gap: var(--spacing-md);
    }

    &.top {
        flex-direction: column;
    }

    &.right {
        flex-direction: row-reverse;
    }

    &.bottom {
        flex-direction: column-reverse;
    }
}
