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

.header {
    border-bottom: 3px solid #a2a9b1;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.main-title {
    font-weight: normal;
    margin-bottom: 5px;
    font-family: 'Linux Libertine', Georgia, Times, serif;
}

.subtitle {
    color: #54595d;
    margin-bottom: 10px;
}

.content-wrapper {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.main-content {
    flex: 1;
}

.extra-content-select {
    display: none;
    width: 250px !important;
}

.extra-content-section {
    margin-top: 40px;
    border-top: 1px solid #a2a9b1;
    padding-top: 20px;
}

.extra-content-section-title {
    font-size: 1.5em;
    font-weight: normal;
    margin-bottom: 20px;
    font-family: 'Linux Libertine', Georgia, Times, serif;
}

.infobox {
    width: 300px;
    border: 1px solid #a2a9b1;
    background-color: #f8f9fa;
    padding: 0;
    margin-left: 20px;
    align-self: flex-start;
}

.infobox-image {
    width: 300px;
    height: 200px;
    object-fit: scale-down;
    display: block;
}

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

.metadata-table th,
.metadata-table td {
    padding: 8px 10px;
    border: 1px solid #a6a9af;
    text-align: left;
}

.metadata-table th {
    background-color: #eaecf0;
    font-weight: bold;
    max-width: max-content !important;
    min-width: min-content !important;
    width: 150px;
}

.infobox-table {
    width: 300px;
    border-collapse: collapse;
    font-size: 0.9em;
}

.infobox-table th,
.infobox-table td {
    padding: 8px 10px;
    border: 1px solid #eaecf0;
    text-align: left;
}

.infobox-table th {
    background-color: #eaecf0;
    font-weight: bold;
    width: 40%;
}

.custom-preview p {
  margin-bottom: 1.5em;
}

.editor-preview {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: white !important;
    font-family: inherit;
    font-size: 1rem;
}

.editor-preview pre {
    background: #f0f0f0;
    padding: 0.5em;
}

.section-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    /* space between buttons */
    background: #f0f0f0;
    /* light gray background */
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    user-select: none;
    /* prevent accidental text selection on toolbar */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
}

.section-toolbar button {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    width: 30px;
    height: 30px;
    text-align: center;
    transition: background-color 0.2s ease;
}

#fontSizeSelector {
    width: 40px;
    height: 30px !important;
    margin-top: 0px;
}

#fontFamilySelector {
    width: 180px;
    height: 30px !important;
    margin-top: 0px;
}

.section-toolbar button:hover {
    background-color: #ddd;
}

.section-toolbar button b,
.section-toolbar button i,
.section-toolbar button u {
    pointer-events: none;
    /* so clicks target button, not icon */
}

.section-toolbar select,
.section-toolbar input[type="color"] {
    padding: 4px 4px;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    font-size: 14px;
}

.section-toolbar select:hover,
.section-toolbar input[type="color"]:hover {
    border-color: #999;
}

.section-toolbar input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #ccc;
}

.section-title {
    font-size: 1.5em;
    font-weight: normal;
    border-bottom: 1px solid #a2a9b1;
    margin-bottom: 15px;
    padding-bottom: 5px;
    font-family: 'Linux Libertine', Georgia, Times, serif;
}

.section-content {
    text-align: justify;
    margin-bottom: 15px;
}

.editable:empty:before {
    content: attr(data-placeholder);
    color: gray;
}

[contenteditable="true"] {
    outline: none;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-height: 1.5em;
    cursor: text;
}

.image-container {
    position: relative;
    display: inline-block;
}

.delete-button {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: rgb(255, 0, 0);
    border: none;
    color: white;
    font-size: 1.2em;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    transition: background-color 0.2s ease;
}

.delete-button:hover {
    background-color: rgb(255, 0, 0);
}

.admin-buttons {
    display: none;
    margin-right: 30px;
}

