:root {
    --color-main: #FF6100;
    --color-main-dark: #EE5100;
    --color-hover-light: #FFDD99;
}

* { 
    padding: 0;
    margin: 0;
    font-family: Calibri;
    box-sizing: border-box;
}

/*** ANIMATION KEYFRAMES ***/

@keyframes spin {
    from {
        transform: rotate(0deg);
    } to {
        transform: rotate(360deg);
    }            
}

/*** BASIC TYPES ***/

body {
    min-height: 100%;
    display: grid;
    grid-template-rows: 2em auto 2em;
    grid-template-columns: 250px auto;
}

a {
    color: inherit;
    text-decoration: none;
}
    a:hover {
        text-decoration: underline;
    }

input, textarea {
    font-size: 100%;
    padding:2px;
    resize: vertical;
}

span.spacer {
    display: inline-block;
    width: 0.5em;
}

.dragging {
    opacity: 0.5;
}

.edit-form {
    width: 800px;
    max-width: 100%;
    display: grid;
    column-gap: 1em;
    row-gap: 2px;
    margin-bottom: 2em;
}
    .edit-form h1, .edit-form h2, .edit-form h3, .edit-form h4 {
        grid-column-start: 1;
        grid-column-end: 3;
        text-align: center;
    }
    .edit-form label {
        padding: 4px;
    }
    .edit-form .button-row {
        /* grid-column-start: 2; */
        grid-column-start: 1;
        grid-column-end: 3;
        text-align: center;
    }

.meta-tag {
    display: inline-block;
    padding: 0 0.5em 0 0.75em;
    margin: 0px 5px;
    background: #888;
    color: #fff;
    border-radius: 8px;
    clip-path: polygon(0 50%, 8px 0, 100% 0, 100% 100%, 8px 100%);
    white-space: nowrap;
}
    .meta-tag::before {
        padding-right: 3px;
        width: 0.5em;
        display: inline-block;
        content: '#';
    }
    .meta-tag.include {
        background: #8af;
    }
    .meta-tag.require {
        background: #4a4;
    }
        .meta-tag.require::before {
            content: '+';
        }
    .meta-tag.exclude {
        background: #844;
    }
        .meta-tag.exclude::before {
            content: '-';
        }

.collapse-title {
    background: #eee;
    border: 1px solid #ccc;
    padding: 0.5em 1em;
    position: relative;
    cursor: pointer;
}
    .collapse-title::after {
        position: absolute;
        top: 50%;
        right: 1em;
        transform: translateY(-50%);
        content: "\2BC6";
    }
    .collapse-title.collapsed::after {
        content: "\2BC8";
    }
.collapse-target.collapsed {
    display: none !important;
}

input[type=checkbox].visibility {
    /* visibility: hidden; */
    appearance: none;
    position: relative;
}
input[type=checkbox].visibility:before {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    background: url('img/eye.png');
    content: ' ';
    width: 20px;
    height: 20px;
    background-position: 0 100%;
}
input[type=checkbox].visibility:checked:before {
    background-position: 0 0;
}

button {
    position: relative;
    padding: 0.2em 1em;
}
    button:has(.icon) {
        padding-left: 0.5em;
    }
    button .icon {
        display: inline-block;
        width: 15px;
        height: 15px;
        margin-right: 0.5em;
    }
    button.hidden {
        display: none;
    }
    button.save {
        background: #bcb;
    }
    button.cancel {
        background: #cbb;
    }
    button.processing {
        cursor: wait;
        color: #666;
        background: #ccc;
    }
    button.processing:before {
        color: #000;
        position: absolute;
        content: "\2B6E";
        top: 0;
        left: 0.5em;
        font-size: 120%;
        width: 15px;
        height: 100%;
        text-align:center;

        animation-name: spin;
        animation-duration: 1500ms;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
    }
    button.processing .icon {
        opacity: 0.35;
    }

.standard-dialog {
    background: #eee;
    border: 1px solid #000;
    padding: 15px;
    pointer-events: all;
}
    .standard-dialog.login-dialog {
        width: 300px;
    }

    .standard-dialog p.title {
        font-size: 125%;
        text-align: center;
    }
    .standard-dialog .message {
        width: 100%;
    }
    .standard-dialog input {
        width: 100%;
    }
    .standard-dialog .buttons {
        margin-top: 1em;
        text-align: center;
    }

