/* =================================================================
           saju_board.css - 명조 원국 격자판, 타임라인 테이블 및 간지 속성 스타일
           ================================================================= */

/* 🌟 카드가 끈끈이(Sticky) 자식을 품고 있을 때 스크롤 고정이 무효화되는 버그(overflow: hidden 충돌) 방어 */
.wide-card:has(.is-sticky), 
.wide-card.is-sticky {
    overflow: visible !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
}

/* 🌟 고정 해제 시 JS의 인라인 스타일 찌꺼기(left: 0 등)로 인해 좌측으로 쏠리는 현상 원천 봉쇄 */
.wide-card,
#wonguk-master-card,
#saju-container {
    left: auto !important;
    right: auto !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* 🌟 원국 컨테이너가 항상 독립적인 카드(흰색 배경, 테두리)처럼 보이도록 스타일 완벽 복구 */
.sticky-saju-container {
    background: #ffffff !important;
    padding: 15px 10px 10px 10px !important;
    margin: 0 auto 15px auto !important; /* 🌟 완벽한 중앙 정렬 강제 보장 */
    border: none !important;
    border-radius: 16px !important;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.05), 0 2px 10px rgba(15, 23, 42, 0.02) !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    flex: 1 1 100% !important; /* 🌟 Flexbox 내부일 경우 가로폭 찌그러짐 완벽 방어 */
    align-self: stretch !important; /* 🌟 Flex 정렬 시 좌측 쏠림 원천 차단 */
    transition: box-shadow 0.3s, background 0.3s, top 0.3s ease;
    position: relative;
    z-index: 100;
}

/* 🌟 고정(Pin) 상태일 때 좌측 쏠림을 막고, 둥둥 뜬 효과 부여 및 배경 투명화 방지 */
.wide-card.is-sticky,
#saju-container.is-sticky,
.sticky-saju-container.is-sticky {
    position: sticky !important; /* JS가 fixed로 강제 변환해도 sticky로 덮어써서 부모 밖 이탈 방지 */
    top: 0 !important;
    left: auto !important;
    right: auto !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 1000 !important;
    background: #ffffff !important; /* 스크롤 시 뒷배경이 비치지 않도록 흰색 강제 */
    box-shadow: 0 12px 30px rgba(31, 72, 110, 0.15), 0 4px 8px rgba(31, 72, 110, 0.05) !important;
    outline: 4px solid #3498db !important; /* 🌟 고정 상태일 때 항상 포커스 외곽선 유지 */
    outline-offset: 0px !important;
}

