:root {
    --accent-primary: hsl(241, 61%, 68%);
    --accent-secondary: hsla(241, 61%, 68%, 0.1);
    --box-border-radius: 1.4rem;
    --box-border-width: 0.0625rem;
    --red-primary: hsl(0, 100%, 65%);
    --red-secondary: hsla(0, 100%, 65%, 0.1);
    --green-primary: hsl(151, 44%, 50%);
    --green-secondary: hsla(151, 44%, 50%, 0.1);
}

@media (prefers-color-scheme: light) {
    :root {
        --background-color: hsl(0, 0%, 100%);
        --text-color: hsl(0, 0%, 22%);
        --secondary: hsl(0, 0%, 12%);
        --box-border-color: hsl(0, 0%, 88%);
        --box-shadow: hsla(0, 0%, 24%, 0.12);

        --table-border: hsla(0, 0%, 0%, 0.2);
        --table-header: hsla(0, 0%, 0%, 0.1);
        --table-contrast: hsla(0, 0%, 0%, 0.05);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: hsl(216, 28%, 7%);
        --text-color: hsl(0, 0%, 92%);
        --secondary: hsl(0, 0%, 82%);
        --box-border-color: hsl(0, 0%, 18%);
        --box-shadow: hsla(0, 0%, 0%, 0.25);

        --table-border: hsla(0, 0%, 100%, 0.2);
        --table-header: hsla(0, 0%, 100%, 0.1);
        --table-contrast: hsla(0, 0%, 100%, 0.05);
    }
}

/* Headings */
h1 {
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.4;
}

h2 {
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.2;
}

h3 {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.1;
}

/* Input and buttons */
input {
    padding: 0.35rem;
}

a {
    color: var(--accent-primary);
}

.button,
button,
input[type=submit] {
    color: var(--accent-primary);
    background: var(--accent-secondary);
    border-radius: var(--box-border-radius);
    padding: 0.4rem 1rem;
    display: inline-block;
    text-decoration: none;
    border: 0;
    cursor: pointer;

    &:hover {
        color: var(--background-color);
        background: var(--accent-primary);
    }

    &:disabled {
        box-shadow: inset 0 0 0 var(--box-border-width) var(--box-border-color);
        color: var(--box-border-color);
        background: transparent;
        cursor: default;
    }

    &.delete-button {
        color: var(--red-primary);
        background: var(--red-secondary);

        &:hover {
            color: var(--background-color);
            background: var(--red-primary);
        }
    }
}

.add-item,
.delete-item {
    border-radius: var(--box-border-radius);
    text-decoration: none;
    display: inline-block;
    width: 100%;
    padding: 1.75rem;
}

.add-item {
    border: var(--box-border-width) solid var(--accent-primary);
    color: var(--accent-primary);

    &:hover {
        background-color: var(--accent-secondary);
    }
}

.delete-item {
    border: var(--box-border-width) solid var(--red-primary);
    color: var(--red-primary);

    &:hover {
        background-color: var(--red-secondary);
    }
}

/* Structure */
body {
    margin: 0;
    font-family: system-ui;
    color: var(--text-color);
    background: var(--background-color);
}

#body {
    width: min(2000px, 100% - 4rem);
    height: 100vh;
    margin-inline: auto;
}

/* Header */
header {
    height: 10%;
    display: flex;
    align-items: center;
}

#header {
    height: 3.5rem;
    width: 100%;
    border: var(--box-border-width) solid var(--box-border-color);
    border-radius: 50vw;
    box-shadow: 0 0 1.25rem var(--box-shadow);
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#header-1 {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 0 0 auto;
}

.app-name {
    font-size: 1.4rem;
    margin-left: 1.5rem;

    & a {
        color: inherit;
        text-decoration: none;
    }
}

/* Main */
main {
    height: 90%;
    padding: 1.5rem 0 2rem;
}

#main {
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1.6rem;
}

.hide-main-left #main-left {
    display: none;
}

#main-left {
    min-width: 15%;
    max-width: 30%;
}

#main-right {
    width: 100%;
}

