@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css");

:root {
    /* Theme tokens (default: light) */
    --color-bg: #ffffff;
    --color-surface: #ffffff;
    --color-surface-muted: #f7f7f7;
    --color-text: #222222;
    --color-text-muted: #666666;
    --color-border: #dddddd;
    --color-border-soft: #eeeeee;

    --color-header-bg: #333333;
    --color-header-text: #ffffff;
    --color-sidebar-bg: #f4f4f4;
    --color-sidebar-surface: #fbfbfb;
    --color-sidebar-border: rgba(0, 0, 0, 0.06);
    --color-sidebar-link-hover: rgba(0, 0, 0, 0.04);
    --color-sidebar-active-bg: rgba(0, 123, 255, 0.10);
    --color-sidebar-active-text: #0b6fe3;
    --color-sidebar-indicator: #007bff;

    --color-link: #007bff;
    --color-link-hover: #0b6fe3;

    --color-focus-ring: rgba(255, 255, 255, 0.7);
}

html[data-theme="dark"] {
    --color-bg: #0f1115;
    --color-surface: #151821;
    --color-surface-muted: #1c2230;
    --color-text: #e7eaf0;
    --color-text-muted: #aab2c0;
    --color-border: #2a3242;
    --color-border-soft: #222a3a;

    --color-header-bg: #0c0f14;
    --color-header-text: #e7eaf0;
    --color-sidebar-bg: #111521;
    --color-sidebar-surface: #0f1420;
    --color-sidebar-border: rgba(255, 255, 255, 0.08);
    --color-sidebar-link-hover: rgba(255, 255, 255, 0.06);
    --color-sidebar-active-bg: rgba(90, 167, 255, 0.16);
    --color-sidebar-active-text: #86bfff;
    --color-sidebar-indicator: #5aa7ff;

    --color-link: #5aa7ff;
    --color-link-hover: #86bfff;

    --color-focus-ring: rgba(135, 191, 255, 0.65);
}

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

html {
    font-size: 16px;
}

body {
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--color-bg);
    color: var(--color-text);
}

header {
    background-color: var(--color-header-bg);
    color: var(--color-header-text);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header a {
    color: var(--color-header-text);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: bold;
    transition: opacity 0.2s ease;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    white-space: nowrap;
}

.brand-logo {
    height: 1.25rem;
    width: auto;
    display: block;
}

.brand-text {
    display: inline-block;
}

header a:hover {
    opacity: 0.8;
}

#header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

#notification-area {
    display: flex;
    align-items: center;
}

.header-item {
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s ease, text-decoration 0.2s ease;

    /* `button.header-item` 기본 스타일 리셋 (브라우저별 UI 튐 방지) */
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    line-height: 1;
    appearance: none;
    -webkit-appearance: none;
}

.header-item:focus-visible {
    outline: 0.125rem solid var(--color-focus-ring);
    outline-offset: 0.125rem;
    border-radius: 0.25rem;
}

.inline-flex-center {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.header-item:hover {
    text-decoration: underline;
    color: #ccc;
}

.user-name {
    font-weight: bold;
    margin-right: 0.5rem;
}

.notification-icon {
    font-size: 1.2rem;
    position: relative;
    display: flex;
    align-items: center;
}

.notification-icon:focus-visible {
    outline: 0.125rem solid rgba(255, 255, 255, 0.7);
    outline-offset: 0.125rem;
    border-radius: 0.25rem;
}

.notification-icon svg {
    display: block;
}

/* 알림 모달 스타일 */
.notification-modal {
    position: absolute;
    top: 100%;
    right: 0;
    width: 18.75rem; /* 300px -> 18.75rem */
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 0.0625rem solid var(--color-border);
    border-radius: 0.25rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 0.625rem;
    display: block;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.625rem);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

.notification-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.notification-modal-header {
    padding: 0.625rem 0.9375rem;
    border-bottom: 0.0625rem solid var(--color-border-soft);
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-read-all {
    background: none;
    border: none;
    color: var(--color-link);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}

.notification-read-all:hover {
    text-decoration: underline;
    color: var(--color-link-hover);
}

.notification-list {
    max-height: 25rem; /* 400px -> 25rem */
    overflow-y: auto;
}

.notification-item {
    padding: 0.75rem 0.9375rem;
    border-bottom: 0.0625rem solid var(--color-border-soft);
    font-size: 0.85rem;
    cursor: default;
    transition: background-color 0.2s ease;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background-color: var(--color-surface-muted);
}

.notification-empty {
    padding: 1.25rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.notification-badge {
    position: absolute;
    top: -0.3125rem;
    right: -0.625rem;
    background-color: red;
    color: white;
    font-size: 0.7rem;
    border-radius: 50%;
    padding: 0.125rem 0.3125rem;
}

.container {
    display: flex;
    flex: 1;
}

/* Sidebar (global) */
#app-aside {
    width: 15.625rem; /* 250px -> 15.625rem */
    background: var(--color-sidebar-bg);
    padding: 1.25rem 1rem;
    border-right: 0.0625rem solid var(--color-sidebar-border);
}

#app-aside .sidebar-nav {
    position: sticky;
    top: 1rem;
}

#app-aside .sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem 0.5rem;
}

#app-aside .sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0;
    margin: 0;
}

#app-aside .sidebar-item {
    margin: 0;
}

#app-aside .sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 0.6rem;
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    background: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#app-aside .sidebar-link:hover {
    background: var(--color-sidebar-link-hover);
}

#app-aside .sidebar-link.active {
    color: var(--color-sidebar-active-text);
    background: var(--color-sidebar-active-bg);
}

