/* =========================================
   [1. 전역 테마 설정 및 변수]
   ========================================= */
:root {
    --bg-dark: #1f2029;
    --card-bg: #2a2b38;
    --text-color: #c4c3ca;
    --text-white: #ffffff;
    
    /* 고급스러운 포인트 컬러 */
    --point-gold: #ffeba7;
    --accent-blue: #102770;
    --danger-red: #ff4444;
    --success-green: #00e676;
    
    /* 은은한 테두리 색상 */
    --border-color: rgba(255, 235, 167, 0.15); 
    --glass-border: 1px solid var(--border-color);
}

/* =========================================
   [2. 기본 레이아웃 & 배경]
   ========================================= */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--bg-dark);
    /* 고급스러운 패턴 배경 적용 */
    background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1462889/pat.svg');
    background-position: center;
    background-repeat: repeat;
    background-size: 300%;
    color: var(--text-color);
    font-family: 'Poppins', 'BMDOHYEON', sans-serif;
    
    /* 페이지 페이드인 효과 */
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    overflow: hidden; /* 스크롤은 content-area에서 처리 */
}

body.fade-out { opacity: 0; }

a { color: inherit; text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--point-gold); }

.page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    backdrop-filter: blur(2px); /* 배경 흐림 효과 */
}

.content-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 상단 정렬로 변경 */
    padding: 20px;
    overflow-y: auto; /* 스크롤 허용 */
    width: 100%;
    position: relative;
}

/* =========================================
   [3. 헤더 & 푸터 (높이 고정 & 디자인 통일)]
   ========================================= */
.main-header,
.main-footer {
    height: 70px; /* 높이 고정 */
    background: rgba(31, 32, 41, 0.95);
    border-bottom: var(--glass-border);
    box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.3);
    padding: 0 30px; /* 상하 0, 좌우 30px */
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    flex-shrink: 0;
    position: relative;
    box-sizing: border-box;
}

.main-footer {
    border-top: var(--glass-border);
    border-bottom: none;
}

/* 내부 요소 정렬 */
.header-left, .header-right, 
.footer-left, .footer-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}
.header-right, .footer-right { justify-content: flex-end; }

.header-center, .footer-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    gap: 15px;
}

/* 헤더 타이틀 폰트 */
.header-center .common-box {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--point-gold);
    font-family: 'Poppins', 'BMDOHYEON', sans-serif;
    font-weight: 800;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 2px;
    text-transform: uppercase;
    pointer-events: none;
}