#main-left-1 {
    height: 100%;
    overflow: hidden;
}

#main-right-1 {
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

#main-left-1,
#main-right-1,
.mb-2 {
    box-shadow: 0 -0.125rem 1.25rem var(--box-shadow);
    border: var(--box-border-width) solid var(--box-border-color);
    border-radius: var(--box-border-radius);
}

#main-left-2 {
    height: 100%;
}

#main-right-2 {
    height: 100%;
}

#main-right-3 {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    top: 0%;
    bottom: 0%;
    left: 0%;
    right: 0%;
    overflow: auto;
}

#main-right-4 {
    align-self: stretch;
}

/* Content */
#content {
    padding: 2rem 0;
}

#content-title {
    padding: 0 2rem;
}

#content-title,
.content-1-title {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;

    & h1,
    h2,
    h3 {
        word-break: break-all;
    }
}

#content-title-right,
.content-1-title-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-1 {
    padding: 0 2rem;
}

.content-1-footer {
    margin-top: 2rem;
}

#content-footer {
    padding: 0 2rem;
    margin-top: 4rem;
}

#content-footer,
.content-1-footer {
    display: flex;
    gap: 1rem;
    justify-content: end;
    align-items: center;
}

/* Menu */
#menu {
    height: 100%;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    position: relative;
}

.menu-item-1 {
    padding: 1.25rem 1.4rem;
    max-width: 100%;
    display: inline-block;
}

.menu-item-link {
    position: absolute;
    top: 0%;
    bottom: 0%;
    left: 0%;
    right: 0%;
    border-radius: var(--box-border-radius);

    &:hover {
        background-color: var(--accent-secondary);
    }
}

.selected-menu-item .menu-item-link {
    background-color: var(--accent-secondary);
    border: var(--box-border-width) solid var(--accent-primary);
    color: var(--accent-primary);
}

.external-menu-item .menu-item-title::after {
    content: ' [↗]';
    color: var(--accent-primary);
}

.add-menu-item {
    & .menu-item-title {
        color: var(--accent-primary);
        font-weight: normal;
    }

    & .menu-item-link {
        border: var(--box-border-width) solid var(--accent-primary);
    }
}

.menu-item-button {
    position: relative;
    z-index: 1;
    font-size: 0.6rem;
}

.menu-item-title {
    color: var(--secondary);
    font-weight: 600;
    /* word-break: break-all; */
}

.menu-item-subtitle {
    font-size: 0.7rem;
}

/* Navigation */
nav {
    height: 100%;
    display: flex;
    flex-flow: row nowrap;
    gap: 1rem;
    align-items: center;
    overflow-x: auto;
    padding: 0.5rem;
}

.nav-item {
    flex: 0 0 auto;
    overflow: hidden;

    & a {
        font-size: 0.9rem;
        display: inline-block;
        height: 100%;
        color: var(--secondary);
        padding: 0.4rem 1rem;
        font-weight: 500;
        line-height: 1.4;
        text-decoration: none;

        &:hover {
            border-radius: var(--box-border-radius);
            background-color: var(--accent-secondary);
        }
    }
}

/* Message */
.mb {
    width: min(35rem, 100% - 1rem);
    margin: 0 auto;
    top: 0;
    left: 0;
    right: 0;
    position: fixed;
}

.mb-1 {
    padding-top: 2rem;
}

.mb-2 {
    background-color: var(--background-color);
    border: var(--box-border-width) solid var(--green-primary);
    padding: 1rem;
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.mb-text {
    width: 100%;
}

.close-mb {
    height: 1.5rem;
    aspect-ratio: 1 / 1;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.375rem;
    cursor: pointer;
    opacity: 0.5;

    &:hover {
        opacity: 1;
    }
}

.error-message .mb-2 {
    border-color: var(--red-primary);
}

/* Custom */
.add-repoitem {
    margin-bottom: 2rem;
}

.edit-repoitem textarea {
    height: 30vh;
}

.edit-repoitemfile textarea {
    height: 10vh;
}

.repoitem:not(:last-child) {
    border-bottom: var(--box-border-width) solid var(--accent-secondary);
    padding-bottom: 1rem;
    margin-bottom: 8rem;
}

.repoitem-editdate {
    font-size: 12px;
}

.repoitemfile-position {
    width: 12ch;
}

.repoitemfile-title {
    flex: max-content;
}

/* Slideshow */
.slideshow {
    margin-top: 2rem;
    font-size: 16px;
}

.slideshow-navigation {
    display: flex;
    justify-content: space-between;
    align-items: end;
}

.slideshow-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    word-break: break-all;
}

