/* 
 * 온라인 노트패드 & 주사위 점괘 서비스
 * 최적화된 스타일시트
 * 버전: 2.0 (2025)
 */

/* 기본 레이아웃 및 스타일 */
html, body {
    margin: 0;
    height: 100%;
    width: 100%;
    font-family: 'Noto Sans KR', Arial, Helvetica, sans-serif;
    background: #444;
    scroll-behavior: smooth; /* 부드러운 스크롤 효과 */
}

/* 접근성 지원: 탭 포커스 표시 명확하게 */
:focus {
    outline: 3px solid #4C1D95;
    outline-offset: 2px;
}

#header { 
    background: #444;
    height: 57px;
}

.sdiv {
    margin-top: 10px;
    display: inline-block;
    vertical-align: top;
    margin-left: 30px;
    margin-right: 0px;
}

h1 { 
    font-size: medium; 
}

#bread { 
    margin-top: 20px; 
    color: #ddd; 
    font-size: medium;  
}

#bread a { 
    color: #ddd; 
    text-decoration: none; 
    padding: 20px 5px; 
    transition: color 0.3s, background 0.3s; /* 부드러운 전환 효과 */
}

#bread a:hover { 
    color: #fff; 
    background: #444; 
}

#main {
    margin: 0;
    height: 90%;
    height: calc(100% - 170px);
}

/* 노트패드 영역 높이 수정 */
#notepad-content {
    height: 100%;
}

#notepad-content #main {
    height: 100%;
    margin: 0;
}

/* Textarea 스타일 */
textarea, #area {
    height: 100%;
    width: 100%;
    margin: 0;
    padding-top: 3px;
    padding-left: 50px;
    font-family: 'Noto Sans KR', Arial, Helvetica, Sans-serif;
    font-size: large;
    outline: none;
    border: 0;
    resize: none;
    transition: background-color 0.3s; /* 배경색 전환 효과 */
}

.notes {
    color: black;
    background-image: -webkit-linear-gradient(90deg, #d0a090 1px, #d0a090 1px), linear-gradient(#fdf8c8, #fdf8c8 23px, #ccd 23px, #ccd 24px, #fdf8c8 24px);
    background-image: -moz-linear-linear-gradient(90deg, #d0a090 1px, #d0a090 1px), linear-gradient(#fdf8c8, #fdf8c8 23px, #ccd 23px, #ccd 24px, #fdf8c8 24px);
    background-image: -ms-linear-gradient(90deg, #d0a090 1px, #d0a090 1px), linear-gradient(#fdf8c8, #fdf8c8 23px, #ccd 23px, #ccd 24px, #fdf8c8 24px);
    background-image: -o-linear-gradient(90deg, #d0a090 1px, #d0a090 1px), linear-gradient(#fdf8c8, #fdf8c8 23px, #ccd 23px, #ccd 24px, #fdf8c8 24px);
    background-image: linear-gradient(90deg, #d0a090 1px, #d0a090 1px), linear-gradient(#fdf8c8, #fdf8c8 23px, #ccd 23px, #ccd 24px, #fdf8c8 24px);
    background-size: 2px 100%, 100% 24px;
    background-position: 40px top, left 0px;
    background-repeat: no-repeat, repeat;
    line-height: 24px !important;
    background-attachment: local;
}

.notes-dark {
    color: #eeeecc;
    background-image: -webkit-linear-gradient(90deg, #642 1px, #642 1px), linear-gradient(#343a40, #343a40 23px, #554 23px, #554 24px, #343a40 24px);
    background-image: -moz-linear-linear-gradient(90deg, #642 1px, #642 1px), linear-gradient(#343a40, #343a40 23px, #554 23px, #554 24px, #343a40 24px);
    background-image: -ms-linear-gradient(90deg, #642 1px, #642 1px), linear-gradient(#343a40, #343a40 23px, #554 23px, #554 24px, #343a40 24px);
    background-image: -o-linear-gradient(90deg, #642 1px, #642 1px), linear-gradient(#343a40, #343a40 23px, #554 23px, #554 24px, #343a40 24px);
    background-image: linear-gradient(90deg, #642 1px, #642 1px), linear-gradient(#343a40, #343a40 23px, #554 23px, #554 24px, #343a40 24px);
    background-size: 2px 100%, 100% 24px;
    background-position: 40px top, left 0px;
    background-repeat: no-repeat, repeat;
    line-height: 24px !important;
    background-attachment: local;
}

/* 메뉴 및 툴바 */
#menu2 { 
    height: 38px; 
    width: 100%; 
    padding-left: 30px; 
    background: #f8f9fa; 
}

#menu2 .dropdown { 
    display: inline-block; 
    margin-left: 0; 
    margin-right: 0; 
}

#menu2 .dropdown button { 
    transition: background-color 0.2s, transform 0.1s; /* 부드러운 버튼 효과 */
}

#menu2 .dropdown button:hover {
    background-color: #e2e6ea;
}

#menu2 .dropdown button:active {
    transform: translateY(1px);
}

#menu2 .dropdown button i { 
    vertical-align: middle; 
}

#menu2 .dropdown a i { 
    vertical-align: middle; 
}

#menu2 .dropdown a {
    transition: background-color 0.2s; /* 부드러운 메뉴 항목 효과 */
}

#menu2 .dropdown a:hover {
    background-color: #e9ecef;
}

#toolbar { 
    height: 40px; 
    border-bottom: #666 1px solid; 
    padding-left: 30px; 
    background: #f8f9fa; 
    width: 100%; 
    display: inline-block; 
}

