/* ==================== CSS 변수 ==================== */
:root {
    /* 주요 색상 */
    --primary-color: #6366f1;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    /* 회색 음영 */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* 레이아웃 */
    --header-height: 64px;
    --sidebar-width: 260px;
    --sidebar-icon-width: 70px;

    /* 그림자 */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ==================== 전역 스타일 ==================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
}

/* ==================== 레이아웃 ==================== */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 헤더 */
.app-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.header-hamburger {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.header-hamburger:hover {
    background: var(--gray-100);
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.header-search {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 400px;
    width: 100%;
}

.header-search i {
    position: absolute;
    left: 1rem;
    color: var(--gray-400);
}

.header-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.header-action {
    position: relative;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.header-action:hover {
    background: var(--gray-100);
}

.header-action .badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--danger-color);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.75rem;
    min-width: 1.25rem;
    text-align: center;
}

/* 사용자 메뉴 */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-900);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1001;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
}

.user-dropdown-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-dropdown-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-900);
}

.user-dropdown-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-dropdown-item:hover {
    background: var(--gray-50);
}

.user-dropdown-item i {
    font-size: 1rem;
}

/* Body */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* 사이드바 오버레이 (모바일) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

/* 사이드바 */
.app-sidebar {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    transition: width 0.3s, transform 0.3s;
    flex-shrink: 0;
}

.app-sidebar.icon-mode {
    width: var(--sidebar-icon-width);
}

.sidebar-nav {
    padding: 1rem 0;
}

/* 네비게이션 아이템 */
.nav-item {
    margin: 0.25rem 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-link i {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.nav-label {
    font-size: 0.875rem;
    font-weight: 500;
}

/* 아코디언 */
.nav-accordion {
    margin: 0.25rem 0.5rem;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background: var(--gray-100);
}

.accordion-header.active {
    background: var(--gray-100);
    color: var(--gray-900);
}

.accordion-header .icon {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
}

.accordion-header .chevron {
    margin-left: auto;
    transition: transform 0.3s;
}

.accordion-header.active .chevron {
    transform: rotate(-180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.open {
    max-height: 500px;
}

.accordion-content .nav-link {
    padding-left: 3rem;
    font-size: 0.875rem;
}

/* 메인 콘텐츠 */
.app-main {
    flex: 1;
    overflow-y: auto;
    background: var(--gray-50);
}

/* ==================== 통계 카드 ==================== */
.stat-icon {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== 유틸리티 ==================== */
.cursor-pointer {
    cursor: pointer;
}

/* ==================== 반응형 ==================== */
@media (max-width: 768px) {
    .header-search {
        display: none;
    }

    .user-info {
        display: none;
    }

    .app-sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0 !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .app-sidebar {
        width: var(--sidebar-icon-width);
    }

    .app-sidebar .nav-label,
    .app-sidebar .chevron {
        display: none;
    }

    .accordion-content {
        display: none !important;
    }
}

/* ==================== 다크모드 대응 (선택사항) ==================== */
@media (prefers-color-scheme: dark) {
    /* 필요시 다크모드 스타일 추가 */
}