p.message {}
    p.message.warning {
        background: #ff8;
    }
    p.message.error {
        color: #fff;
        background: #f00;
        font-weight: bold;
    }
    p.message.success {
        color: #fff;
        background: #080;
    }

/*** SPECIFICS ***/

#page-header {
    grid-area: 1/1/2/3;
    background: var(--color-main);
    padding: 3px 0.5em;
    display: flex;
    flex-direction: row;
    color: #fff;
    font-weight: bold;
}
    #page-header #breadcrumbs {
        flex: 1 0 0;
    }

#page-main {
    grid-area: 2/1/2/3;
    overflow-x: auto;
    overflow-y: scroll;
    padding: 0.5em 1em;
}
    #page-main.loading {
        pointer-events: none;
    }
    #page-main.loading > * {
        opacity: 50%;
    }

#page-footer {
    grid-area: 3/1/4/3;
    background: var(--color-main);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 3px 0.5em;
    flex-direction: column;
    color: #fff;
}

#header-tray {}
    #header-tray #tray-section-auth button.auth-icon-anon {
        cursor: pointer;
        width: 24px;
        height: 24px;
        border: 0;
        background: url("img/auth-anon.png") no-repeat center center;
    }
    #header-tray #tray-section-auth button.auth-icon-loggedin {
        cursor: pointer;
        width: 24px;
        height: 24px;
        border: 0;
        background: url("img/auth-loggedin.png") no-repeat center center;
    }

#dialogs{
    position: absolute;
    z-index: 99;
    display: relative;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
    #dialogs:has(*) {
        display: flex;
    }

/*** COLLECTION INDEX PAGE ***/

.collection-list-title {
    padding: 15px 10px;
    font-size: 165%;
    font-weight: bold;
    display: flex;
}
    .collection-list-title .collection-name {
        flex: 1 0 0;
    }
    .collection-list-title .button-tray {
        flex: 0 0 auto;
    }

.collection-list {}
    .collection-list a.collection-list-row {
        display: flex;
        flex-direction: row;
        padding: 15px;
        border: 1px solid #eee;
    }
    .collection-list a.collection-list-row:nth-child(even)  {
        background: #eee;
    }
    .collection-list a:hover {
        background: var(--color-hover-light) !important;
    }
    .collection-list .collection-name {
        font-weight: bold;
    }
    .collection-list .collection-owner {
        margin-left: 0.5em;
        color: #999;
    }

/*** COLLECTION PAGE ***/

.collection-info-head {
    display: grid;
    grid-template: auto auto / 1fr auto auto auto;
    border-bottom: 1px dotted #000;
    padding-bottom: 0.5em;
    margin-bottom: 0.5em;
}
    .collection-info-title {
        grid-area: 1 / 1;
        padding-top: 10px;
        font-size: 165%;
        font-weight: bold;
    }
    .collection-info-owner {
        grid-area: 2 / 1;
        padding-left: 15px;
        margin-bottom: 15px;
        font-size: 90%;
    }
    .collection-info-notes {
        grid-area: 3 / 1 / 3 / 3;
        padding: 0.5em 1em;
        margin: 0.5em;
        border-left: 3px solid #ccc;
    }
        .collection-info-notes:empty {
            display: none;
        }
    .collection-info-buttontray {
        grid-area: 1 / 2 / 3 / 2;
        display: flex;
        flex-direction: row;
        align-items: center;
    }
        .collection-info-buttontray button {
            height: auto;
        }
    .collection-info-head .collection-filters {
        grid-area: 4 / 1 / 4 / 3;
    }
    .collection-info-head .search {
        display: flex;
        flex-direction: row;
    }
        .collection-info-head .search-note {
            margin-left: 0.5em;
            font-style: italic;
            color: #999;
        }
        .collection-info-head .search input.search-bar {
            flex: 1 0 0;
        }
    .collection-info-head .tag-title {
        display: flex;
        flex-direction: row;
        align-items: center;
    } 
    .collection-info-head .used-tags {
        padding: 0.5em;
        display: flex;
        flex-direction: row;
        pointer-events: none;
        flex-wrap: wrap;
    }
        .collection-info-head .used-tags:empty {
            display: none;
        }
        .collection-info-head .used-tags > * {
            margin-left: 0.5em0;
        }

    .collection-info-head .collection-tags {
        padding: 0.5em;
        display: flex;
        flex-direction: column;
        align-content: flex-start;
        flex-wrap: wrap;
        white-space: normal;
        max-height: 30vh;
    }
        .collection-info-head .collection-tags ul {
            padding-left: 1em;
            margin-right: 0.5em;
            margin-bottom: 1lh;
            display: flex;
            flex-direction: column;
            flex-wrap: wrap;
            max-height: 30vh;
            list-style: none;
        }
            .collection-info-head .collection-tags ul li {
                width: auto;
            }
            .collection-info-head .collection-tags .category-prefix {
                display: none;
                margin-left: -0.5em;
                margin-bottom: 0.5em;
                font-weight: bold;
                white-space: nowrap;
                border-bottom: 1px solid #000;
            }

    