#toolbar .btn {
    transition: background-color 0.2s, transform 0.1s; /* 부드러운 툴바 버튼 효과 */
}

#toolbar .btn:hover {
    background-color: #e2e6ea;
}

#toolbar .btn:active {
    transform: translateY(1px);
}

/* 상태 바 */
#bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 35px;
    padding: 5px 40px;
    border-top: #ccc 1px solid; 
    background: #f8f9fa;
    z-index: 1000;
}

/* 파일 이름 입력 */
#getFilename { 
    max-width: 700px; 
    padding-left: 40px; 
    display: none; 
}

/* 탭 관련 스타일 */
#main-tabs {
    background-color: #f8f9fa;
    padding-left: 30px;
    margin-bottom: 0;
}

.tab-content {
    position: relative;
    height: calc(100vh - 170px);
    overflow: auto; /* hidden → auto */
}

.tab-pane {
    height: 100%;
    width: 100%;
}

#divination-content {
    padding: 0;
    position: relative;
    overflow: auto; /* hidden → auto */
}

#divination-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    overflow: auto; /* 이 줄 추가 */
}

/* '노트패드로 돌아가기' 버튼 스타일 */
.return-button {
position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    opacity: 0.8;
    transition: opacity 0.3s, transform 0.2s;
}

.return-button:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* 다크 모드에서의 탭 스타일 */
[data-bs-theme="dark"] .nav-tabs {
    border-color: #495057;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: #343a40;
    border-color: #495057 #495057 #343a40;
    color: #f8f9fa;
}

[data-bs-theme="dark"] .nav-tabs .nav-link:hover,
[data-bs-theme="dark"] .nav-tabs .nav-link:focus {
    border-color: #495057;
}

/* 다크 모드 스타일 강화 */
[data-bs-theme="dark"] body {
    background-color: #212529;
    color: #e9ecef;
}

[data-bs-theme="dark"] #menu2, 
[data-bs-theme="dark"] #toolbar,
[data-bs-theme="dark"] #main-tabs,
[data-bs-theme="dark"] #bar {
    background-color: #343a40 !important;
    color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: #343a40;
    border-color: #495057;
}

[data-bs-theme="dark"] .dropdown-item {
    color: #e9ecef;
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: #495057;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: #495057;
}

[data-bs-theme="dark"] .modal-content {
    background-color: #343a40;
    color: #e9ecef;
}

[data-bs-theme="dark"] .modal-header, 
[data-bs-theme="dark"] .modal-footer {
    border-color: #495057;
}

/* 애니메이션 및 전환 효과 */
.nav-link, .btn, .dropdown-item {
    transition: all 0.2s ease;
}

.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

/* 중요 요소 로딩 최적화를 위한 스켈레톤 스타일 */
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

/* 반응형 스타일 */
@media (max-width: 670px) {
    #toolbar .btn { 
        padding: .375rem .35rem; 
    }
    
    #menu2, #toolbar, #main-tabs { 
        padding-left: 5px; 
    }
    
    #bar { 
        padding: 5px 20px; 
    }
    
    #toolbar .btn:nth-child(n+9) { 
        display: none; 
    }
    
    /* 메뉴 글자 크기 및 간격 조정 추가 */
    #menu2 .dropdown button {
        font-size: 0.85rem;
        padding: 0.375rem 0.5rem;
    }
    
    #menu2 .dropdown {
        margin-right: -5px;
    }
    
    /* 터치 디바이스를 위한 버튼 크기 확대 */
    .btn, 
    .dropdown-item,
    .form-control {
        min-height: 42px; /* 터치 타겟 크기 확보 */
    }
    
    /* 모바일에서의 모달 조정 */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    /* 모바일에서 노트 패딩 줄이기 */
    textarea, #area {
        padding-left: 30px;
    }
    
    /* 모바일에서 배경 이미지 위치 조정 */
    .notes, .notes-dark {
        background-position: 28px top, left 0px;
    }
}

