/* General styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f5f5f5;
    overflow: hidden; /* Prevent scrollbars */
    position: relative;
}

/* Logo styling */
.logo {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
}

.logo img {
    height: auto;
    width: 44px;
    max-width: 100%;
    object-fit: contain;
    opacity: 1;
    border-radius: 10px;
}

/* Bottom Navigation Menu */
.bottom-nav {
    background: rgba(20, 20, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 3px solid #e50914;
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.26);
    padding: 0.45rem 0;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 100;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    backdrop-filter: blur(14px);
}

.nav-menu {
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    list-style: none;
    padding: 0 8px;
    margin: 0;
    gap: 6px;
}

.nav-menu li {
    flex: 1;
    text-align: center;
    max-width: 75px;
}

.nav-menu a {
    text-decoration: none;
    color: #d6d6d6;
    font-weight: 600;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0.5rem 0.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    border-radius: 12px;
    min-height: 58px;
    border: 1px solid transparent;
}

.nav-menu a i {
    font-size: 1.16rem;
    margin-bottom: 0.22rem;
    color: inherit;
}

.nav-menu a:hover, .nav-menu a.active {
    color: #ffffff;
    background: rgba(229, 9, 20, 0.18);
    border-color: rgba(229, 9, 20, 0.36);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.nav-menu a.active i {
    color: #e50914;
}

/* Main content styles */
main {
    flex: 1;
    padding: 0;
    display: flex;
    overflow: hidden;
    width: 100%;
    height: calc(100vh - 50px); /* Reduced for smaller menu height */
    position: relative;
    margin-bottom: 50px; /* Reduced space for the bottom navigation */
}

/* Iframe styling */
.content-iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* Default low z-index */
    /* Disable transition on load (prevent flicker) */
    transition: none;
    opacity: 0; /* Hide by default */
    visibility: hidden; /* Hide completely */
}

.content-iframe.active {
    z-index: 10; /* Higher z-index when active */
    opacity: 1;
    visibility: visible;
}

/* Level Popup Styles */
.level-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at center, rgba(229, 9, 20, 0.18), transparent 42%),
        rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(5px);
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.level-popup-content {
    background: linear-gradient(180deg, #191919 0%, #0b0b0b 100%);
    border-radius: 8px;
    padding: 30px 24px 26px;
    max-width: min(92vw, 430px);
    width: 100%;
    text-align: center;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.58);
    border: 1px solid rgba(229, 9, 20, 0.42);
    position: relative;
    overflow: hidden;
}

.level-popup-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #e50914;
}

.level-popup-content::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 36%);
    pointer-events: none;
}

.level-popup-content h2 {
    color: #ffffff;
    margin: 0 0 14px;
    font-size: clamp(1.65rem, 6vw, 2.1rem);
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.1;
    position: relative;
    z-index: 1;
}

.level-popup-content p {
    color: #d2d2d2;
    margin: 0 auto 24px;
    line-height: 1.5;
    font-size: 1rem;
    max-width: 30ch;
    position: relative;
    z-index: 1;
}

.close-btn {
    background-color: #e50914;
    color: #ffffff;
    border: 1px solid #e50914;
    border-radius: 4px;
    padding: 11px 24px;
    min-width: 124px;
    min-height: 44px;
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 0;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s, box-shadow 0.2s;
    position: relative;
    z-index: 1;
}

.close-btn:hover {
    background-color: #f6121d;
    border-color: #f6121d;
    box-shadow: 0 12px 24px rgba(229, 9, 20, 0.28);
    transform: translateY(-2px);
}

.close-btn:active {
    transform: translateY(0px);
}

/* System Alert Popup Styles */
.system-alert-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.system-alert-popup-content {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    width: 350px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid #8f140d;
}

.system-alert-popup-content h2 {
    color: #8f140d !important;
    margin-bottom: 15px;
}

.system-alert-popup-content p {
    margin-bottom: 12px;
    line-height: 1.5;
    color: #333; /* Dark text for readability on light background */
}

.system-alert-popup .close-btn {
    background-color: #8f140d;
    color: #ffffff;
    border: 1px solid #6f0f09;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: 600;
    margin-top: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.system-alert-popup .close-btn:hover {
    background-color: #6f0f09;
    transform: translateY(-2px);
}

.system-alert-popup .close-btn:active {
    transform: translateY(0px);
}

/* Also style the system message popup the same way */
#system-message-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

#system-message-popup .system-alert-popup-content {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    width: 350px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    border: 2px solid #8f140d;
}

#system-message-popup .system-alert-popup-content h2 {
    color: #8f140d;
    margin-bottom: 15px;
}

#system-message-popup .system-alert-popup-content p {
    margin-bottom: 12px;
    line-height: 1.5;
    color: #333;
}

#system-message-popup .close-btn {
    background-color: #8f140d;
    color: #ffffff;
    border: 1px solid #6f0f09;
    border-radius: 8px;
    padding: 8px 20px;
    font-weight: 600;
    margin-top: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#system-message-popup .close-btn:hover {
    background-color: #6f0f09;
    transform: translateY(-2px);
}

#system-message-popup .close-btn:active {
    transform: translateY(0px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

h1 {
    margin-bottom: 1rem;
    color: #1a1a2e;
}

/* Mobile styles */
@media only screen and (max-width: 768px) {
    body {
        background: linear-gradient(180deg, #fff6f2 0%, #f4f5f8 38%, #eef1f6 100%);
    }

    .logo {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        padding: 4px;
        background: transparent;
        border-radius: 14px;
        box-shadow: none;
    }

    .logo img {
        width: 100%;
        border-radius: 10px;
    }

    .bottom-nav {
        padding: 0.42rem 0 calc(0.42rem + env(safe-area-inset-bottom, 0px));
        border-top-left-radius: 18px;
        border-top-right-radius: 18px;
    }

    .nav-menu {
        gap: 4px;
        padding: 0 6px;
    }

    .nav-menu li {
        max-width: none;
    }

    .nav-menu a {
        padding: 0.46rem 0.15rem;
        font-size: 0.74rem;
        border-radius: 12px;
        min-height: 56px;
    }

    .nav-menu a i {
        font-size: 1.12rem;
        margin-bottom: 0.2rem;
    }

    main {
        height: calc(100vh - 74px);
        margin-bottom: 74px;
    }

    .content-iframe {
        top: 0;
        height: 100%;
    }

    .level-popup {
        align-items: center;
        padding: 18px 14px calc(92px + env(safe-area-inset-bottom, 0px));
    }

    .level-popup-content {
        padding: 28px 20px 24px;
        max-width: 100%;
    }

    .level-popup-content p {
        font-size: 0.96rem;
        margin-bottom: 22px;
    }

    .level-popup .close-btn {
        width: 100%;
        max-width: 220px;
    }
}

@media only screen and (max-width: 420px) {
    .logo {
        width: 36px;
        height: 36px;
        top: 8px;
        left: 8px;
        border-radius: 12px;
    }

    .nav-menu a {
        font-size: 0.72rem;
    }

    .nav-menu a i {
        font-size: 1.05rem;
    }
}
