:root {
    --link: #1e2693;
    --hover: #1e9293;
    --pane-background: #ececec;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body, html {
    width: 100%;
    height: 100%;
    font-family: Arial, sans-serif;
}
body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: space-between;
}
body.fixed {
    min-width: 640px;
    min-height: 480px;
}

header {
    height: 80px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#logo {
    height: 64px;
    display: inline-block;
    margin: 5px 15px;
}

#user-login {
    margin: 5px 15px;
}

#user-auth {
    margin: 5px 15px;
    display: flex;
}

#user-auth > div {
    align-content: center;
}

#user-auth span {
    font-weight: 600;
    display: block;
}

#user-auth > img {
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    border-radius: 50%;
    border: 2px solid var(--hover);
    margin-right: 0.5em;
}

header button {
    border: 2px solid black;
    background-color: white;
    padding: 0.5em;
    font-size: 20px;
    font-weight: 600;
}
header button:hover {
    cursor: pointer;
}

header button > svg {
    display: inline-block;
    width: 24px;
    vertical-align: middle;
    margin-left: 5px;
    margin-bottom: 5px;
}

footer {
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5em;
    margin-top: auto;
    flex-wrap: wrap;
}
main {
    width: 100%;
    display: flex;
    padding: 1em;
}

body.fixed main {
    height: calc(100% - 112px);
    padding: 0;
}

main > * {
    flex: 1;
    height: 100%;
    border: 2px solid var(--pane-background);
}

/* Index page */
#content-container {
    max-width: 960px;
    margin: auto;
    border: none;
    line-height: 1.6em;
}

#content-container h2 {
    margin-top: 2em;
}
#content-container p {
    margin-top: 1em;
}

#template-list {
    margin-top: 2em;
    margin-bottom: 2em;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 1em;
}

#template-list > * {
    flex: 1 1 1;
}

#template-list div {
    background-color: var(--pane-background);
    border: 1px solid var(--pane-background);
    border-radius: 5px;
    padding: 1em;
    max-width: 256px;
    white-space: nowrap;
}
#template-list img {
    width: 100%;
    aspect-ratio: 1;
    display: block;
}

#template-list div:hover {
    border: 1px solid var(--hover);
    cursor: pointer;
}

#template-list a:hover {
    text-decoration: none;
}

/* Meta pane */
#meta {
    display: flex;
    flex-direction: column;
    min-width: 300px;
    max-width: 300px;
    padding: 1em;
    background-color: var(--pane-background);
}

#meta > * {
    margin-bottom: 2em;
}

#meta > * h2 {
    padding: 0 1em 0.1em 1em;
    margin: 0 -1em 0.3em -1em;
    border-bottom: 1px solid gray;
    display: flex;
    align-items: center;
    gap: 0.2em;
    font-size: 22px;
}

/* Project details */
#general > p {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

#project-author {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    vertical-align: middle;
}

#project-author-avatar {
    width: 28px;
    height: 28px;
    border-radius: 100%;
}

#project-actions {
    margin-top: 0.5em;
}

#project-actions > button {
    padding: 0.2em;
    display: inline-flex;
    align-items: center;
    width: 48%;
}

#project-actions > button > span {
    flex: 1;
}

#project-actions > button:hover {
    cursor: pointer;
    color: var(--hover);
}

/* Files */
#files li {
    display: flex;
    align-items: center;
    padding: 0.05em 0;
    border-bottom: 1px dotted gray;
    font-family: 'Courier New', Courier, monospace;
}
#files li > *:first-child {
    flex: 1;
    /* Match icon height to ensure list item height stays consistent */
    height: 24px;
}
#files li > * {
    width: 18px;
    margin: 5px;
}
#files li:hover {
    background-color: lightblue;
    cursor: pointer;
}

#files li.selected {
    font-weight: 600;
}

#file-list-actions {
    margin-top: 0.5em;
}

#file-list-actions > button {
    padding: 0.2em;
    display: inline-flex;
    align-items: center;
    width: 48%;
}

#file-list-actions > button > span {
    flex: 1;
}

#file-list-actions > button:hover {
    cursor: pointer;
    color: var(--hover);
}

/* Usage */
#files-footer {
    margin-top: auto;
    margin-bottom: 0em;
}

#project-usage {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 1em;
    border: 1px solid gray;
    background-color: aliceblue;
}
#project-usage[value]::-webkit-progress-bar {
    background-color: aliceblue;
}

#project-usage::-moz-progress-bar {
    background-color: #0064b4;
}
#project-usage[value]::-webkit-progress-value {
    background-color: #0064b4;
}

/* Editor pane */
#container {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

#editor-container {
    width: 100%;
    height: 100%;
    /* Needed for Chrome */
    max-height: 100%;
}

/* Preview pane */
#preview {
    display: flex;
    flex-direction: column;
}

#preview > .pane-header {
    line-height: 100%;
    padding: 0.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#preview .icon {
    margin: 0 0.5em;
}

#preview-url-bar {
    line-height: 2em;
    flex: 1;
    padding: 0.2em;
    color: #666;
    margin-right: 0.5em;
}

#preview > iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
}

.pane-header {
    width: 100%;
    height: 3em;
    background-color: #eee;
}

.tab {
    display: inline-block;
    background-color: white;
    width: auto;
    height: 100%;
    padding: 1em;
    border: 5px solid #eee;
    border-bottom: none;
    margin-left: 2em;
}

/* Resize between editor and preview */
.resizer {
    cursor: ew-resize;
    border: none;
    max-width: 5px;
    background-color: white;
}
.spacer {
    border: none;
    max-width: 5px;
    background-color: white;
}

/* Hide/disable components in readonly mode */
main.readonly #files button, main.readonly #files .icon-btn, main.readonly #delete-project-btn {
    display: none;
}

/* Project list */
#project-list {
    margin-top: 3em;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    border-bottom: 1px solid black;
}

th, td {
    padding: 0.5em;
    text-align: center;
}

td > svg {
    margin: 0 0.4em;
}

tr:nth-child(even) {
    background-color: aliceblue;
}

/* Generic */
.hidden {
    display: none !important;
}

.error-invalid-value {
    text-decoration: underline wavy red;
}

.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
}

.icon-btn:hover {
    color: var(--hover);
    cursor: pointer;
}

a {
    font-weight: 600;
    text-decoration: none;
    color: var(--link);
}

a:hover {
    text-decoration: underline;
    color: var(--hover);
}

/* Error dialog */
::backdrop {
  background-color: black;
  opacity: 0.75;
}

dialog {
    position: absolute;
    margin: auto;
    padding: 2em;
    border: 1px solid black;
}

dialog > p {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

#error-dialog > p {
    color: red;
}

dialog form {
    display: flex;
    justify-content: center;
    gap: 0.5em;
}

dialog button {
    padding: 0.5em;
    display: inline-flex;
    align-items: center;
    margin-top: 0.5em;
}
dialog button:hover {
    cursor: pointer;
    color: var(--hover);
}