/* 기본 스타일 및 폰트 설정 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    --bg-color: #1a1c23;
    --sidebar-bg: #22252e;
    --header-bg: #22252e;
    --main-bg: #1a1c23;
    --table-header-bg: #2c303a;
    --table-row-hover: #3a3f4b;
    --text-color: #e0e0e0;
    --text-light-color: #b0b0b0;
    --border-color: #3a3f4b;
    --primary-color: #007bff;
    --status-on: #28a745;
    --status-off: #dc3545;
    --status-unstable: #ffc107;
    --alert-bg: rgba(220, 53, 69, 0.15);
    --alert-border: var(--status-off);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
}

/* 전체 대시보드 레이아웃 */
.dashboard-container {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
}

/* 헤더 */
.dashboard-header {
    grid-area: header;
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
}

.dashboard-header h1 { font-size: 1.5rem; font-weight: 500; }

/* 링크들을 감싸는 div에만 margin-left: auto를 적용 */
.header-nav-links {
    margin-left: auto; /* 이 그룹을 통째로 오른쪽 끝으로 보냄 */
    display: flex;     /* 내부 링크들을 가로로 나열 */
    gap: 1.5rem;       /* 링크 사이의 간격 */
}

/* 개별 링크 스타일 */
.header-link {
    color: #0095ff; /* 또는 var(--link-color) */
    text-decoration: none; /* 밑줄 제거  */
    font-size: 0.9rem;
    white-space: nowrap; /* 줄바꿈 방지 */
}

.header-link:hover {
    text-decoration: underline;
}

/* 사이드바 */
.sidebar {
    grid-area: sidebar;
    background-color: var(--sidebar-bg);
    padding-top: 2rem;
    border-right: 1px solid var(--border-color);
}

.sidebar nav ul { list-style: none; }

.sidebar nav ul li a {
    display: block;
    padding: 0.9rem 2rem;
    color: var(--text-light-color);
    text-decoration: none;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar nav ul li a:hover {
    background-color: var(--table-row-hover);
    color: var(--text-color);
}

.sidebar nav ul li a.active {
    background-color: rgba(0, 123, 255, 0.1);
    color: var(--primary-color);
    font-weight: 700;
    border-left-color: var(--primary-color);
}

/* 본문 */
.main-content {
    grid-area: main;
    background-color: var(--main-bg);
    padding: 2rem;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* --- 경고 상자 스타일 (추가됨) --- */
.alert-box {
    display: flex;
    align-items: flex-start;
    background-color: var(--alert-bg);
    border: 1px solid var(--alert-border);
    border-left-width: 5px;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
}

.alert-icon {
    flex-shrink: 0;
    margin-right: 1rem;
    color: var(--alert-border);
}

.alert-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.alert-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.alert-content li {
    color: var(--text-light-color);
    line-height: 1.6;
}

.alert-content li strong {
    color: var(--text-color);
}

/* --- 컨텐츠 섹션 및 테이블 스타일 --- */
.content-section { margin-bottom: 4rem; }
.content-section:last-child { margin-bottom: 0; }
.main-content h2 { font-size: 1.8rem; margin-bottom: 2rem; color: #fff; }

.table-container {
    background-color: var(--sidebar-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table th:nth-child(1) { width: 45%; }
.data-table th:nth-child(2) { width: 35%; }
.data-table th:nth-child(3) { width: 20%; }

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

thead th {
    background-color: var(--table-header-bg);
    color: var(--text-color);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

thead th:first-child { border-top-left-radius: 6px; }
thead th:last-child { border-top-right-radius: 6px; }
tbody tr:hover { background-color: var(--table-row-hover); }
tbody td { color: var(--text-light-color); }
tbody td a { color: var(--primary-color); text-decoration: none; font-weight: 500; }
tbody td a:hover { text-decoration: underline; }

/* 상태 표시 스타일 */
.status-on, .status-off, .status-unstable {
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-block;
    min-width: 80px;
    text-align: center;
}

.status-on { background-color: var(--status-on); }
.status-off { background-color: var(--status-off); }
.status-unstable { background-color: var(--status-unstable); color: #1a1c23; }


/* ---------------------------------------------- */
/* --- 반응형 디자인: 모바일 환경 스타일 (추가) --- */
/* ---------------------------------------------- */
@media (max-width: 768px) {
    /* 모바일에서는 그리드 레이아웃을 변경 */
    .dashboard-container {
        grid-template-columns: 1fr; /* 컬럼을 하나로 만듦 */
        grid-template-areas:
            "header"
            "main";
    }

    /* 헤더에 메뉴 버튼을 위한 공간 확보 */
    .dashboard-header {
        justify-content: flex-start; /* 아이템들을 왼쪽부터 정렬 */
    }

    .dashboard-header h1 {
        font-size: 1.1rem; /* 모바일에서 헤더 타이틀 폰트 크기 조절 */
    }

    /* 햄버거 메뉴 버튼 스타일 */
    .menu-toggle {
        display: block; /* 모바일에서만 버튼 보이기 */
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 1rem;
    }

    /* 사이드바를 화면 좌측 바깥에 숨기고, 메뉴가 열릴 때 보이도록 설정 */
    .sidebar {
        position: fixed; /* 화면에 고정 */
        top: 0;
        left: 0;
        width: 250px; /* 메뉴 너비 */
        height: 100%;
        background-color: var(--sidebar-bg);
        transform: translateX(-100%); /* 왼쪽 화면 밖으로 이동시켜 숨김 */
        transition: transform 0.3s ease-in-out; /* 부드러운 애니메이션 효과 */
        z-index: 1000; /* 다른 요소들보다 위에 보이도록 설정 */
        border-right: 1px solid var(--border-color);
    }

    /* JS로 'open' 클래스가 추가되면 사이드바가 보이도록 함 */
    .sidebar.open {
        transform: translateX(0); /* 원래 위치로 이동 */
    }

    /* 본문 패딩 조절 */
    .main-content {
        padding: 1.5rem;
    }

    /* 오버레이 스타일 */
    .overlay {
        display: none; /* 평소에는 숨김 */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999; /* 사이드바 바로 아래에 위치 */
    }

    /* JS로 'active' 클래스가 추가되면 오버레이 보이기 */
    .overlay.active {
        display: block;
    }

    /* 테이블 Status 너비 자동 조절 (모바일 화면이 좁으므로) */
    .data-table th:nth-child(1),
    .data-table th:nth-child(2),
    .data-table th:nth-child(3) {
        width: auto;
    }
    
    .status-on, .status-off, .status-unstable {
        min-width: unset; /* 최소 너비 제한 해제 */
        white-space: normal; /* 글자가 길면 줄바꿈 허용 */
        font-size: 0.8rem;
    }
}

/* 데스크탑에서는 햄버거 버튼 숨기기 (기존 코드에 추가) */
.menu-toggle {
    display: none;
}