/* Fonts */
@font-face {
    font-family: 'NodestoCapsCondensed';
    src: url('/static/fonts/NodestoCapsCondensed.otf') format('opentype');
    font-style: normal;
    /* drop-shadow is not valid in font-face */
}

@font-face {
    font-family: 'AmiriRegular';
    src: url('/static/fonts/AmiriBold.ttf') format('truetype');
}

/* General Styles */
body {
    margin: 0;
    padding: 1rem 2rem 0rem 2rem;
    font-family: "Signika", "Palatino Linotype", sans-serif;
    color: #e8eff7;
    background-image: url('/static/images/background.jpg');
    background-size: cover;
    background-attachment: fixed;
}

button {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #3a94ee;
    height: 40px;
    width: 40px;
    /* object-fit: contain; */
    vertical-align: middle;
    text-align: center;
    padding: 0.5rem;
    border-radius: 4px;
}

button:hover {
    background: #27547e;
    border-color: #a0c6ec;
    transition: background-color 0.5s, border-color 0.5s;
    cursor: pointer;
}

.fa-fake {
    height: 100%;
    font-family: 'FontAwesome';
    font-style: normal;
    font-weight: normal;
    text-decoration: inherit;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 95vh;
}

.header,
.footer {
    text-align: center;
}

.header {
    background: url('/static/images/foundry-portal-icon-512.png') 50% 50% no-repeat;
    background-size: contain;
    display: table;
    position: relative;
    /* For absolute positioning of admin button */
}

.footer {
    padding: 0.5rem 0 0 0;
}

.footer p {
    color: #e8efi7;
    margin: 0;
    font-size: 0.7rem;
}

.header {
    max-height: 80px;
    line-height: 1;
}

h1 {
    font-family: 'NodestoCapsCondensed', sans-serif;
    font-weight: normal;
    letter-spacing: -0.1rem;
    font-size: 5rem;
    line-height: 1;
    margin: 0;
    color: #e8eff7;
    text-shadow: 2px 2px 5px #000;
    display: inline-block;
    -webkit-transform: scale(1.15, 1);
    /* Safari and Chrome */
    -moz-transform: scale(1.15, 1);
    /* Firefox */
    -ms-transform: scale(1.15, 1);
    /* IE 9 */
    -o-transform: scale(1.15, 1);
    /* Opera */
    transform: scale(1.15, 1);
}

.header h1 {
    vertical-align: middle;
}

#menu {
    position: fixed;
    right: 2rem;
    top: 3rem;
}

.main-content {
    display: flex;
    flex: 1;
    gap: 2rem;
    padding: 2rem 0rem 0rem 0rem;
    box-sizing: border-box;
}

/* Worlds Section */
#worlds-section {
    flex-grow: 1;
    background-color: rgba(11, 9, 10, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 0 20px #000;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

h2 {
    font-family: 'AmiriRegular', sans-serif;
    font-size: 2em;
    color: #e8eff7;
    padding-bottom: 10px;
    margin: 0px;
    text-align: center;
    display: flex;
    flex: none;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    line-height: 1;
    font-weight: normal;
    text-shadow: 1px 1px 4px #000;
}

.panel>h2::before {
    content: "";
    width: 50%;
    margin-right: 0.5rem;
    border-top: 2px ridge #3a94ee;
    mask-image: linear-gradient(90deg, transparent 0%, black 100%);
}

.panel>h2::after {
    content: "";
    width: 50%;
    margin-left: 0.5rem;
    border-top: 2px ridge #3a94ee;
    mask-image: linear-gradient(270deg, transparent 0%, black 100%);
}

.worlds-controls {
    padding: 0 1.5rem;
    margin-bottom: 1rem;
}

#world-search {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #3a94ee;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.5);
    color: #e8eff7;
    font-family: 'Signika', sans-serif;
}

#world-search::placeholder {
    color: #888;
}

#world-search:focus {
    outline: none;
    border-color: #5ab4ff;
    box-shadow: 0 0 8px rgba(58, 148, 238, 0.5);
}