.entry-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

.entry-list-row {
    background: #000;
    border: 1px solid #000;
    display: flex;
    /* TODO allow changing thumb size in frontend */
    width: 200px;
    height: 200px;
    margin: 3px;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
}
    .entry-list-row:hover {
        border-color: var(--color-hover-light);
        color: var(--color-hover-light);
        text-decoration: none;
    }
    .entry-list-row > * {
        pointer-events: none;
    }
    .entry-list-row img {
        object-fit: contain;
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
    }
    .entry-list-row span.thumb-meta {
        align-self: flex-start;
        z-index: 1;
        background: rgba(0, 0, 0, 0.5);
        border-bottom-right-radius: 4px;
        max-width: 50%;
    }
    .entry-list-row span.thumb-meta > span {
        width: auto;
        padding: 3px;
        padding-right: 6px;
        display: block;
        text-align: left;
        font-size: 75%;
        color: #ccc;
        text-overflow: ellipsis;
        white-space:nowrap;
        overflow: hidden;
    }
    .entry-list-row span.thumb-meta > span.entryId {
        text-align: center;
        font-weight: bold;
        color: #fff;
    }

    .entry-list-row span.name {
        padding: 5px;
        display: block;
        z-index: 1;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        background: linear-gradient(rgba(0,0,0,0), #000);
    }

/*** EDIT COLLECTION PAGE ***/

.edit-collection-page {
    display: flex;
    flex-direction: column;
    align-items: center;
}
    .edit-collection-page .edit-form {
        grid-template-columns: auto 1fr;
    }
    .edit-collection-page input {
        display: block;
    }
    .edit-collection-page .meta-row {
        display: flex;
        flex-direction: row;
    }
    .edit-collection-page .meta-row .drag-handle {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        width: 1.5em;
        border: 1px solid #ccc;
        cursor: grab;
    }
    .edit-collection-page .meta-row input[type=text] {
        flex: 1 0 auto;
    }
    .edit-collection-page .meta-row input[type=checkbox] {
        flex: 0 0 1lh;
    }

    .edit-collection-page .meta-row button {
        flex: 0 0 0;
        width: 100%;
        display: inline-block;
    }
    .edit-collection-page .button-row {
        margin-top: 1.5em;
        grid-column-start: 2;
        text-align: center;
    }


/*** BULK ADD COLLECTION PAGE ***/

.bulk-add-page {
    display: flex;
    flex-direction: column;
    align-items: center;
}
    .bulk-add-page .edit-form {
        grid-template-columns: auto 1fr;
    }
    .bulk-add-page .meta-fields {
        margin-top: 0;
    }
    .bulk-add-page .bulk-header {
        width: 950px;
        margin-top: 1em;
        border-top: 1px solid #000;
        padding-top: 1em;
    }
    .bulk-add-page .bulk-rows {
        margin-top: 0.5em;
        display: flex;
        flex-direction: column;
    }
    .bulk-add-page .bulk-rows > *:nth-child(even) {
        background: #eee;
    }
    .bulk-add-page .bulk-row {
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: start;
        padding: 5px;
    }
    .bulk-add-page .bulk-row.processing {
        opacity: 0.5;
    }
    .bulk-add-page .bulk-row.complete {
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #bfc;
    }
    .bulk-add-page .bulk-row.error {
        background: #fbb;
    }
        .bulk-add-page .bulk-row .img-container {
            text-align: center;
            width: 325px;
        }
        .bulk-add-page .bulk-row.complete .img-container img {
            width: 75px;
        }
        .bulk-add-page .bulk-row img {
            width: 100%;
            height: auto;
            object-fit: contain;
            margin-right: 1em;
        }
        .bulk-add-page .bulk-row .success {
            width: 800px;
            color: #666;
        }
        .bulk-add-page .bulk-row .error-message {
            border: 1px solid #fff;
            font-weight: bold;
            background: #f00;
            color: #fff;
            text-align: center;
            width: 100%;
            position: absolute;
            top: 10px;
            left: 10px;
            width: 315px;
            white-space: pre-wrap;
        }
        /* .bulk-add-page .bulk-row img:hover {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 750px;
            z-index: 99;
        } */

/*** ENTRY PAGE ***/

.entry-page {
    display: grid;
    grid-template: auto auto auto auto auto 1fr / 765px 1fr;
    grid-auto-rows: min-content;
    width: 100%;
    min-height: 100%;
}
    .entry-page.editing button.edit, .entry-page.editing button.remove, .entry-page button.save, .entry-page button.cancel {
        display: none;
    }
    .entry-page button.edit, .entry-page button.remove, .entry-page.editing button.save, .entry-page.editing button.cancel {
        display: inherit;
    }
    .entry-page .meta-value a, .entry-page .entry-info a {
        color: #662;
    }


.entry-head {
    grid-area: 1/2;
    display: flex;
    flex-direction: row;
    align-items: center;
}
    .entry-name {
        flex: 1 0 0;
        grid-area: 1/2;
        font-size: 165%;
    }
        .entry-name input {
            font-size: 100%;
            width: 100%;
        }

.entry-owner {
    grid-area: 2/2;
    border-bottom: 1px dotted #666;
    padding-left: 15px;
    padding-bottom: 0.5em;
}
    .entry-owner .entry-id {
        display: inline-block;
    }
        .entry-owner .entry-id input {
            width: auto;
        }

.entry-metadata {
    grid-area: 3/2;
    margin-top: 0.5em;
    padding-bottom: 0.5em;
    border-bottom: 1px dotted #666;
}
    .entry-tags span.no-tags {
        color: #aaa;
        font-style: italic;
    }
    .entry-tags input {
        width: 100%;
    }

.meta-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    margin-top: 0.5em;
    align-items: center;
}
    .meta-fields > span {
        display: inline-block;
    }
    .meta-fields .meta-key {
        padding-right: 0.5em;
        font-weight: bold;
    }
    .meta-fields input {
        width: 100%;
    }