/* 매우 작은 화면에 대한 추가 스타일 */
@media (max-width: 480px) {
    #menu2 .dropdown button {
        font-size: 0.8rem;
        padding: 0.375rem 0.4rem;
    }
    
    #menu2 .dropdown {
        margin-right: -6px;
    }
    
    #toolbar .btn { 
        padding: .375rem .3rem; 
    }
    
    /* 모바일에서 탭 스타일 조정 */
    .nav-tabs .nav-link {
        padding: 0.3rem 0.5rem;
        font-size: 0.9rem;
    }
    
    /* 매우 작은 화면에서 텍스트 사이즈 자동 조정 */
    html {
        font-size: 14px;
    }
}

/* 고해상도 화면에 대한 최적화 */
@media (min-width: 1500px) {
    .container {
        max-width: 1400px;
    }
    
    #area {
        font-size: 1.1rem;
    }
}

/* 인쇄 최적화 */
@media print {
    body * {
        visibility: hidden;
    }
    
    #notepad-content, #notepad-content * {
        visibility: visible;
    }
    
    #notepad-content {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 15px;
    }
    
    #header, #menu2, #toolbar, #bar {
        display: none !important;
    }
    
    #area {
        height: auto;
        overflow: visible;
        font-size: 12pt;
        line-height: 1.5;
        color: #000 !important;
        background: none !important;
    }
}

/* 사용자 경험 향상을 위한 추가 스타일 */
::selection {
    background-color: #8B5CF6;
    color: #fff;
}

/* 접근성 향상을 위한 포커스 스타일 */
.btn:focus, 
.form-control:focus, 
.form-select:focus,
.dropdown-item:focus {
    box-shadow: 0 0 0 0.25rem rgba(139, 92, 246, 0.25);
}

/* 성능 최적화를 위한 GPU 가속 설정 */
.card, 
.btn-primary, 
.modal-content {
    transform: translateZ(0);
    will-change: transform, opacity;
}

/* 성능 개선을 위한 가상 요소 최적화 */
.btn-primary::before,
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    transition: background-color 0.3s;
    pointer-events: none;
    z-index: -1;
}

/* 모바일 디바이스 가독성 최적화 */
@media (max-width: 670px) {
    .modal-body, 
    .nav-link, 
    .dropdown-item {
        font-size: 16px; /* 모바일 가독성 확보 */
    }
}

/* 웹 폰트 최적화: 시스템 폰트 우선 사용 */
body, .form-control, .btn, .dropdown-item {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* 행운의 선택 메뉴 차별화 스타일 */
#menu2 .dropdown button:contains("행운의 선택") {
    background-color: #EDE9FE;
    color: #6D28D9;
    border-color: #C4B5FD;
    font-weight: 500;
}

#menu2 .dropdown button:contains("행운의 선택"):hover {
    background-color: #DDD6FE;
    color: #5B21B6;
}

/* CSS에는 :contains 선택자가 없으므로 아래와 같이 대체 방법 사용 */
/* 행운의 선택 메뉴에 특정 클래스를 추가하는 것이 가장 좋습니다 */
#menu2 .dropdown:nth-child(5) button {
    background-color: #EDE9FE;
    color: #6D28D9;
    border-color: #C4B5FD;
    font-weight: 500;
}

#menu2 .dropdown:nth-child(5) button:hover {
    background-color: #DDD6FE;
    color: #5B21B6;
}

/* 다크 모드 지원 */
[data-bs-theme="dark"] #menu2 .dropdown:nth-child(5) button {
    background-color: #5B21B6;
    color: #EDE9FE;
    border-color: #7C3AED;
}

[data-bs-theme="dark"] #menu2 .dropdown:nth-child(5) button:hover {
    background-color: #6D28D9;
    color: #FFFFFF;
}

/* 주사위 점괘 서비스 하위 메뉴 스타일 */
#menu2 .dropdown-item[onclick="showDivinationTab()"] {
    background-color: #EDE9FE;
    color: #6D28D9;
    font-weight: 500;
}

#menu2 .dropdown-item[onclick="showDivinationTab()"]:hover {
    background-color: #DDD6FE;
    color: #5B21B6;
}

/* 주사위 점괘 서비스 메뉴 아이콘 색상 변경 */
#menu2 .dropdown-item[onclick="showDivinationTab()"] i.material-icons-outlined {
    color: #8B5CF6;
}

/* 다크 모드 지원 */
[data-bs-theme="dark"] #menu2 .dropdown-item[onclick="showDivinationTab()"] {
    background-color: #4C1D95;
    color: #EDE9FE;
}

[data-bs-theme="dark"] #menu2 .dropdown-item[onclick="showDivinationTab()"]:hover {
    background-color: #6D28D9;
    color: #FFFFFF;
}

[data-bs-theme="dark"] #menu2 .dropdown-item[onclick="showDivinationTab()"] i.material-icons-outlined {
    color: #A78BFA;
}