.worlds-gallery {
    white-space: nowrap;
    display: flex;
    flex-wrap: wrap;
    padding: 1.5rem;
    gap: 20px;
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3a94ee rgba(0, 0, 0, 0.3);
}

.worlds-gallery::-webkit-scrollbar {
    width: 8px;
}

.worlds-gallery::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.worlds-gallery::-webkit-scrollbar-thumb {
    background: #3a94ee;
    border-radius: 4px;
}

.worlds-gallery::-webkit-scrollbar-thumb:hover {
    background: #5ab4ff;
}

.world-card {
    position: relative;
    background-color: black;
    border-radius: 2px;
    height: 200px;
    width: calc(33.333% - 20px);
    /* 3 items per row */
    box-sizing: border-box;
    box-shadow: 0 0 10px #000;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    background-size: cover;
    background-position: center;
}

a:link {
    color: #FFFFFF;
}

a:visited {
    color: #FFFFFF;
}

a:hover {
    color: #FFFFFF;
}

.world-card h3 {
    font-family: 'Signika', sans-serif;
    margin: 1rem 0;
    color: #e8eff7;
    font-size: 1.25em;
    text-align: center;
    padding: 1rem;
    text-shadow: 1px 1px 4px black;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.5) 25%, rgba(0, 0, 0, 0.5) 75%, transparent 100%);
}

.world-card h3::after {
    display: block;
    border-top: 2px solid #3a94ee;
    mask-image: linear-gradient(270deg, transparent 0%, black 50%, transparent 100%);
    content: "";
    width: 80%;
    margin: 0.5rem auto 0;
}

.world-card p {
    margin: 1rem;
    color: white;
    text-shadow: 1px 1px 4px black;
    text-align: left;
}

/* World card states */
.world-card.active {
    cursor: pointer;
}

.world-card.idle {
    opacity: 0.8;
    filter: grayscale(20%);
}

.world-card.offline {
    opacity: 0.6;
    filter: grayscale(40%);
}

.world-card.idle,
.world-card.offline {
    cursor: default;
}

.world-card.active:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px #000;
    border: 1px solid #3a94ee;
}

.world-card.idle:hover,
.world-card.offline:hover {
    transform: none;
    cursor: default;
}

/* World status indicator */
.world-status {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    z-index: 10;
    cursor: help;
}

.world-status.active {
    background-color: #00ff00;
    box-shadow: 0 0 10px #00ff00;
}

.world-status.idle {
    background-color: #ffaa00;
    box-shadow: 0 0 10px #ffaa00;
}

.world-status.offline {
    background-color: #ff4444;
    box-shadow: 0 0 10px #ff4444;
}

/* Play icon */
.world-card .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.5rem;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    z-index: 5;
}

.world-card.active:hover .play-icon {
    opacity: 1;
}

/* World info container */
.world-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.85) 30%, rgba(0, 0, 0, 0.95) 100%);
}

.world-info h3 {
    font-family: 'Signika', sans-serif;
    margin: 0 0 0.5rem 0;
    color: #e8eff7;
    font-size: 1.25em;
    text-shadow: 2px 2px 4px black;
}

.world-info p {
    margin: 0.25rem 0;
    color: #e8eff7;
    font-size: 0.9rem;
    text-shadow: 1px 1px 3px black;
}

.world-info .world-instance {
    color: #aaa;
    font-size: 0.85rem;
}

.world-info .world-time {
    color: #888;
    font-size: 0.8rem;
    font-style: italic;
}

.world-info .world-players {
    color: #5ab4ff;
    font-weight: bold;
}

/* Admin delete button */
.delete-world {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(255, 68, 68, 0.8);
    color: white;
    border: none;
    font-size: 18px;
    line-height: 20px;
    cursor: pointer;
    z-index: 15;
    transition: background-color 0.2s;
    padding: 0;
}

.delete-world:hover {
    background-color: rgba(255, 68, 68, 1);
}

.world-card:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px #000;
    border: 1px solid #3a94ee;
    cursor: pointer;
}

.add-new {
    background: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.75)), url('/static/images/background.jpg');
    background-size: cover;
    background-position-x: 50%;
}