.entry-info {
    grid-area: 4/2/7/2;
    margin-top: 0.5em;
    white-space: pre-wrap;
}
    .entry-info span:empty::after {
        font-style: italic;
        color: #999;
        content: "no notes";
    }
    .entry-info textarea {
        width: 100%;
        height: 100%;
    }

.entry-image {
    grid-area: 1/1/5/1;
    width: 750px;
    height: 750px;
    border: 1px solid #000;
}
    .entry-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.entry-gallery {
    grid-area: 5/1;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}
    .entry-gallery button.add-image {
        display:none;
    }
    .entry-page.editing .entry-gallery button.add-image {
        display: inline;
        height: 100px;
        width: 100px;
        padding: 0;
        margin-left: 1px;
        margin-right: 5px;
        margin-top: 5px;
        border: 3px dashed #ccc;
        cursor: pointer;
    }
        .entry-page.editing .entry-gallery button.add-image:hover {
            background: #fff;
        }
        .entry-page.editing .entry-gallery button.add-image:active {
            background: #ccc;
        }

.entry-gallery-thumb {
    position: relative;
    background: #000;
    border: 1px solid #000;
    margin-left: 1px;
    margin-right: 5px;
    margin-top: 5px;
}
.entry-gallery-thumb img {
    width: 100px;
    height: 100px;
    object-fit: contain;
}
    .entry-gallery-thumb.unconfirmed-add img {
        border: #0f0 dotted 2px;
    }
    .entry-page .entry-gallery-thumb button.remove {
        display: none;
        position: absolute;
        top: 0;
        right: 0;
    }
    .entry-page.editing .entry-gallery-thumb button.remove {
        display: block;
    }
