/* style.css */
body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #fff;
    /* 어두운 배경으로 금속성 모델/이미지 시인성 확보 */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.split-layout {
    display: flex;
    width: 100vw;
    height: 100dvh;
    align-items: center;
    justify-content: center;
    /* 글로벌 리모컨 공간 확보 */
    box-sizing: border-box;
}

.side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 45vw;
    height: 100dvh;
}

.animation-container {
    position: relative;
    width: 100%;
    /* 좌우 공간을 차지하도록 유동적인 너비 지정 */
    max-width: 600px;
    /* 원본 크기를 초과하지 않도록 설정 */
    aspect-ratio: 1 / 1;
    /* 정사각형 비율 유지 */
    display: flex;
    align-items: center;
    justify-content: center;
    /* 배경 및 테두리를 제거하여 자체 이미지의 테두리와 구멍 부위가 투명하게 보이도록 수정 */
    background-color: transparent;
}

/* 애니메이션 레이어 공통 스타일 */
.layer {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center center;
    /* 정중앙을 기준으로 회전하도록 설정 */
}

/* 이미지 계층 순서 설정 (z-index) */
#inner-plate-left,
#inner-plate-right {
    z-index: 1;
    width: calc(100% - 84px);
}

#pendulum-axis-left {
    z-index: 3;
    height: 1006px;
    margin-top: 15px;
    /* 제일 위 (축) - 밖으로 튀어나와야 함 */
}

#fixed-ring-left,
#fixed-ring-right {
    z-index: 2;
    /* 중간 (고정 덮개) */
}

/* 우측, 좌측 독립적인 컨트롤 구역 공통 컨테이너 */
.ui-container {
    position: absolute;
    bottom: 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 100;
    width: 80%;
    max-width: 400px;
}

/* 컨트롤러 (시작/정지 버튼) 영역 스타일 */
.controls {
    display: flex;
    gap: 15px;
}

/* 컨트롤 버튼 공통 스타일 */
.btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

/* 규칙: 세멘틱한 색상 적용 (성공-초록, 경고/정지-빨강) */
.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-warn {
    background-color: #dc3545;
    color: white;
}

.btn-warn:hover {
    background-color: #c82333;
}

/* UI 숨김 처리를 위한 유틸리티 클래스 */
.hidden {
    display: none !important;
}

/* 최상단 글로벌 스텔스 (체크박스) 컨트롤 창 */
.global-toggles {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    padding: 10px 20px;
    background-color: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    color: #333;
    font-size: 14px;
    z-index: 9999;
    transition: all 0.3s;
}

.global-toggles:hover {
    background-color: rgba(255, 255, 255, 0.9);
}

.global-toggles label {
    cursor: pointer;
    font-weight: bold;
}

/* 좌/우측 반투명 토글 버튼 */
.btn-stealth {
    background-color: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: absolute;
    bottom: 20px;
    right: 0;
}

/* 파라미터 조절 패널 창 */
.settings {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-stealth:hover {
    background-color: rgba(255, 255, 255, 0.9);
    color: #333;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #333;
    /* Changed from #e0e0e0 for better contrast on light background */
}

.setting-item label {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
}

.setting-item input[type="range"] {
    flex: 1.5;
    cursor: pointer;
    accent-color: #28a745;
    /* 슬라이더 스크롤 색상도 세멘틱하게 통일 */
}

/* 우측 패널 히트맵 오버레이 (스크류 마찰 단면 표현) */
#heatmap-right {
    position: absolute;
    width: calc(100% - 24px);
    /* 내부 원형판과 거의 동일한 크기 */
    height: calc(100% - 24px);
    border-radius: 50%;
    pointer-events: none;
    z-index: 4;
    /* 내부 원형판(1)과 고정링(2) 위나 사이에 배치 */
    opacity: 0;
    /* 초기 숨김, JS에서 0 ~ 1 사이로 제어 */

    /* 사용자 요청(구름 모양 히트맵)을 반영하여 불규칙한 위치에 온도가 몰려 있는 효과 구현 */
    background:
        radial-gradient(circle at 20% 30%, rgba(255, 0, 0, 0.8) 0%, rgba(255, 165, 0, 0.5) 20%, transparent 40%),
        radial-gradient(circle at 80% 25%, rgba(255, 50, 0, 0.7) 0%, rgba(255, 200, 0, 0.4) 25%, transparent 50%),
        radial-gradient(circle at 75% 85%, rgba(200, 0, 0, 0.8) 0%, rgba(255, 140, 0, 0.5) 15%, transparent 35%),
        radial-gradient(circle at 30% 75%, rgba(255, 20, 0, 0.75) 0%, rgba(255, 215, 0, 0.4) 30%, transparent 55%),
        radial-gradient(circle at 50% 10%, rgba(255, 0, 0, 0.6) 0%, rgba(255, 100, 0, 0.3) 25%, transparent 45%),
        radial-gradient(circle at 10% 60%, rgba(220, 0, 0, 0.8) 0%, rgba(255, 150, 0, 0.4) 20%, transparent 40%);

    /* 테두리 부근의 마모를 강조하는 블러(box-shadow 유지, 강도 약화) */
    box-shadow: inset 0 0 30px 10px rgba(255, 69, 0, 0.4);

    mix-blend-mode: hard-light;
    /* 금속 재질 위에서 색상이 강하게 먹히도록 수정 */
    filter: blur(8px);
    /* 구름 경계를 부드럽게 퍼지게 만듦 */
    transition: opacity 0.1s;
}