/* 시계 폰트 */
.time-display {
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 1rem !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* 반응형 헤더 */
@media (max-width: 768px) {
    .main-header, .main-footer {
        height: auto;
        padding: 15px 20px;
        flex-direction: column;
        gap: 10px;
    }
    .header-center, .footer-center {
        position: static; transform: none; margin-bottom: 10px;
    }
}

/* =========================================
   [4. 공통 UI 컴포넌트 (버튼, 박스)]
   ========================================= */
/* 기본 박스 & 버튼 스타일 */
.common-box, .footer-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 7px 18px;
    border-radius: 30px; /* 둥근 버튼 */
    font-weight: bold;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    font-family: 'BMJUA', sans-serif;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

/* 호버 효과 (금색 배경 + 남색 글씨) */
.common-box:hover, .footer-btn:hover, .clickable-box:hover {
    background-color: var(--point-gold) !important;
    color: var(--accent-blue) !important;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(255, 235, 167, 0.4);
    transform: translateY(-2px);
}

/* 클릭 효과 */
.clickable-box:active, .footer-btn:active {
    transform: translateY(1px);
}

/* 관리자 버튼 전용 (index.html) */
.admin-custom-btn { color: var(--point-gold) !important; }
.admin-custom-btn:hover { color: var(--accent-blue) !important; background: var(--point-gold) !important; }

/* 폰트 유틸리티 */
.font-45pt { font-size: 3rem; }
.font-35pt { font-size: clamp(25px, 3.5vw, 35px); }
.font-15pt { font-size: clamp(13px, 1.2vw, 18px); }

/* 그리드 레이아웃 */
.grid-container { display: grid; gap: 20px; }
.grid-layout-2-col { grid-template-columns: repeat(2, 1fr); }
.grid-layout-3-col { grid-template-columns: repeat(3, 1fr); }

/* =========================================
   [5. 생산/주차별 UI 요소 (기존 기능 보존 + 디자인 UP)]
   ========================================= */
.week-box {
    font-family: 'BMJUA', sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    background: linear-gradient(145deg, #2a2b38, #23242d); /* 그라데이션 배경 */
    color: #c4c3ca;
    padding: 20px 10px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.week-box:hover {
    background: var(--point-gold);
    color: var(--accent-blue);
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(255, 235, 167, 0.3);
    border-color: transparent;
}

.week-box.current-week {
    border-color: var(--point-gold);
    box-shadow: 0 0 10px rgba(255, 235, 167, 0.2);
    color: var(--point-gold);
}

/* =========================================
   [6. 모달 (Modal) 스타일]
   ========================================= */
.modal-overlay, .dropup-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: none; justify-content: center; align-items: center;
    z-index: 1000;
}

.dropup-overlay { align-items: flex-end; z-index: 999; }

.modal-overlay.visible, .dropup-overlay.visible { display: flex; animation: fadeInOverlay 0.3s forwards; }

/* [common.css 수정] */
.modal-window {
    background-color: #23242d;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    width: 95vw;
    max-width: 1400px;
    
    /* 기존 height: 90vh; 를 아래와 같이 변경하여 유동적으로 조절 */
    height: auto !important; 
    max-height: 90vh; /* 화면 높이의 90%를 넘지 않도록 제한 */
    
    position: relative;
    display: flex;
    flex-direction: column;
    color: #fff;
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dropup-content {
    background-color: #23242d; width: 100%; max-width: 1200px; padding: 20px;
    border-top-left-radius: 20px; border-top-right-radius: 20px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

.modal-title {
    color: var(--point-gold);
    font-size: 1.5rem;
    padding: 15px 20px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'BMJUA', sans-serif;
}

.modal-content {
    flex-grow: 1; display: flex; flex-direction: column; gap: 20px;
    padding: 20px; overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}

.close-btn {
    position: absolute; top: 15px; right: 20px;
    font-size: 2rem; color: #888; cursor: pointer;
    border: none; background: none; z-index: 10; transition: color 0.2s;
}
.close-btn:hover { color: var(--point-gold); }

/* 모달 애니메이션 */
@keyframes fadeInOverlay { from { background-color: rgba(0,0,0,0); } to { background-color: rgba(0,0,0,0.85); } }
@keyframes modalSlideUp { from { opacity: 0; transform: translateY(30px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* 다운로드 선택 작은 모달 */
.small-modal {
    max-width: 350px; height: auto; padding: 0;
}
.small-modal .modal-content { flex-grow: 0; }
.choice-buttons { display: flex; flex-direction: column; gap: 15px; padding: 20px; }
.choice-buttons .common-box { width: 100%; box-sizing: border-box; justify-content: center; padding: 12px; }

/* =========================================
   [7. 테이블 스타일 (고급 테마 적용)]
   ========================================= */
.table-container {
    flex: 1; min-height: 0; overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    background-color: rgba(0,0,0,0.2);
}

table.editable-table {
    width: 100%; border-collapse: collapse; font-family: inherit; table-layout: fixed;
}

.editable-table th, .editable-table td {
    padding: 8px 6px; text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-size: clamp(11px, 1.1vw, 14px);
}

.editable-table th {
    background-color: #1a1b23;
    color: var(--point-gold);
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 2px solid rgba(255, 235, 167, 0.2);
    position: sticky; top: 0; z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.editable-table tbody tr:hover {
    background-color: rgba(255, 235, 167, 0.05);
}

/* 테이블 인풋/셀렉트 */
.editable-table input, .editable-table select {
    width: 100%; height: 100%; padding: 5px;
    background: transparent; border: 1px solid transparent;
    color: #fff; font-family: 'Poppins', 'BMJUA';
    text-align: center; border-radius: 4px;
}
.editable-table input:focus, .editable-table select:focus {
    outline: none; background-color: #15151a; border-color: var(--point-gold);
}

/* 생산 모달 내부 섹션 */
.line-schedule-section {
    background-color: var(--card-bg);
    border-radius: 10px; padding: 10px 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 10px; display: flex; flex-direction: column; min-height: 0;
}

.line-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.line-title {
    font-family: 'BMDOHYEON', sans-serif;
    font-size: 1.3rem; color: #fff; margin: 0;
    display: flex; align-items: center; gap: 10px;
}
.line-title::before {
    content: ''; display: block; width: 4px; height: 16px;
    background-color: var(--point-gold); border-radius: 2px;
}

/* 버튼들 */
.text-btn { 
    background: #3a3a3c; border: 1px solid #555; color: #fff; 
    font-size: 0.85rem; font-family: 'BMJUA'; cursor: pointer; 
    padding: 4px 10px; border-radius: 4px; transition: all 0.2s;
}
.text-btn:hover { background: #555; color: var(--point-gold); }

.icon-btn {
    background: #3a3a3c; border: 1px solid #555; color: #fff;
    width: 30px; height: 30px; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.icon-btn:hover { background: #555; color: var(--point-gold); }

.reset-btn { background-color: #5a1a1a !important; border-color: #ff4444 !important; }
.reset-btn:hover { background-color: #8b0000 !important; }

/* =========================================
   [8. 기타 유틸리티 및 로고]
   ========================================= */
.svg-sprite { position: absolute; width: 0; height: 0; }
.header-logo-wrapper { position: relative; display: flex; align-items: center; cursor: pointer; }
.header-logo { height: 35px; width: auto; fill: var(--point-gold); transition: fill 0.2s ease; filter: drop-shadow(0 0 5px rgba(255, 235, 167, 0.4)); }
.header-logo-wrapper.btn-glitch-active .header-logo { fill: #ffffff; filter: url('#filter'); }

/* 유효성 검사 메시지 */
.validation-message {
    position: absolute; top: -28px; left: 0; width: 100%;
    background-color: var(--danger-red); color: white;
    padding: 2px 5px; border-radius: 4px; text-align: center;
    font-size: 0.75rem; opacity: 0; visibility: hidden;
    transition: opacity 0.3s; pointer-events: none; z-index: 10;
}
.validation-message.visible { opacity: 1; visibility: visible; }

/* =========================================
   [8. 캘린더 팝업 (이전 데이터) - 미니 & 주간 선택]
   ========================================= */
.custom-calendar-popup {
    position: absolute;
    bottom: 120%;
    right: 0;
    width: 280px; /* [수정] 너비 축소 (340 -> 280) */
    
    background-color: rgba(42, 43, 56, 0.98);
    border: 1px solid var(--point-gold);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    
    padding: 15px; /* [수정] 패딩 축소 */
    z-index: 2000;
    display: none;
    font-family: 'BMDOHYEON', sans-serif;
    backdrop-filter: blur(10px);
    
    animation: popupSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

.custom-calendar-popup.visible { display: block; }

@keyframes popupSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 헤더 (년월) */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: var(--point-gold);
    font-size: 1.1rem; /* [수정] 폰트 축소 */
    padding: 0 5px;
}

.calendar-nav-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    width: 28px; /* [수정] 버튼 크기 축소 */
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.calendar-nav-btn:hover {
    background-color: var(--point-gold);
    color: var(--accent-blue);
    border-color: var(--point-gold);
}

/* 요일 헤더 */
.calendar-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 5px;
    color: #888;
    font-size: 0.75rem; /* [수정] 폰트 축소 */
    font-family: 'Poppins', sans-serif;
}

/* 날짜 그리드 */
.calendar-body {
    display: flex;
    flex-direction: column;
    gap: 2px; /* 행 간격 좁힘 */
}

/* [핵심 수정] 주(Week) 단위 스타일 */
.calendar-week-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    border-radius: 6px;
    cursor: pointer; /* 행 전체에 포인터 */
    transition: all 0.2s;
    padding: 2px 0;
}

/* 마우스 올렸을 때 행 전체 하이라이트 */
.calendar-week-row:hover {
    background-color: var(--point-gold);
    transform: scale(1.02);
    box-shadow: 0 4px 10px rgba(255, 235, 167, 0.2);
}

/* 날짜 셀 */
.day-cell {
    height: 30px; /* [수정] 높이 축소 (38 -> 30) */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem; /* [수정] 폰트 축소 */
    pointer-events: none; /* 클릭 이벤트를 부모(Row)가 받도록 통과시킴 */
}

/* 호버 시 글자색 반전 (남색) */
.calendar-week-row:hover .day-cell {
    color: var(--accent-blue);
    font-weight: bold;
}

/* 일요일 */
.day-cell.sunday { color: var(--danger-red); }

/* 오늘 */
.day-cell.today {
    border: 1px solid var(--point-gold);
    border-radius: 50%;
}
.calendar-week-row:hover .day-cell.today {
    border-color: var(--accent-blue);
}

/* 이전/다음 달 */
.day-cell.other-month { opacity: 0.3; }

.month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px 0;
}

/* 월 선택 셀 */
.month-cell {
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    background-color: var(--card-bg); /* 기본 배경 */
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.month-cell:hover {
    background-color: #3a3a3c;
}

/* 선택된 월 스타일 */
.month-cell.selected-start {
    background-color: var(--point-gold) !important;
    color: var(--accent-blue) !important;
    font-weight: bold;
}

.month-cell.in-range {
    background-color: rgba(255, 235, 167, 0.2) !important;
}

/* 기간 선택 버튼 텍스트가 길어질 경우 대비 */
.aoi-controls .footer-btn span {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 뷰 컨테이너 조정 */
.admin-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 40px;
    overflow: hidden;
}