/* ============================================================
   의전MASTER - 통합 관제 시스템 메인 스타일시트
   ============================================================ */

/* ── 디자인 토큰 ── */
:root {
    --sidebar-width: 270px;
    --topbar-height: 68px;

    /* 색상 팔레트 */
    --bg:          #12151e;
    --bg-deep:     #0d0f17;
    --panel:       #1c2030;
    --panel-light: #222840;
    --sidebar-bg:  #161929;
    --border:      rgba(255,255,255,0.07);
    --border-accent: rgba(197,160,89,0.4);

    /* 포인트 컬러 (골드) */
    --gold:        #c5a059;
    --gold-light:  #dfc07a;
    --gold-dim:    rgba(197,160,89,0.15);
    --gold-glow:   rgba(197,160,89,0.3);

    /* 텍스트 */
    --text:        #e8edf5;
    --text-dim:    #7e8fa8;
    --text-muted:  #4a5568;

    /* 상태 색상 */
    --green:  #2ecc71;
    --red:    #e74c3c;
    --blue:   #3b82f6;
    --yellow: #f59e0b;

    /* 카테고리 색상 */
    --cat-db:     #3b82f6;
    --cat-app:    #8b5cf6;
    --cat-admin:  #10b981;
    --cat-user:   #f59e0b;

    /* 반경 & 그림자 */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 50px rgba(0,0,0,0.6);

    /* 트랜지션 */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur: 0.3s;
}

/* ── 리셋 & 기본 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ============================================================
   레이아웃
   ============================================================ */
#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ============================================================
   사이드바
   ============================================================ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
    position: relative;
    z-index: 100;
}

#sidebar.collapsed {
    width: 0;
}

/* 로고 */
.sidebar-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    background: linear-gradient(135deg, rgba(197,160,89,0.08) 0%, transparent 100%);
    transition: background var(--dur);
}
.sidebar-header:hover { background: linear-gradient(135deg, rgba(197,160,89,0.15) 0%, transparent 100%); }

.logo-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: var(--gold);
    display: flex; align-items: center; justify-content: center;
    color: #12151e;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--gold-glow);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-main { font-family: 'Noto Serif KR', serif; font-size: 1.15rem; font-weight: 700; color: var(--gold); }
.logo-sub  { font-size: 0.65rem; font-weight: 600; color: var(--text-dim); letter-spacing: 3px; text-transform: uppercase; }

/* 메뉴 검색 */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 14px;
    padding: 9px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.sidebar-search i { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }
.sidebar-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.82rem;
    width: 100%;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

/* 메뉴 컨테이너 */
#sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

/* 카테고리 그룹 레이블 */
.menu-category {
    padding: 14px 20px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 사이드바 아이템 */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 11px 20px;
    cursor: pointer;
    color: var(--text-dim);
    white-space: nowrap;
    transition: background var(--dur), color var(--dur), border-color var(--dur);
    border-left: 3px solid transparent;
    position: relative;
}
.sidebar-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}
.sidebar-item.active {
    background: var(--gold-dim);
    color: var(--gold);
    border-left-color: var(--gold);
}
.sidebar-item .item-icon {
    width: 28px; height: 28px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem;
    flex-shrink: 0;
    background: rgba(255,255,255,0.05);
    transition: background var(--dur);
}
.sidebar-item.active .item-icon { background: var(--gold-dim); color: var(--gold); }
.sidebar-item .item-label { font-size: 0.875rem; font-weight: 500; }
.sidebar-item .item-num {
    margin-left: auto;
    font-size: 0.68rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 7px;
    border-radius: 99px;
}
.sidebar-item.hidden { display: none; }

/* 사이드바 푸터 */
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
}
.footer-version { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================================
   메인 콘텐츠
   ============================================================ */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    min-width: 0;
}

/* ── 상단바 ── */
#top-bar {
    height: var(--topbar-height);
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
}

.top-left-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

#sidebar-toggle {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim);
    font-size: 1rem;
    transition: background var(--dur), color var(--dur);
    flex-shrink: 0;
}
#sidebar-toggle:hover { background: rgba(255,255,255,0.06); color: var(--gold); }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    overflow: hidden;
}
.breadcrumb-home {
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur);
    flex-shrink: 0;
}
.breadcrumb-home:hover { color: var(--gold); }
.breadcrumb-sep { font-size: 0.6rem; color: var(--text-muted); flex-shrink: 0; }
#top-bar-title {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-right-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

/* 데이터 상태 배지 */
.data-status-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--dur);
}
.data-status-badge.loading {
    background: rgba(245,158,11,0.12);
    color: var(--yellow);
    border: 1px solid rgba(245,158,11,0.3);
}
.data-status-badge.ready {
    background: rgba(46,204,113,0.1);
    color: var(--green);
    border: 1px solid rgba(46,204,113,0.25);
}
.data-status-badge.error {
    background: rgba(231,76,60,0.1);
    color: var(--red);
    border: 1px solid rgba(231,76,60,0.25);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--gold-dim);
    border: 2px solid var(--gold-glow);
    display: flex; align-items: center; justify-content: center;
    color: var(--gold);
    font-size: 0.85rem;
}
.user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dim);
}