/* ---------------- TCO 대시보드 모달 스타일링 ---------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ---------------- TCO 모달 CSS 강제 재정의 (Bottom Sheet) ---------------- */
.p-dialog.p-dialog-bottom {
    bottom: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    max-height: 50vh !important;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1) !important;
}

.p-dialog-header {
    padding: 1rem 1.5rem !important;
    position: relative;
}

/* 닫기 버튼 우측 배치 최적화 */
.p-dialog-header-icons {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.p-dialog-content {
    padding: 0 !important;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.center-dashboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    width: 60%;
    max-width: 800px;
    max-height: 90vh;
    /* 화면을 넘어가지 않도록 방지 */
    overflow-y: auto;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.dash-title {
    text-align: center;
    margin: 0;
    font-size: 22px;
    color: #2c3e50;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.dash-controls {
    display: flex;
    gap: 20px;
    align-items: center;
}

.tco-graph-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.tco-bar-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tco-label {
    width: 100px;
    font-weight: bold;
    color: #333;
}

.tco-bar-track {
    flex: 1;
    height: 30px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    display: flex;
}

.tco-bar {
    height: 100%;
    transition: width 0.3s ease;
}

.tco-base {
    background-color: #3498db;
    /* 초기 기계값 */
}

.tco-maint {
    background-color: #e74c3c;
    /* 마모 교체/유지보수 비용 */
}

.tco-value {
    width: 60px;
    text-align: right;
    font-weight: bold;
    font-size: 16px;
}

.dash-footer {
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    color: #28a745;
    min-height: 24px;
}

/* ---------------- 애니메이션 알림(경고) 이펙트 ---------------- */
.failure-alert {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 900;
    color: white;
    background: rgba(255, 0, 0, 0.8);
    padding: 10px 20px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    animation: flashAlert 0.5s calc(var(--flash-count, 1) * 3) alternate;
}

@keyframes flashAlert {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 20px red;
    }
}

.tco-bottom-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    background: #fff;
    padding: 20px 40px;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    box-shadow: beige;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}

/* style.css 에 추가해 주세요 (닫기 버튼 우측 상단 고정 및 스타일링) */
.tco-bottom-modal .p-dialog-header-icons {
    position: absolute !important;
    right: 30px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    border: none !important;
}

/* 닫기 버튼 내부 아이콘(X) 박스 깨짐 보정 */
.tco-bottom-modal .p-dialog-header-close {
    width: 2rem !important;
    height: 2rem !important;
    border-radius: 50% !important;
    transition: background-color 0.2s;
    border: none !important;
}

.tco-bottom-modal .p-dialog-header-close:hover {
    background-color: #fce4e4 !important;
    /* 마우스 올렸을 때 옅은 붉은색 */
    color: #d9534f !important;
}

.tco-bottom-modal div[data-pc-section="header"] {
    display: flex;
    justify-content: space-between;
}

.tco-bottom-modal div[data-pc-section="header"] span {
    font-size: 1.675rem;
    font-weight: bold;
    letter-spacing: -0.054em;
}

.tco-bottom-modal div[data-pc-section="header"] button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    border-width: 1px;
}