/* layout.css - Main Viewport, Panels & Modals */
/* =========================================
   [Level 0] 메인 래퍼 (사이드바 제외 전체 영역)
   구조: .main-wrapper > (공지/광고) > .page-container
   ========================================= */
.main-wrapper {
/* 1. 기본 레이아웃 배치 */
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background-color: #f8f9fa;

    /* 2. [복구 완료] 사이드바 공간 확보 (이게 없어서 겹쳤던 것!) */
    margin-left: var(--sidebar-width, 250px); 
    width: auto; /* 여백 제외 나머지 꽉 채움 */
    
    /* 3. [복구 완료] 사이드바 움직임과 동기화 */
    transition: margin-left 0.3s ease;

    /* 내부 컨텐츠가 넘칠 때 깨짐 방지 */
    min-width: 0; 
}

/* [누락분 추가] 상단 공지바 및 광고 영역 (레이아웃 구조) */
/* 1. 공지바 (최상단 띠) */
.announcement-bar {
    height: var(--header-height);
    background: #1a252f;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.announcement-bar a {
    color: var(--accent-blue, #3498db); 
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 2. 광고 영역 (공지바 아래) */
.ad-space-top {
    background: white;
    margin: 10px var(--main-padding) 0 var(--main-padding);
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px dashed #ddd;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #888;
}

/* 사이드바 토글 상태 제어 */
body.sidebar-closed .main-wrapper { margin-left: 0 !important; }

/* ------------------------------------------------------------
   B. 통합 레이아웃 시스템 (Main & Body Panels)
   ------------------------------------------------------------ */
/* 페이지 전체 컨테이너 */
.page-container {
    flex: 1;                    /* 메인 래퍼의 남은 공간 꽉 채움 */
    display: flex;
    flex-direction: column;     /* 위(Header) -> 아래(Body) */
    overflow: hidden;           /* 넘침 방지 */
    padding: 0 20px 20px;       /* 페이지 전체 여백 */
}

/* 1. 상단 컨트롤 패널 (헤더) */
.page-header {
    flex-shrink: 0;             /* 높이 고정 */
    height: 50px;               /* 헤더 높이 */
    display: flex;
    align-items: center;        /* 수직 중앙 정렬 */
}

/* [추가] 헤더 내부 컨트롤 그룹 (라벨 + 입력창 세트) */
.page-header > div {
    display: flex;
    align-items: center;
    gap: 0; /* 라벨과 입력창 사이 틈 없애기 */
}

/* 헤더 내부 라벨 스타일 (회색 배경) */
.page-header label {
    font-size: 13px;
    height: 32px;
    background-color: #edeff1;
    color: #333;
    border: 1px solid #ccc;
    border-right: none;         /* 오른쪽 테두리 제거 (입력창과 연결) */
    border-radius: 4px 0 0 4px; /* 왼쪽만 둥글게 */
    padding: 0 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    margin: 0;
}

/* 헤더 내부 입력창/선택박스 스타일 (흰색 배경) */
.page-header select,
.page-header .form-input {
    font-size: 13px;
    height: 32px;
    border: 1px solid #ccc;
    border-radius: 0 4px 4px 0; /* 오른쪽만 둥글게 */
    padding: 0 8px;
    font-family: inherit;
    outline: none;
    background-color: white;
    margin: 0;
    box-sizing: border-box;
    text-align: center;    
}

/* 입력창 포커스 효과 (변수 사용 + 그림자 효과 통합) */
.page-header input:focus,
.page-header select:focus {
    /* 1. 색상은 테마 변수를 따라가도록 설정 */
    border-color: var(--accent-blue, #3498db);
    
    /* 2. 라벨과 겹칠 때 테두리가 위로 오도록 설정 */
    z-index: 1;
    
    /* 3. 살짝 안쪽 그림자를 줘서 깊이감 추가 (기존 디자인 유지) */
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

/* [추가] 헤더 내부 버튼 그룹 예외 처리 (gap: 0을 덮어씀) */
.page-header .btn-container {
    display: flex;
    align-items: center;
    gap: 8px !important; /* 버튼끼리는 적당히 떨어져야 함 */
}

/* 페이지 본문 (패널들이 놓이는 곳) */
.page-body {
    flex: 1;                /* 헤더 제외한 나머지 높이 꽉 채움 */
    width: 100%;
    display: flex;          /* 패널들을 가로(Row)로 배치 */
    gap: 15px;              /* 좌우 패널 사이 간격 */
    overflow: hidden;       /* 내부 패널이 튀어나가지 않게 단속 */
    min-height: 0;          /* [중요] Flexbox 중첩 스크롤 버그 방지용 */
}

/* 3. 콘텐츠 패널 (하얀 박스) */
.panel-frame {
    display: flex;
    flex-direction: column;     /* 위(Header) -> 아래(Body) */
    height: 100%;               /* 부모(.page-body) 높이를 꽉 채움 */
    background: white;
    border-radius: 8px;         /* 둥근 모서리 */
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    overflow: hidden;           /* 자식 요소가 둥근 모서리 침범 못하게 */
}

.panel-header {
    height: 60px;               /* 높이 고정 (모든 패널 통일) */
    flex-shrink: 0;             /* 줄어들지 않음 */
    display: flex;
    justify-content: space-between; /* 양끝 정렬 */
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid #eee;
    background: #fff;
    gap: 10px;                  /* 내부 요소 간격 */
}

/* 2. 패널 바디 (가변 영역 + 스크롤) */
.panel-body {
    flex: 1;                    /* 헤더 제외한 나머지 공간 채움 */
    overflow-y: auto;           /* 내용 넘치면 여기서 스크롤 */
    position: relative;
    padding: 0;                 /* 내부 여백 제거 (테이블 등 꽉 차게) */
}

/* 유틸리티: 꽉 채우기 */
.flex-fill {
    flex: 1;
    min-height: 0; /* 스크롤 버그 방지용 */
}

/* ------------------------------------------------------------
   C. 모달 시스템 (Modal Structure)
   ------------------------------------------------------------ */
/* 1. 배경 (Overlay) */
.modal-overlay {
    display: none; /* [중요] 기본값은 반드시 none 이어야 합니다! */
    position: fixed;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    
    /* display: flex는 지우고, 정렬 속성만 남겨둡니다. 
       (나중에 JS가 display: flex로 바꿀 때 이 정렬 속성이 작동합니다) */
    align-items: center;     
    justify-content: center; 
    
    /* 시각적 중앙 보정 */
    padding-bottom: 10vh;   
    box-sizing: border-box; 

    backdrop-filter: blur(2px);
}

/* 등장 애니메이션 */
@keyframes modalFadeIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-frame {
    background: white;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    position: relative;
    max-height: 85vh; /* 화면 높이의 90%를 넘지 않음 */
    overflow: hidden; /* 둥근 모서리 유지 */
    animation: modalFadeIn 0.2s ease-out;
}

/* [추가됨] 모달 및 패널 내부 입력 필드 강제 13px 적용 */
.modal-frame input, 
.modal-frame select,
.panel-body input,
.panel-body select {
    font-size: 13px !important;
}

/* 2. (추가) 중앙 정렬이 필요한 화면용 스타일 */
/* 로그인 화면처럼 가운데 정렬이 필요할 때만 사용합니다 */
.layout-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px; /* 여백도 여기서 처리 */
}

/* 한 줄에 배치하는 컨테이너 */
.place-one-row {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: center; 
}

/* 균등하게 나뉘는 열 */
.even-col {
    flex: 1;
}

/* [추가] 테이블 포커스 컨테이너 (panel-frame과 동일한 기본 속성 + 테이블 전용) */
.table-focus-container {
    display: flex;
    flex-direction: column;     
    height: 100%;               
    background: white;
    border-radius: 8px;         
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    overflow: hidden;          
}

/* [추가] 모달 하단 영역 */
.modal-footer {
    flex-shrink: 0; /* 크기 고정 */
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #fdfdfd;
}

/* [수정] 모달 내부 폼 레이아웃 (입력창 좁게, 설명 넓게) */
.row-group {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.row-group:last-child { border-bottom: none; }

.label-col { 
    width: 140px;           /* 라벨 너비 약간 확보 */
    font-weight: 600; 
    font-size: 13px; 
    color: #2c3e50;
    flex-shrink: 0;         /* 줄어들지 않음 */
}

.input-col { 
    width: 340px;           /* [핵심] 입력 필드 영역을 고정 너비로 제한 */
    padding-right: 15px; 
    flex-shrink: 0;         /* 줄어들지 않음 */
    display: flex;          /* 내부 요소 정렬 */
    align-items: center;
    gap: 5px;               /* 인풋 사이 간격 */
    font-size: 13px;        /* 텍스트 사이즈 명시 */
}

.desc-col { 
    flex: 1;                /* [핵심] 나머지 공간을 모두 차지하여 넓게 표시 */
    font-size: 13px;        /* 폰트 크기 살짝 키움 (가독성) */
    color: #7f8c8d; 
    line-height: 1.4; 
    word-break: keep-all;   /* 단어 단위 줄바꿈 */
    background-color: #f9f9f9; /* (선택사항) 설명 영역 배경색 추가하여 구분 */
    padding: 5px 10px;      /* (선택사항) 여백 추가 */
    border-radius: 4px;     /* (선택사항) 둥근 모서리 */
}

/* --- [수정] ALV 설정 모달 (공통) --- */
.alv-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); z-index: 1000;
    display: flex; justify-content: center; align-items: flex-start; /* 상단 정렬 */
    padding-top: 100px; /* 위치 조정 */
}

.alv-modal-container {
    background: #fff; 
    width: 750px; /* [변경] 필터 입력 공간 확보를 위해 너비 확대 (기존 500px -> 750px) */
    padding: 20px;
    border-radius: 5px; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    font-size: 13px;
    display: flex; flex-direction: column;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.alv-modal-header {
    font-weight: bold; font-size: 15px; margin-bottom: 15px;
    border-bottom: 1px solid #ddd; padding-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
}

.alv-sort-row {
    display: flex; gap: 8px; margin-bottom: 10px; align-items: center;
    background: #f8f9fa; /* 행 구분감 추가 */
    padding: 5px;
    border-radius: 4px;
}

.alv-select {
    padding: 5px; border: 1px solid #ccc; border-radius: 3px; font-size: 13px;
}

/* [추가] 필터 입력창 영역 */
.alv-filter-box {
    flex: 1; /* 남은 공간을 필터가 차지 */
    display: flex; align-items: center; gap: 5px;
}
.alv-input-mini {
    width: 80px; padding: 5px; border: 1px solid #ddd; border-radius: 3px; font-size: 13px;
}
.alv-input-text {
    width: 100%; padding: 5px; border: 1px solid #ddd; border-radius: 3px; font-size: 13px;
}