/* Foundry Instance Status Section */
#instance-status {
    flex-basis: 300px;
    background-color: rgba(11, 9, 10, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 0 24px #000;
    border-radius: 8px;
    padding: 1.5rem;
}

.status-key {
    padding: 0rem 1rem 1rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.status-container {
    display: table;
}

.status-indicator {
    width: 0.5rem;
    height: 0.5rem;
    ;
    display: inline-block;
    border-radius: 50%;
    margin-right: 5px;
}

.online {
    background-color: rgb(0, 255, 0);
    margin-bottom: 0.1rem;
}

/* Keyframes for pulsing light-to-bright blue */
@keyframes pulse-light {
    0% {
        background-color: #0040ff;
        /* Darker blue */
    }

    50% {
        background-color: #ffffff;
        /* Brighter blue */
    }

    100% {
        background-color: #0040ff;
        /* Back to darker blue */
    }
}

/* Active instance indicator with light-to-bright blue pulsing animation */
.active {
    background-color: #0040ff;
    /* Initial darker blue */
    margin-bottom: 0.1rem;
    animation: pulse-light 1.5s infinite ease-in-out;
    /* Apply the light pulse animation */
}

.offline {
    background-color: red;
    margin-bottom: 0.1rem;
}

.instance-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.instance-url {
    margin: 0;
    text-align: center;
    text-shadow: 2px 2px 5px #000;
}

.instance-card {
    display: table;
    background-color: black;
    border-radius: 5px;
    box-shadow: 0 0 10px #000;
    transition: transform 0.2s, box-shadow 0.2s;
}

.instance-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.instance-card h3 {
    font-family: 'Signika', sans-serif;
    vertical-align: middle;
    margin: 0;
    color: #e8eff7;
    font-size: 1.25em;
    text-align: center;
    text-shadow: 2px 2px 5px #000;
}

.instance-info-container {
    padding: 1.5rem;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.5) 25%, rgba(0, 0, 0, 0.5) 75%, transparent 100%)
}

.instance-card:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px #000;
    border: 1px solid #3a94ee;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    #active-worlds,
    #instance-status {
        width: 100%;
    }

    .world-card {
        width: calc(50% - 20px);
        /* For smaller screens, show 2 cards per row */
    }
}

@media (max-width: 768px) {
    .world-card {
        width: calc(100% - 20px);
        /* For smaller screens, show 1 card per row */
    }
}

/* Add styles for the GitHub link */
.github-link {
    position: absolute;
    top: 20px;
    right: 20px;
    display: block;
    width: 30px;
    height: 30px;
}

.github-link img {
    width: 100%;
    height: auto;
}

/* --- New Styles for Modals and Forms --- */

.nav-separator {
    display: inline-block;
    width: 2px;
    height: 40px;
    background-color: white;
    margin: 0 10px;
    vertical-align: middle;
}

.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.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #1a1a1a;
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid #3a94ee;
    width: 400px;
    border-radius: 8px;
    box-shadow: 0 0 20px #000;
    color: #e8eff7;
    position: relative;
}

.modal-content.large {
    width: 800px;
    max-width: 90%;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.5rem;
}

.close:hover,
.close:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="url"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #444;
    background-color: #222;
    color: #fff;
    border-radius: 4px;
    box-sizing: border-box;
}

.form-group input:focus {
    border-color: #3a94ee;
    outline: none;
}

.btn-primary {
    background-color: #3a94ee;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    font-weight: bold;
}

.btn-primary:hover {
    background-color: #27547e;
}

.btn-secondary {
    background-color: #444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    width: auto;
}

.btn-secondary:hover {
    background-color: #666;
}

.btn-danger {
    background-color: #d9534f;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    width: auto;
    height: auto;
}

.btn-danger:hover {
    background-color: #c9302c;
}

.help-text {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 0.25rem;
}

/* Config Sections */
.config-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #444;
}

.config-section:last-child {
    border-bottom: none;
}

.config-section h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #3a94ee;
    font-family: 'Signika', sans-serif;
    font-size: 1.2rem;
}

/* Instance Rows */
.instance-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.instance-row input {
    flex: 1;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}