/* ── 뷰포트 ── */
.view-port-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ============================================================
   대시보드
   ============================================================ */
#view-dashboard {
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 히어로 섹션 */
.dashboard-hero {
    background: linear-gradient(135deg, var(--bg-deep) 0%, var(--panel) 100%);
    border-bottom: 1px solid var(--border);
    padding: 36px 36px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.dashboard-hero::before {
    content: '';
    position: absolute;
    right: -60px; top: -60px;
    width: 280px; height: 280px;
    background: radial-gradient(circle, var(--gold-glow) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}
.hero-title-ko { font-family: 'Noto Serif KR', serif; color: var(--text); }
.hero-title-en { color: var(--gold); margin-left: 4px; }
.hero-subtitle { font-size: 0.85rem; color: var(--text-dim); margin-top: 6px; }

.hero-stats {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
}
.stat-item { text-align: center; }
.stat-num {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}
.stat-label { font-size: 0.72rem; color: var(--text-dim); margin-top: 4px; display: block; }
.stat-divider { width: 1px; height: 40px; background: var(--border); }

/* 대시보드 바디 */
.dashboard-body {
    flex: 1;
    padding: 28px 36px 36px;
}

/* 카테고리 섹션 */
.cat-section { margin-bottom: 36px; }
.cat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.cat-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cat-name {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
}
.cat-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* 카드 그리드 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

/* 카드 */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 18px 18px;
    cursor: pointer;
    transition: transform var(--dur) var(--ease),
                border-color var(--dur),
                box-shadow var(--dur),
                background var(--dur);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    overflow: hidden;
}
.card::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--dur);
    pointer-events: none;
    background: linear-gradient(135deg, var(--gold-dim), transparent);
}
.card:hover {
    transform: translateY(-4px);
    border-color: var(--border-accent);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 0 1px var(--border-accent);
}
.card:hover::after { opacity: 1; }

.card-icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.card-body { position: relative; z-index: 1; width: 100%; }
.card-num {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 3px;
}
.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.card-arrow {
    position: absolute;
    bottom: 14px; right: 14px;
    color: var(--text-muted);
    font-size: 0.7rem;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity var(--dur), transform var(--dur);
    z-index: 1;
}
.card:hover .card-arrow { opacity: 1; transform: translateX(0); }

/* 카테고리별 카드 색상 */
.cat-db    .card-icon { background: rgba(59,130,246,0.15); color: var(--cat-db); }
.cat-app   .card-icon { background: rgba(139,92,246,0.15); color: var(--cat-app); }
.cat-admin .card-icon { background: rgba(16,185,129,0.15); color: var(--cat-admin); }
.cat-user  .card-icon { background: rgba(245,158,11,0.15); color: var(--cat-user); }

.cat-db    .cat-dot { background: var(--cat-db); }
.cat-app   .cat-dot { background: var(--cat-app); }
.cat-admin .cat-dot { background: var(--cat-admin); }
.cat-user  .cat-dot { background: var(--cat-user); }

/* ============================================================
   iframe 뷰
   ============================================================ */
#view-iframe-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.iframe-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
    z-index: 10;
    color: var(--text-dim);
    font-size: 0.9rem;
    transition: opacity 0.3s;
}
.iframe-loading.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#module-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ============================================================
   모바일 오버레이
   ============================================================ */
#mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}
#mobile-overlay.visible { display: block; }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 1024px) {
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }

    #sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        z-index: 200;
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
        transition: transform var(--dur) var(--ease);
    }
    #sidebar.mobile-open { transform: translateX(0); }

    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px 20px;
    }
    .dashboard-body { padding: 20px; }
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

    .hero-title { font-size: 1.6rem; }
    .hero-stats { gap: 16px; }

    #top-bar { padding: 0 16px; }
    .user-name { display: none; }
    .data-status-badge span { display: none; }
}

@media (max-width: 480px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-body { padding: 16px; }
}

/* ============================================================
   유틸리티 / 애니메이션
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cat-section {
    animation: fadeInUp 0.4s var(--ease) both;
}
.cat-section:nth-child(1) { animation-delay: 0.05s; }
.cat-section:nth-child(2) { animation-delay: 0.10s; }
.cat-section:nth-child(3) { animation-delay: 0.15s; }
.cat-section:nth-child(4) { animation-delay: 0.20s; }
.cat-section:nth-child(5) { animation-delay: 0.25s; }
.cat-section:nth-child(6) { animation-delay: 0.30s; }

/* 데이터 카운터 숫자 */
.data-count-small {
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 1px 6px;
    background: rgba(255,255,255,0.04);
    border-radius: 4px;
    margin-top: 2px;
    display: inline-block;
}