#app-aside .sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.2rem;
    height: 1.15rem;
    border-radius: 9999px;
    background: var(--color-sidebar-indicator);
}

#app-aside .sidebar-link:focus-visible {
    outline: 0.125rem solid var(--color-link);
    outline-offset: 0.125rem;
}

/* Sidebar Accordion Styles */
#app-aside .sidebar-accordion-toggle {
    justify-content: space-between;
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 1rem;
    width: 100%;
}

#app-aside .sidebar-accordion-icon {
    transition: transform 0.2s ease;
}

#app-aside .sidebar-accordion-toggle[aria-expanded="true"] .sidebar-accordion-icon {
    transform: rotate(180deg);
}

#app-aside .sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0 0 0 1.25rem; /* Indent the whole submenu list */
    border-left: 1px solid var(--color-sidebar-border); /* The directory guideline */
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#app-aside .sidebar-submenu.show {
    max-height: 50rem; /* Arbitrary large height */
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
}

#app-aside .sidebar-submenu .sidebar-item {
    margin-top: 0.1rem;
}

#app-aside .sidebar-submenu .sidebar-link {
    padding-left: 1rem; /* Spacing from the guideline */
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

#app-aside .sidebar-submenu .sidebar-link.active {
    color: var(--color-sidebar-active-text);
    background: var(--color-sidebar-active-bg);
    font-weight: 700;
}

/* Active indicator for nested items - aligns with the guideline */
#app-aside .sidebar-submenu .sidebar-link.active::before {
    left: -1px; /* Align exactly with the border-left of parent ul */
    width: 2px;
    height: 100%;
}

main {
    flex: 1;
    padding: 2rem;
    background-color: var(--color-surface);
}

/* 반응형 스타일 */

/* 0단계: 대형 데스크톱 (1440px 초과) */
@media (min-width: 90.0625rem) { /* 1441px -> 90.0625rem */
    html {
        font-size: 112.5%; /* 18px / 16px = 1.125 = 112.5% */
    }

    #app-aside {
        width: 18.75rem; /* 300px -> 18.75rem */
    }
    
    header {
        padding: 1.2rem 1rem;
    }
    
    main {
        padding: 3rem;
    }
}

/* 1단계: 태블릿 및 모바일 (1200px 이하 - 75rem) */
@media (max-width: 75rem) {
    #mobile-menu-toggle {
        display: inline-flex !important;
    }

    #view-mode-toggle {
        display: none !important;
    }

    html[data-view-mode="narrow"] main {
        max-width: none;
    }

    #app-aside {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%; /* Full width */
        height: 100%;
        z-index: 2000;
        background: var(--color-sidebar-bg);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        border-right: none;
        display: block;
        padding: 1.5rem;
        overflow-y: auto;
    }

    #app-aside.mobile-open {
        transform: translateX(0);
    }

    #app-aside .sidebar-mobile-header {
        display: flex !important;
        color: var(--color-text);
    }

    #app-aside .sidebar-nav {
        position: static;
        max-width: 40rem; /* Optional: Center content on larger mobile screens */
        margin: 0 auto;
    }

    #app-aside .sidebar-section-title {
        display: block;
        margin-top: 2rem;
    }

    #app-aside .sidebar-menu {
        flex-direction: column;
        gap: 0.25rem;
        overflow-x: visible;
    }

    #app-aside .sidebar-link {
        width: 100%;
        white-space: normal;
        border: none;
        background: transparent;
    }

    #app-aside .sidebar-link.active::before {
        display: block;
    }

    /* Submenu reset for mobile drawer */
    #app-aside .sidebar-submenu {
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        width: auto !important;
        background: transparent !important;
        animation: none !important;
        margin-top: 0 !important;
        /* Keep max-height logic from base styles to allow accordion to work */
    }
}

/* 2단계: 소형 모바일 (768px 이하) */
@media (max-width: 48rem) { /* 768px -> 48rem */
    main {
        padding: 1rem 1.5rem;
    }
    
    header {
        padding: 1rem;
    }
    
    header a {
        font-size: 1rem;
    }

    .brand-text {
        display: none;
    }
    
    #header-right {
        gap: 0.8rem;
    }
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s;
    backdrop-filter: blur(0.125rem);
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* 로딩 스피너 스타일 */
#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex; /* 기본적으로 보임 (초기 로딩 커버) */
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

html[data-theme="dark"] #loading-spinner {
    background-color: rgba(0, 0, 0, 0.55);
}

.spinner {
    width: 3.125rem; /* 50px -> 3.125rem */
    height: 3.125rem;
    border: 0.3125rem solid #f3f3f3;
    border-top: 0.3125rem solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.page-description {
    margin-top: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Theme toggle button (header) */
.theme-toggle {
    border: 0.0625rem solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: var(--color-header-text);
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.55);
}

.theme-toggle:focus-visible {
    outline: 0.125rem solid var(--color-focus-ring);
    outline-offset: 0.125rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 404 에러 페이지 스타일 */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    height: 100%;
}

.error-code {
    font-size: 8rem;
    font-weight: 900;
    color: #333;
    line-height: 1;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.5rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 1rem;
}

.error-description {
    font-size: 1rem;
    color: #777;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.home-button {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background-color: #333;
    color: white;
    text-decoration: none;
    border-radius: 0.25rem;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.home-button:hover {
    background-color: #555;
}

.home-button:active {
    transform: scale(0.98);
}

/* View Mode (Narrow/Wide) */
html[data-view-mode="narrow"] main {
    max-width: 60rem;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state-text {
    color: var(--color-text-muted);
    font-size: 1rem;
}

