/* Flipbook CSS - Improved Version - Category: 법령및제도 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #667eea;
    height: 100vh;
    overflow: hidden;
    user-select: none;
    position: fixed;
    width: 100%;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

/* 헤더 - 최소화 */
.header {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
    min-height: 40px;
    max-height: 40px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 0.9rem;
    font-weight: 400;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.controls button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.controls button:hover {
    background: rgba(255,255,255,0.2);
}

.controls button.active {
    background: rgba(52,152,219,0.8);
    box-shadow: 0 2px 8px rgba(52,152,219,0.3);
}

#pageInfo {
    background: rgba(0,0,0,0.6);
    padding: 0.3rem 0.6rem;
    border-radius: 16px;
    font-size: 0.75rem;
    min-width: 60px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

/* 드롭다운 메뉴 */
.dropdown-menu {
    position: absolute;
    top: 42px;
    right: 8px;
    background: rgba(0,0,0,0.95);
    border-radius: 8px;
    padding: 0.5rem;
    z-index: 999;
    display: none;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-menu button {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.dropdown-menu button:hover {
    background: rgba(255,255,255,0.2);
}

.dropdown-menu button i {
    width: 16px;
}

/* 검색 패널 - 최소화 */
.search-panel {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 6px;
    z-index: 950;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.search-panel.show {
    max-height: 400px;
}

.search-container {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.4rem;
}

#searchInput {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.85rem;
    outline: none;
}

#searchInput:focus {
    border-color: #3498db;
}

.search-execute-btn, .close-search-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-results {
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 0.6rem;
    margin: 0.3rem 0;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    cursor: pointer;
    border-left: 3px solid #3498db;
}

.search-result-item:hover {
    background: rgba(255,255,255,0.1);
}

.search-result-page {
    font-weight: bold;
    color: #3498db;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
}

.search-result-text {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    line-height: 1.3;
}

.search-result-text mark {
    background: #f39c12;
    color: #000;
    padding: 1px 3px;
    border-radius: 2px;
}

/* 패널 - 최소화 */
.panel {
    background: rgba(0,0,0,0.95);
    color: white;
    padding: 4px 8px;
    z-index: 900;
    backdrop-filter: blur(10px);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.panel.show {
    max-height: 200px;
}

.voice-controls, .annotation-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0.3rem 0;
}

.voice-btn, .tool, .clear-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.voice-btn:hover, .tool:hover, .clear-btn:hover {
    background: rgba(255,255,255,0.2);
}

.voice-btn.active {
    background: rgba(46,204,113,0.8);
}

.tool.active {
    background: rgba(52,152,219,0.8);
}

.tools, .colors {
    display: flex;
    gap: 0.4rem;
}

.color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
}

.color.active {
    border-color: white;
}

.speed-control, .thickness-control {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
}

.speed-control input, .thickness-control input {
    width: 80px;
    height: 4px;
}

/* 메인 뷰어 - 최대화 */
.book-viewer {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    overflow: hidden;
    min-height: 0;
}

.book-container {
    display: flex;
    gap: 2px;
    perspective: 1500px;
    max-width: 100%;
    max-height: 100%;
    position: relative;
    transform-origin: center center;
    transition: transform 0.3s ease;
    touch-action: none;
    user-select: none;
}

.book-container.single-page {
    justify-content: center;
}

.book-container.single-page .left-page {
    display: none !important;
}

.book-container.single-page .right-page {
    max-width: 100%;
}

.book-container.dragging {
    cursor: grabbing;
}

.book-container.zoomed {
    cursor: move;
}

.page-wrapper {
    position: relative;
    background: white;
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    overflow: hidden;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.page-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.page-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.annotation-canvas.active {
    pointer-events: auto;
    cursor: crosshair;
}

/* 네비게이션 버튼 */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.85);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 1rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.3rem;
    opacity: 0.8;
    transition: all 0.3s;
    z-index: 20;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.nav-btn:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.nav-prev {
    left: 1rem;
}

.nav-next {
    right: 1rem;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* 줌 정보 */
.zoom-info {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.8rem;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
}

.zoom-info.show {
    opacity: 1;
}

/* 뷰 모드 표시 */
.view-mode-indicator {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.8rem;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.3s;
}

.view-mode-indicator.show {
    opacity: 1;
}

/* 썸네일 슬라이더 - 최소화 */
.thumbnail-slider {
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 6px;
    z-index: 900;
    flex-shrink: 0;
    max-height: 60px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.slider-nav {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.slider-track {
    flex: 1;
    height: 4px;
    background: transparent;
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.slider-progress {
    height: 100%;
    background: linear-gradient(to right, #3498db, #2ecc71);
    border-radius: 2px;
    width: 0%;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.handle-indicator {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
}

/* 모달 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.modal-content {
    position: relative;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    min-width: 300px;
    max-width: 90vw;
    z-index: 1;
}

.modal-content textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

.btn-primary, .btn-secondary {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .header {
        padding: 3px 6px;
        min-height: 36px;
        max-height: 36px;
    }
    
    .header h1 {
        font-size: 0.8rem;
    }
    
    .controls button {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
    
    #pageInfo {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
        min-width: 50px;
    }
    
    .book-viewer {
        padding: 1px;
    }
    
    .book-container {
        gap: 1px;
        touch-action: pan-x pan-y pinch-zoom;
    }
    
    .book-container.zoomed {
        touch-action: pan-x pan-y pinch-zoom;
    }
    
    .page-wrapper {
        touch-action: pan-x pan-y pinch-zoom;
    }
    
    .nav-btn {
        width: 44px;
        height: 44px;
        padding: 0.8rem;
        font-size: 1.1rem;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    }
    
    .nav-btn:active {
        transform: translateY(-50%) scale(0.95);
    }
    
    .nav-prev {
        left: 0.5rem;
    }
    
    .nav-next {
        right: 0.5rem;
    }
    
    .thumbnail-slider {
        padding: 4px;
        max-height: 50px;
    }
    
    .slider-container {
        margin-bottom: 0.2rem;
    }
    
    .dropdown-menu {
        right: 4px;
        top: 38px;
    }
    
    .zoom-info {
        font-size: 0.9rem;
        padding: 0.5rem 0.9rem;
        top: 1rem;
        right: 1rem;
        background: rgba(0,0,0,0.85);
        border-radius: 20px;
    }
    
    .view-mode-indicator {
        font-size: 0.9rem;
        padding: 0.5rem 0.9rem;
        top: 1rem;
        left: 1rem;
        background: rgba(0,0,0,0.85);
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 2px 4px;
        min-height: 32px;
        max-height: 32px;
    }
    
    .header h1 {
        font-size: 0.75rem;
    }
    
    .controls button {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }
    
    #pageInfo {
        font-size: 0.65rem;
        min-width: 45px;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}