.admin-button {
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    padding: 0.6em 1.2em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.admin-row-button {
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    padding: 0.3em 0.6em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.admin-button:active,
.admin-row-button:active {
    transform: scale(0.92);
    box-shadow: none;
    background-position: right center;
}

.admin-row-div {
    cursor: pointer;
}

.add {
    background: linear-gradient(135deg, #218838, #28a745);
}

.add:hover {
    background: linear-gradient(135deg, #28a745, #34d058);
    box-shadow: 0 6px 14px rgba(40, 167, 69, 0.4);
}

.save {
    background: linear-gradient(135deg, #1f28a1, #3843da);
}

.save:hover {
    background: linear-gradient(135deg, #3843da, #5565ff);
    box-shadow: 0 6px 14px rgba(15, 21, 115, 0.4);
}

.login {
    background: linear-gradient(135deg, #000762, #081193);
}

.login:hover {
    background: linear-gradient(135deg, #081193, #101cbe);
    box-shadow: 0 6px 14px rgba(15, 21, 115, 0.4);
}

.loginBar {
    background: linear-gradient(135deg, #3c3c3c, #3c3c3c);
}

.loginBar:hover {
    background: linear-gradient(135deg, #4e4e4e, #898989);
    box-shadow: 0 6px 14px rgba(96, 96, 96, 0.4);
}

.logout {
    background: linear-gradient(135deg, #620000, #7a0505);
    display: none;
}

.logout:hover {
    background: linear-gradient(135deg, #7a0505, #a70000);
    box-shadow: 0 6px 14px rgba(139, 0, 0, 0.4);
}

.add-image {
    background: linear-gradient(135deg, #41414a, #5a5a66);
}

.add-image:hover {
    background: linear-gradient(135deg, #5a5a66, #6f6f7d);
    box-shadow: 0 6px 14px rgba(65, 65, 74, 0.4);
}

.delete {
    background: linear-gradient(135deg, #c82333, #dc3545);
}

.delete:hover {
    background: linear-gradient(135deg, #dc3545, #e85a69);
    box-shadow: 0 6px 14px rgba(220, 53, 69, 0.4);
}

.manage {
    background: linear-gradient(135deg, #23c8c0, #35dcd9);
}

.manage:hover {
    background: linear-gradient(135deg, #35dcd1, #5ae8df);
    box-shadow: 0 6px 14px #23c8c066;
}

.metadata-section {
    margin-bottom: 20px;
}

.admin-button:active {
    transform: scale(0.92);
    box-shadow: none;
}

.gallery {
    margin-top: 40px;
    border-top: 1px solid #a2a9b1;
    padding-top: 20px;
}

.gallery-title {
    font-size: 1.5em;
    font-weight: normal;
    margin-bottom: 20px;
    font-family: 'Linux Libertine', Georgia, Times, serif;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(275px, 275px));
    gap: 15px;
}

.gallery-item {
    text-align: center;
}

.gallery-image {
    width: 275px !important;
    height: 275px !important;
    object-fit: cover;
    border: 1px solid #a2a9b1;
    border-radius: 3px;
}

.gallery-image-button {
    margin-top: auto;
    margin-bottom: auto;
}

.gallery-image:hover {
    cursor: pointer;
}

.gallery-caption {
    font-size: 0.85em;
    color: #54595d;
    margin-top: 5px;
    padding: 0 5px;
}

.wiki-link {
    color: #0645ad;
    text-decoration: none;
}

.wiki-link:hover {
    text-decoration: underline;
}

.wiki-link:visited {
    color: #0b0080;
}

.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
}

.image-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 80%;
    max-height: 80%;
    user-select: none;
}

#newPage {
    width: 500px;
}

.close-btn {
    position: absolute;
    top: 30px;
    right: 40px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    user-select: none;
}

.nav-btn {
    position: absolute;
    top: 50%;
    font-size: 40px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    user-select: none;
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.rawMetadata {
    width: 600px;
    height: 550px;
    padding: 0 10px;
}

#extraContentTable {
    width: 650px;
    padding: 10px;
}

#extraContentTable tr th {
    width: max-content;
    max-width: 150px;
}

#extraContentTable td:first-child {
    min-width: 450px;
    max-width: 450px;
    width: 100%;
    white-space: nowrap;
}

.extra-content {
    margin-bottom: 5px;
}

#rawMetadata {
    font-size: 11px;
    font-family: monospace;
    line-height: 15px;
    font-weight: 500;
    margin: 0;
    padding: 0;
    resize: both;
    color: rgb(0, 0, 0);
    border: 0;
    background-color: #ffffff;
    white-space: pre-wrap;
}

#rawMetadata:active {
    border: 0;
}

/* Modal Box */
.modal-content {
    background-color: #fff;
    margin: auto;
    margin-top: 80px !important;
    padding: 20px;
    max-width: max-content;
    /* shrink-wrap content */
    min-width: 300px;
    border-radius: 8px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Lato, Helvetica, Arial, sans-serif;
}

.modal-text {
    padding: 10px 5px;
    margin-top: 5px;
    border-top: 1px solid #aeaeae;
    border-bottom: 1px solid #aeaeae;
    max-height: 700px;
    overflow: auto;
    width: 100%;
}

.modal-content h2 {
    margin-top: 0;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

.modal-content input[type="text"],
.modal-content input[type="password"] {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

select {
    appearance: none;
    /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    margin-top: 5px;
    background-color: #f0f4ff;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 10px 40px 10px 12px;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s ease;
    background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='18' viewBox='0 0 24 24' width='18' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 3px center;
    background-size: 18px;
    width: 100%;
    max-width: 250px;
}

option:active {
    background-color: #d3deff !important;
}

select:hover {
    border-color: #888;
    cursor: pointer;
}

select:focus {
    border-color: #0033cc;
    box-shadow: 0 0 0 2px rgba(0, 51, 204, 0.2);
}

input:disabled {
    background: lightgrey;
}

.tab-buttons {
    margin-bottom: -2px;
}

.tab-btn {
    padding: 10px 20px;
    cursor: pointer;
    background: #ddd;
    border: none;
    outline: none;
    border-radius: 4px 4px 0 0;
}

.tab-btn.active {
    background: #757575;
    border-bottom: 2px solid white;
    color: white;
}

.tab-content {
    border: 1px solid #ccc;
    padding: 10px;
    background: #fff;
    max-height: 600px;
    overflow: auto;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

#extraContentMessage {
    width: 650px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

#logoutModal .modal-content {
    margin-top: 300px !important;
    max-width: 500px !important;
}

.logout-group {
    margin-top: 50px;
}

.logout-buttons {
    float: right;
}

.metadata, .description-block {
    margin-top: 10px;
    background: #f0f4f8;
    padding: 10px;
    border-radius: 6px;
}

.description-block div {
    margin-bottom: 10px;
}

.home-section {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    padding: 20px;
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .infobox {
        width: 100%;
        margin-left: 0;
        margin-bottom: 20px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}