.pin-btn {
    position: fixed;
    bottom: 110px;
    right: 40px;
    z-index: 1000;
    background: #f6860f;
    color: white;
    padding: 16px 24px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(44, 62, 80, 0.25);
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.pin-btn:hover { background: #1a252f; transform: translateY(-2px); box-shadow: 0 12px 30px rgba(44, 62, 80, 0.35); }
.pin-btn.active { background: #e67e22 !important; color: white !important; box-shadow: 0 10px 25px rgba(230, 126, 34, 0.35) !important; }
.pin-btn.active:hover { background: #d35400 !important; }

/* 유연한 타임라인 가로 스크롤 영역 */
.table-wrapper {
    width: 100%;
    max-width: 100%; /* 🌟 테이블이 카드 밖으로 삐져나가는 현상 원천 차단 */
    margin: 0 auto; /* 🌟 스크롤 래퍼 중앙 정렬 */
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 15px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y pinch-zoom;
    border: 2px solid transparent;
    transition: border-color 0.3s, box-shadow 0.3s;
    border-radius: 8px;
    box-sizing: border-box; /* 🌟 여백 계산 꼬임 방지 */
    display: block;
}

/* 🌟 가로 스크롤바 모던 화이트 그라데이션 렌더링 */
.table-wrapper::-webkit-scrollbar { height: 12px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }
.table-wrapper::-webkit-scrollbar-thumb { background: linear-gradient(145deg, #ffffff 0%, #cbd5e1 100%); border: 3px solid transparent; background-clip: padding-box; border-radius: 10px; box-shadow: inset 0 1px 4px rgba(15,23,42,0.1); }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: linear-gradient(145deg, #ffffff 0%, #94a3b8 100%); border: 3px solid transparent; background-clip: padding-box; }
.table-wrapper.keyboard-focused {
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.2);
}

/* 🌟 원국 테이블 운세 헤더 포커스 시 효과 */
th.keyboard-focused {
    box-shadow: inset 0 0 0 2px #3498db !important;
    background-color: #d6f3ec !important; /* 포커스 시 배경색 강조 */
    position: relative;
    z-index: 10;
}

/* 🌟 풀페이지 네비게이션용 일반 섹션 포커스 효과 */
.keyboard-focused-section {
    outline: 4px solid #3498db !important; /* 🌟 카드 고유의 box-shadow와 충돌하여 포커스가 묻히는 현상 원천 차단 */
    outline-offset: 0px !important;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.3) !important;
    transition: all 0.2s ease;
    z-index: 20 !important;
}

/* 🌟 [레이아웃 교정] 원국 타이틀 및 옵션바와 만세력 테이블 간의 공백 밀착 조절 */
#saju-table-container {
    position: relative;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important; /* 🌟 테이블 컨테이너 중앙 정렬 */
    box-sizing: border-box !important;
    padding: 4px 0 12px 0; /* 🌟 기존 30px 0에서 상단 4px, 하단 12px로 여백 전격 압축 */
    z-index: 10;
}
.scroll-rtl { direction: rtl; }
.scroll-rtl table { direction: rtl; }
.scroll-rtl th, .scroll-rtl td { direction: ltr; }

table { width: 100%; border-collapse: collapse; text-align: center; min-width: max-content; margin: 0 auto; /* 🌟 테이블 자체 중앙 정렬 */ }
th, td { border: 1px solid #dcdde1; padding: 12px 10px; }
th { background-color: #f1f2f6; font-weight: bold; color: #2f3640; }

/* 🌟 원국 테이블 전용 가변폭(Flexible) 설정: 스크롤 없이 화면 너비에 꽉 차게 반응 */
#main-saju-table {
    min-width: 100% !important;
    width: 100% !important;
    table-layout: fixed; /* 셀의 너비를 1/n로 균등하게 분배 */
}
#main-saju-table th, #main-saju-table td {
    padding: 8px 2px; /* 좁아진 폭에 맞춰 좌우 여백 최소화 */
    word-wrap: break-word; /* 글자가 셀 폭을 넘으면 자동 줄바꿈 허용 */
    white-space: normal;
}
/* 그룹 사이를 띄워주는 여백용 투명 셀(공백)의 폭을 최소화하여 데이터 셀 공간 확보 */
#main-saju-table th[style*="border: none"],
#main-saju-table td[style*="border: none"] {
    width: 6px !important;
    min-width: 6px !important;
    padding: 0 !important;
}

/* 상호작용 셀렉터 간섭망 시각 상태 피드백 */
.interactive-cell { cursor: pointer; position: relative; transition: background-color 0.2s ease, outline 0.2s ease; border-radius: 0; z-index: 5; }
.interactive-cell:hover { background-color: #f1f2f6; outline: 2px solid #dcdde1; outline-offset: -2px; z-index: 10; }
.interactive-cell.active-cell { background-color: #ffeaa7 !important; outline: 2px solid #f39c12 !important; outline-offset: -2px; z-index: 20; }
.interactive-cell.target-cell { background-color: #e8f8f5 !important; outline: 3px solid #1abc9c !important; outline-offset: -3px; z-index: 15; }
.interactive-cell.flow-disperse { background-color: transparent !important; outline: 3px solid #e67e22 !important; outline-offset: -3px; z-index: 12; }
.interactive-cell.flow-concentrate { background-color: transparent !important; outline: 3px solid #3498db !important; outline-offset: -3px; z-index: 12; }
.interactive-cell.flow-mixed { background-color: transparent !important; outline: 3px dashed #9b59b6 !important; outline-offset: -3px; z-index: 15; }
.active-col, .active-year, .active-wolwun { background-color: #ffeaa7 !important; font-weight: bold; border: 3px solid #e17055 !important; color: #d35400; }

/* 정통 오행 전용 지정 컬러 스키마 */
.elem-木 { color: #27ae60; }
.elem-火 { color: #e74c3c; }
.elem-土 { color: #d35400; }
.elem-金 { color: #7f8c8d; }
.elem-水 { color: #2980b9; }

/* 폰트 구조화 */
.hanja { font-size: 1.8em; font-weight: bold; font-family: 'Batang', 'Nanum Myeongjo', serif; line-height: 1.3; }
.main-saju .hanja { font-size: 2.6em; font-weight: 900; }
.shibsang { font-size: 0.9em; font-weight: bold; color: #576574; }
.jijanggan { font-size: 0.95em; font-weight: bold; color: #6c5ce7; letter-spacing: 1px; }
.special-shinsal-cell { font-size: 0.8em; color: #7f8c8d; max-width: 80px; white-space: normal; line-height: 1.3; padding: 6px 2px; }

/* 🌟 운세 네비게이션 화살표 호버 효과 */
.nav-arrow {
    transition: transform 0.15s ease, color 0.15s ease;
    display: inline-block;
}
.nav-arrow:hover {
    color: #e67e22;
    transform: scale(1.3);
}

/* 컨트롤 패널 필터 보드 박스 */
.saju-options-panel { background: #fcfdfd; border: 1px solid #dcdde1; border-radius: 8px; padding: 14px 16px; margin-bottom: 20px; box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.01); display: flex; flex-direction: column; gap: 8px; }
.options-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.options-row:last-child { margin-bottom: 0; }
.options-label { width: auto; min-width: 126px; padding: 0 12px; height: 30px; font-weight: 800; color: #475569; background: #e2e8f0; border-radius: 10px; font-size: 0.85em; border: 1px solid #cbd5e1; display: flex; justify-content: center; align-items: center; flex-shrink: 0; box-sizing: border-box; }
.filter-label { width: 126px; height: 30px; font-weight: 800; color: #475569; background: #e2e8f0; border-radius: 10px; font-size: 0.85em; border: 1px solid #cbd5e1; display: flex; justify-content: center; align-items: center; flex-shrink: 0; margin-right: 0; padding: 0; box-sizing: border-box; }
.filter-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 0; }
.filter-items { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; flex: 1; min-height: 28px; }
.filter-row:last-child { margin-bottom: 0; }
.options-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* 🌟 은은하고 연한 무채색 톤의 스쿼클 칩 버튼으로 변경 (배경색을 없애고 텍스트 대비로만 켜짐/꺼짐 표현) */
.custom-cb-label { display: inline-flex; justify-content: center; align-items: center; background: #ffffff; padding: 0 4px; width: 126px; height: 30px; box-sizing: border-box; border-radius: 10px; border: 1px solid #e2e8f0; cursor: pointer; font-size: 0.85em; font-weight: 600; transition: all 0.2s ease; color: #94a3b8; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02); user-select: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.custom-cb-label:hover { background: #f8fafc; color: #64748b; border-color: #cbd5e1; transform: translateY(-1px); box-shadow: 0 3px 6px rgba(15, 23, 42, 0.04); }
.custom-cb-label:active { transform: scale(0.97); } /* 클릭 시 쫀득한 물리적 피드백 */
.custom-cb-label input { display: none; }
.custom-cb-label:has(input:checked) { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; font-weight: 800; box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.05); }
.custom-cb-label:has(input:checked):hover { background: #e2e8f0; border-color: #94a3b8; }
.custom-cb-label:has(input:checked):active { transform: scale(0.97); }

/* 🌟 우측 슬라이더 내부 필터 패널 보정 (버튼 섞임 방지 및 자연스러운 가로 정렬) */
#module-tools-content .saju-options-panel { background: transparent; border: none; padding: 0; margin-bottom: 0; box-shadow: none; display: flex; flex-direction: column; gap: 15px; }
#module-tools-content .filter-row { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 0; border-bottom: 1px dashed #cbd5e1; padding-bottom: 15px; gap: 6px; }
#module-tools-content .filter-row:last-child { border-bottom: none; padding-bottom: 0; }
#module-tools-content .filter-label { width: 100%; text-align: left; margin-bottom: 6px; background: transparent; border: none; padding: 0; color: #1e293b; font-size: 0.95em; }
#module-tools-content #line-filter-controls { margin: 0; padding: 0; border: none; background: transparent; }
#module-tools-content .options-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#module-tools-content .options-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* 🌟 [관계선 복구] 만세력 격자판 위에 마찰/간섭망 선을 투명하게 오버레이하는 도화지 레이아웃 */
#interaction-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 500;
    overflow: visible;
}

/* 통근(Rooting) 효과 적용 시 부드러운 전환 효과 */
.tonggeun-root { transition: background-color 0.3s ease, color 0.3s ease; border-radius: 4px; }


/* =================================================================
   🌟 특수 뱃지 (격국/용신/희신) UI 컴포넌트
   ================================================================= */
.saju-badge {
    /* 디자인 속성 (운세 뱃지와 완벽 통일, 위치는 JS 컨테이너가 제어) */
    display: inline-block;
    font-size: 0.4em;        /* 운세 뱃지와 크기 통일 (0.4em) */
    font-weight: 900;
    font-family: 'Malgun Gothic', sans-serif;
    padding: 2px 4px;        /* 운세 뱃지와 여백 통일 */
    border-radius: 3px;      /* 운세 뱃지와 둥글기 통일 */
    line-height: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    cursor: help;            /* 마우스 오버 시 툴팁을 위해 헬프 커서 적용 */
    transition: transform 0.2s;
}

/* 마우스 오버 시 효과 및 색상 스타일은 그대로 유지 */
.saju-badge:hover { transform: scale(1.1); }

/* 🌟 격국 뱃지 (파스텔톤 옐로우) */
.badge-gyuk { background-color: rgba(245, 158, 11, 0.15); color: #d97706; border: 1px solid #d97706; }
/* 🌟 용신 뱃지 (파스텔톤 레드) */
.badge-yong { background-color: rgba(225, 29, 72, 0.15); color: #e11d48; border: 1px solid #e11d48; }
/* 🌟 희신 뱃지 (파스텔톤 그린) */
.badge-hee { background-color: rgba(16, 185, 129, 0.15); color: #059669; border: 1px solid #059669; }

/* =================================================================
   🌟 격국·용신 셀 전체 하이라이트 효과 (은은한 파스텔 글로우)
   ================================================================= */
.highlight-yong { background-color: rgba(225, 29, 72, 0.06) !important; box-shadow: inset 0 0 0 2px rgba(225, 29, 72, 0.3) !important; transition: all 0.3s ease; }
.highlight-hee { background-color: rgba(16, 185, 129, 0.06) !important; box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.3) !important; transition: all 0.3s ease; }
.highlight-gyuk { background-color: rgba(139, 92, 246, 0.06) !important; box-shadow: inset 0 0 0 2px rgba(139, 92, 246, 0.3) !important; transition: all 0.3s ease; }

/* =================================================================
   🌟 타임라인 운세 뱃지 전용 클래스 모음 (JS 인라인 스타일 제거)
   ================================================================= */
.timeline-badge-container {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
}

.badge-gaedu, .badge-jeolgak { background-color: rgba(71,85,105,0.15); color: #334155; border: 1px solid #334155; }
.badge-ganjidong { background-color: rgba(100,116,139,0.15); color: #475569; border: 1px solid #475569; }
.badge-habgeo { background-color: rgba(225,29,72,0.15); color: #be123c; border: 1px solid #be123c; }
.badge-giban { background-color: rgba(217,119,6,0.15); color: #b45309; border: 1px solid #b45309; }
.badge-ilji-clash { background-color: rgba(190,18,60,0.15); color: #9f1239; border: 1px solid #9f1239; }
.badge-baneum { background-color: rgba(159,18,57,0.15); color: #881337; border: 1px solid #881337; }
.badge-bokum { background-color: rgba(180,83,9,0.15); color: #92400e; border: 1px solid #92400e; }
.badge-samhyeong { background-color: rgba(139,92,246,0.15); color: #6d28d9; border: 1px solid #6d28d9; }
.badge-habguk { background-color: rgba(37,99,235,0.15); color: #1d4ed8; border: 1px solid #1d4ed8; }

/* =================================================================
   🌟 사이드바 공개/비공개 토글 버튼 마우스 오버(Hover) 효과
   ================================================================= */
.visibility-toggle-btn {
    display: inline-block;
    transition: all 0.15s ease-in-out;
}
.visibility-toggle-btn:hover {
    transform: translateY(-1px) scale(1.05);
    filter: brightness(0.92);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* =================================================================
   🌟 숨은 데이터 시각화 (공망/납음오행/특수성격)
   ================================================================= */
.badge-pattern {
    display: inline-flex; align-items: center; gap: 4px;
    background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
    color: #b45309; border: 1px solid #facc15;
    padding: 3px 8px; border-radius: 20px;
    font-size: 0.65em; font-weight: 900; box-shadow: 0 2px 5px rgba(217, 119, 6, 0.15);
    white-space: nowrap; vertical-align: middle;
}
.gongmang-cell { font-size: 0.9em; font-weight: bold; color: #94a3b8; background-color: #f8fafc; letter-spacing: -0.5px; line-height: 1.3; padding: 6px 2px !important; }
.gongmang-cell.is-empty { color: #be123c; background-color: #fff1f2; }
.nabeum-cell { font-size: 0.9em; font-weight: bold; color: #0f766e; background-color: #f0fdfa; letter-spacing: -0.5px; line-height: 1.3; padding: 6px 2px !important; }

/* =================================================================
   🌟 아웃룩 바(Outlook Bar) 공통 컨트롤러 렌더링 스타일
   ================================================================= */
.outlook-group { margin-bottom: 12px; }
.outlook-group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; cursor: pointer; background: #f8fafc;
    border-radius: 10px; color: #334155; font-weight: 800; font-size: 0.9em;
    transition: background 0.2s, box-shadow 0.2s; border: 1px solid #e2e8f0;
}
.outlook-group-header:hover { background: #f1f5f9; color: #0f172a; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.outlook-group-title { font-size: 1.05em; }
.outlook-group-toggle { font-size: 0.8em; color: #94a3b8; }
.outlook-group-items { padding: 6px 0 6px 8px; overflow: hidden; }

.outlook-item {
    display: flex; align-items: center; padding: 12px;
    margin-bottom: 8px; border-radius: 12px; cursor: pointer;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #ffffff; box-shadow: 0 4px 10px rgba(15, 23, 42, 0.03);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.outlook-item:hover {
    transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
}
.outlook-item.active-profile {
    background: linear-gradient(145deg, #ffffff 0%, #eff6ff 100%) !important;
    box-shadow: 0 6px 15px rgba(59, 130, 246, 0.1) !important;
    border-color: #bfdbfe;
}
.outlook-item-icon {
    width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
    background: #f1f5f9; display: flex; justify-content: center; align-items: center;
    overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.06); margin-right: 14px;
}
.outlook-item-content { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; justify-content: center; }
.outlook-item-title { font-size: 1em; font-weight: 800; color: #1e293b; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.outlook-item-subtitle { font-size: 0.8em; color: #64748b; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outlook-item-checkbox { width: 22px; height: 22px; cursor: pointer; accent-color: #0f172a; margin-left: 12px; flex-shrink: 0; border: 1px solid #cbd5e1; border-radius: 4px; }
.outlook-item-empty { padding: 10px 15px; font-size: 0.85em; color: #94a3b8; font-weight: bold; text-align: center; }