.slideshow-content {
    margin: 0.25rem 0;
    border: var(--box-border-width) solid var(--accent-secondary);
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;

    & object[type="application/pdf"] {
        width: 100%;
        height: 50vh;
    }
}

.slideshow-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.edit-slideshow {
    padding-top: 1rem;
    display: flex;
    justify-content: center;
}

/* List */
.list {
    margin: 1rem 0;
    font-size: 16px;
}

.list-title {
    padding: 1.25rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.list-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: stretch;
}

.list-item {
    padding: 0.25rem;
    border: var(--box-border-width) solid var(--accent-secondary);
    display: flex;
    flex-flow: row wrap;
    gap: 0.25rem;
    align-items: center;
}

/* Datagrid */
.datagrid {
    font-size: 14px;

    & table {
        border-collapse: collapse;
    }

    & th,
    td {
        padding: 1rem;
        text-align: left;
        max-width: 20rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    & th {
        background: var(--table-header);
    }

    & tr:nth-of-type(2n) {
        background: var(--table-contrast);
    }
}

.datagrid-controls {
    display: flex;
    gap: 2rem;
    padding: 1rem 2rem;
}

/* Data */
.data {
    font-size: 16px;

    &>div {
        margin: 1.5rem 0;

        &>label {
            display: block;
            padding-bottom: 0.25rem;
        }

        &>input,
        &>textarea {
            display: block;
        }

        &>textarea,
        &>input[type=text],
        &>input[type=password] {
            width: 100%;
        }

        &>textarea {
            font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
        }
    }
}

/* Custom markdown */
@media (max-width: 700px) {

    .markdown-body,
    .slideshow,
    .list {
        font-size: 1rem;
    }

}

/* Responsive */
@media (max-width: 1100px) {

    /* This is for tablet computer */
    #body {
        width: min(1100px, 100% - 2rem);
    }
}

@media (max-width: 800px) {

    /* This is for phone device */
    #body {
        width: min(800px, 100% - 0.25rem);
    }

    nav {
        gap: 0.25rem;
    }

    main {
        padding: 0.25rem 0;
    }

    #main {
        flex-direction: column-reverse;
        gap: 0.25rem;
    }

    #main-left {
        min-width: 100%;
        max-width: 100%;
        height: 10%;
    }

    #main-right {
        height: 90%;
    }

    .hide-main-left #main-right {
        height: 100%;
    }

    #menu {
        flex-flow: row nowrap;
        overflow-x: auto;
        padding: 0.3rem;
    }

    .menu-item {
        flex: 0 0 auto;
        overflow: hidden;
    }

    .menu-item-1 {
        padding: 0 1rem;
        height: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0.7rem;
    }

    #content {
        padding: 1rem 0;
    }

    #content-title {
        padding: 0 1rem;
    }

    .content-1 {
        padding: 0 1rem;
    }

    #content-footer {
        padding: 0 1rem;
    }
}

/* Adapt font-size to vw */
html {
    font-size: calc(0.6875000000000001rem + 0.6249999999999999vw);
}

@media (max-width: 1920px) {
    html {
        font-size: calc(0.6874999999999999rem + 0.6250000000000001vw);
    }
}

@media (max-width: 1440px) {
    html {
        font-size: calc(0.9690426638917794rem + 0.3121748178980229vw);
    }
}

@media (max-width: 479px) {
    html {
        font-size: calc(0.8746077405857741rem + 0.6276150627615062vw);
    }
}