/* ===== CSS Variables ===== */
:root {
    --primary-color: #d32f2f;
    --primary-dark: #b71c1c;
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --bg-light: #f5f5f5;
    --text-light: #ffffff;
    --text-dark: #333333;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --sidebar-width: 320px;
    --header-height: 70px;
    --transition-speed: 0.3s;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    overflow: hidden;
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    /* Modern Glassy Gradient */
    background: linear-gradient(-45deg, #0f0c29, #302b63, #24243e, #1e3c72, #2a5298);
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;

    /* Glassmorphism */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);

    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%
    }

    50% {
        background-position: 100% 50%
    }

    100% {
        background-position: 0% 50%
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 30px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    transition: transform var(--transition-speed);
}

.mobile-menu-btn:hover {
    transform: scale(1.1);
}

.header-title {
    font-family: 'Do Hyeon', sans-serif;
    /* New Font */
    font-size: 36px;
    font-weight: 500;
    /* Do Hyeon is bold by nature */
    color: var(--text-light);
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.header-right {
    display: flex;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
}

.logo-img {
    height: 53px;
    /* Slightly smaller */
    width: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.logo-img:hover {
    transform: scale(1.05);
}

/* ===== Main Container ===== */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    position: relative;
    /* Context for absolute positioning */
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition-speed), width var(--transition-speed);
}

@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 0;
    }
}

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.sidebar-nav {
    padding: 20px 0;
}

.menu-list {
    list-style: none;
}

.menu-item {
    margin-bottom: 8px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    color: #ecf0f1;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.menu-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.menu-link i {
    margin-right: 12px;
    font-size: 18px;
    width: 24px;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    position: relative;
    background: white;
    overflow: hidden;
    /* Ensure overlay stays within */
}

#content-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Bottom Left Logo Overlay */
.bottom-logo-overlay {
    position: absolute;
    bottom: 5px;
    left: 25px;
    z-index: 90;
    pointer-events: none;
    /* Allow clicking through if needed, or remove if clickable */
}

.bottom-logo-overlay a {
    pointer-events: auto;
    display: inline-block;
}

.bottom-logo-overlay img {
    height: 45px;
    /* Adjust size properly */
    width: auto;
    /* Make it look white/bright on map */
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
    opacity: 0.9;
    transition: opacity 0.3s, transform 0.3s ease;
}

.bottom-logo-overlay img:hover {
    opacity: 1;
    transform: scale(1.05);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .header-content {
        padding: 0 3px;
    }

    .header-title {
        font-size: 23px;
        /* Slightly larger due to font change */
    }

    .logo-img {
        height: 30px;
    }

    .logo-container {
        padding-right: 6px;
    }

    /* Adjust bottom logo for mobile */
    .bottom-logo-overlay {
        bottom: 5px;
        left: 15px;
        z-index: 90;
    }

    .header-left {
        gap: 6px;
        /* Reduced from 20px */
    }

    .bottom-logo-overlay img {
        height: 33px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: 280px;
        transform: translateX(-100%);
        z-index: 2001;
        /* Higher than bottom logo (2000) */
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 21px;
        letter-spacing: -1px;

    }

    .sidebar {
        width: 260px;
    }
}

/* ===== Sidebar Grouping Updates ===== */

.menu-category {
    margin-bottom: 15px;
}

.category-header {
    padding: 15px 20px 15px 25px;
    /* Adjust padding for larger font */
    font-size: 20px;
    /* Increased from 15px (approx 1.33x, but visually significant) */
    font-weight: 700;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
    /* Remove margin as submenu handles it */
    line-height: 1.4;
    letter-spacing: -0.5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.category-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.category-header .header-text {
    flex: 1;
}

.category-header i.arrow {
    font-size: 16px;
    /* Increased from 12px */
    color: #9aa0a6;
    transition: transform 0.3s ease;
}

.menu-category.active .category-header i.arrow {
    transform: rotate(180deg);
}

.category-header .subtitle {
    font-size: 16px;
    font-weight: 500;
    color: #d1d1d1;
    margin-top: 4px;
    display: block;
}

.submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.menu-category.active .submenu {
    max-height: 500px;
    /* ample space */
    opacity: 1;
    padding-bottom: 10px;
    /* Space after expanded items */
}

/* Update menu link for compact list */
.menu-link {
    padding: 12px 20px 12px 35px;
    /* Increased left padding for indentation */
    font-size: 14px;
    border-radius: 0 25px 25px 0;
    /* Rounded tabs on one side style */
    margin-right: 15px;
    /* Spacing for the rounded tab */
}

.menu-link:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.05);
}

.menu-link.active {
    background: linear-gradient(90deg, #d32f2f 0%, #ff5252 100%);
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.4);
}

.menu-link i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
    font-size: 16px;
    opacity: 0.9;
}

/* Main Level Menu Links (Ungrouped items) */
.menu-link.main-level {
    font-size: 18px;
    /* Larger than submenu items */
    font-weight: 700;
    padding: 15px 20px 15px 25px;
    /* Match header padding mostly */
    border-radius: 0;
    /* Full width feel like headers */
    margin-right: 0;
    color: #e0e0e0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.menu-link.main-level:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    /* No slide for main items, keeps it stable */
}

.menu-link.main-level.active {
    background: rgba(255, 255, 255, 0.1);
    /* Subtle active state or keep the gradient? */
    /* Let's keep gradient but maybe less rounded/indented */
    background: linear-gradient(90deg, rgba(211, 47, 47, 0.8) 0%, rgba(255, 82, 82, 0.6) 100%);
    box-shadow: none;
    border-left: 4px solid #ff5252;
}

.menu-link.main-level i {
    font-size: 20px;
    width: 30px;
    margin-right: 10px;
}

.menu-link.main-level .subtitle {
    font-size: 15px;
    font-weight: 500;
    color: #d1d1d1;
    margin-top: 2px;
    display: block;
}