/* 기본 스타일 */
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f9; }

/* 고정 헤더 스타일 */
#header-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #471c87;
    color: white;
    text-align: center;
    padding: 15px 0;
    font-size: 1.8em;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* 컨테이너 스타일 */
.container { 
    display: flex; 
    max-width: 1400px; 
    margin: 20px auto; 
    background-color: #fff; 
    box-shadow: 0 0 10px rgba(0,0,0,0.1); 
    border-radius: 8px; 
    overflow: hidden; 
    margin-top: 80px; 
    min-height: calc(100vh - 120px); 
    overflow-x: auto;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0px, 1fr));
    gap: 100px;
    border-collapse: collapse;
}   
.card {
    padding: 30px;
    border: 0px solid #ddd;
    border-radius: 8px; width: 100%; width: 1100px; 
}     

/* 사이드바 (메뉴) 스타일 */
.sidebar { 
    width: 250px; 
    background-color: #2c3e50; 
    color: white; 
    padding: 20px 0; 
    height: auto; 
    overflow-y: auto; 
    flex-shrink: 0;
}
.logo { text-align: center; padding-bottom: 20px; font-size: 1.5em; font-weight: bold; border-bottom: 1px solid #34495e; margin-bottom: 20px; }
.menu-group { margin-bottom: 20px; padding: 0 20px; }
.menu-title { font-size: 1.1em; font-weight: bold; color: #ecf0f1; margin-bottom: 10px; border-bottom: 1px solid #4a637a; padding-bottom: 5px; }
.tab-button { display: block; padding: 10px 0; color: #bdc3c7; text-decoration: none; transition: background-color 0.3s, color 0.3s; border-radius: 4px; padding-left: 10px; }
.tab-button:hover { background-color: #34495e; color: #fff; }
.tab-button.active { background-color: #3498db; color: #fff; font-weight: bold; }

/* 메인 콘텐츠 스타일 */
.content { flex-grow: 1; padding: 30px; }
h1 { color: #2c3e50; margin-top: 0; }

/* 컨트롤 영역 (검색, 정렬) */
.controls-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 15px; background-color: #ecf0f1; border-radius: 6px; }
.search-controls input, .sort-controls select { padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }
.sort-controls label { margin-right: 10px; font-weight: bold; color: #2c3e50; }

/* 기사 목록/간행물 목록 스타일 */
.article-list { list-style: none; padding: 0; width: 100%;}
.article-item { background-color: #f9f9f9; border: 1px solid #ddd; border-radius: 6px; margin-bottom: 10px; padding: 15px; display: flex; justify-content: space-between; align-items: center; transition: box-shadow 0.2s; position: relative; }
.article-item:hover { box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.article-title-group { flex-grow: 1; margin-right: 20px; }
.article-title { font-size: 1.1em; color: #3498db; text-decoration: none; font-weight: bold; cursor: pointer; }
.article-meta { color: #7f8c8d; font-size: 0.9em; margin-top: 5px; }
.article-meta span { margin-right: 15px; }
.article-date { flex-shrink: 0; font-weight: bold; color: #2c3e50; font-size: 1em; }

/* 즐겨찾기 버튼 */
.favorite-btn { background: none; border: none; font-size: 1.5em; cursor: pointer; padding: 0 5px; color: #ccc; transition: color 0.2s; }
.favorite-btn.is-favorite { color: #f39c12; }
.favorite-btn:hover { color: #e67e22; }

/* 데이터 없음 메시지 */
#no-data { text-align: center; color: #e74c3c; padding: 40px; border: 1px dashed #e74c3c; border-radius: 6px; margin-top: 20px; display: none; }

/* 대시보드 스타일 */
#dashboard-view { padding: 20px; background-color: #ecf0f1; border-radius: 8px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background-color: #fff; padding: 20px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); text-align: center; }
.stat-card h3 { color: #34495e; margin-top: 0; font-size: 1.1em; }
.stat-card p { font-size: 2.5em; font-weight: bold; color: #3498db; margin: 5px 0 0 0; }
.trend-section h2 { border-bottom: 2px solid #bdc3c7; padding-bottom: 10px; color: #2c3e50; }
.txt h2 { border-bottom: 2px solid #bdc3c7; padding-bottom: 10px; color: #2c3e50; }
.latest-list { list-style: none; padding: 0; }
.latest-item { background-color: #f9f9f9; padding: 10px; margin-bottom: 8px; border-radius: 4px; display: flex; justify-content: space-between; align-items: center; }
.latest-item a { color: #2c3e50; text-decoration: none; font-weight: bold; }
.latest-item a:hover { text-decoration: underline; }
.latest-item span { font-size: 0.9em; color: #7f8c8d; }

/* 카피라이트 스타일 */
#footer-copyright {
    text-align: center;
    padding: 15px 0;
    font-size: 0.9em;
    color: #7f8c8d;
    background-color: #ecf0f1;
    margin-top: 20px;
}
#loadFileBtn,#runActionBtn2, #createAudioBtn {
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#deleteCodesBtn{
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
    background: #b81c0b;
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#loadFileBtn:hover,#runActionBtn2:hover, #createAudioBtn:hover, #deleteCodesBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.2);
}

/* 카테고리 뱃지 스타일 */
.category-badge {
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    margin-left: 8px;
    vertical-align: middle;
    font-weight: normal;
    display: inline-block;
}
/* 국방: 파란색 */
.cat-defense { background-color: #3498db; }
/* 육군: 초록색 */
.cat-army { background-color: #2ea44f; }
/* 민간: 빨간색 */
.cat-civil { background-color: #e74c3c; }
/* 기타: 노란색 (글자색 검정) */
.cat-etc { background-color: #ffcc00; color: #333; }
/* 기관: 핑크색 */
.cat-pub { background-color: #fb9de8;color: #333; }
/* 기본값(지정 안됨 등) */
.cat-default { background-color: #758888; }

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; /* 모바일 줄바꿈 */
    gap: 10px;
    margin-bottom: 10px;
}
.dashboard-title {
    margin: 0;
    font-size: 1.4em;
    color: #2c3e50;
}
.dashboard-actions {
    display: flex;
    gap: 10px;
}
#sidebarToggle {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 1.6em;
    cursor: pointer;
}

/* ------------------------------------------------ */
/* [새로 추가] 맨 위로 가기 버튼 스타일 */
/* ------------------------------------------------ */
#scrollTopBtn {
    display: none; /* 스크롤 전에는 안 보이는 게 정상입니다 */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    font-size: 0.8em;
    font-weight: bold;
    border: none;
    outline: none;
    background-color: #b3b3b3ff;
    color: white;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: background-color 0.3s, transform 0.3s;
}
#scrollTopBtn:hover {
    background-color: #808080;
    transform: translateY(-3px);
}

/* ================================================= */
/* 📱 모바일 반응형 (768px 이하) */
/* ================================================= */
@media (max-width: 768px) {

    /* 헤더 */
    #header-fixed {
        font-size: 1.2em;
        padding: 10px 0;
    }

    /* 전체 레이아웃 세로 스택 */
    .container {
        flex-direction: column;
        margin-top: 60px;
        min-height: auto;
    }

    /* 사이드바 스타일 수정: 화면 위에 덮어씌우기(Overlay) */
    .sidebar {
        display: none; /* 기본적으로 숨김 */
        position: fixed; /* 화면 고정 */
        top: 50px; /* 헤더(약 50px) 아래부터 시작 */
        left: 0;
        width: 100%;
        height: calc(100vh - 50px); /* 전체 화면 높이 채움 */
        background-color: #2c3e50;
        z-index: 1500; /* 헤더(1000)보다 높게 설정하여 컨텐츠 덮음 */
        overflow-y: auto;
        padding: 20px 0;
        box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    }
    
    /* 사이드바가 열렸을 때 애니메이션 */
    .container.sidebar-open .sidebar {
        display: block;
        animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .logo {
        font-size: 1.2em;
        padding-bottom: 10px;
    }

    /* 메뉴 버튼 정렬 */
    .menu-group {
        padding: 0 10px;
    }

    .tab-button {
        padding: 10px;
        font-size: 0.95em;
    }

    /* 메인 콘텐츠 */
    .grid {
        display: block;
    }

    .card {
        width: 100%;
        padding: 15px;
    }

    /* 컨트롤 영역 */
    .controls-row {
        flex-direction: column;
        gap: 10px;
    }

    .search-controls input,
    .sort-controls select {
        width: 100%;
    }

    /* 기사 리스트 */
    .article-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .article-date {
        align-self: flex-end;
        font-size: 0.9em;
    }

    .article-title {
        font-size: 1em;
    }

    /* 대시보드 카드 */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card p {
        font-size: 1.8em;
    }

    /* 팝업 */
    #popup {
        width: 90%;
        height: 70%;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }

    .dashboard-actions {
        width: 100%;
    }

    .dashboard-actions button {
        width: 100%;
    }
    
    /* 사이드바 토글 버튼: 사이드바 위로 오도록 z-index 조정 */
    #sidebarToggle {
        z-index: 1600; 
    }
}