/* ========================================
   Preview
   ======================================== */

/* プレビューモーダル内は絶対にはみ出さないように枠を固定 */
#previewModal .modal-content.modal-large {
    height: 80vh; /* modal.css の max-height:80vh と揃える */
    max-height: 80vh;
    overflow: hidden;
    min-height: 0;
}

#previewModal .modal-body.preview-body {
    overflow: hidden;
    min-height: 0;
}

/* ボディ自体をFlexにして、プレビュー領域を最大化させる */
.preview-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden; /* 動画の時はスクロールバーを出さない */
    background-color: var(--bg-primary);
}

#previewContainer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1; /* 縦方向の余白を埋める */
    width: 100%;
    min-height: 0; /* Flexboxの入れ子ではみ出し防止 */
    min-width: 0;
    background-color: transparent; /* ボディの黒背景を使う */
    overflow: hidden;
}

/* 画像プレビューの場合はスクロールさせたい場合があるので上書き */
#previewContainer.preview-zoom-enabled {
    overflow: auto;
}

/* PDFなど縦スクロールが必要なプレビュー用 */
#previewContainer.preview-scroll-enabled {
    overflow-y: auto;
    overflow-x: hidden;
    align-items: flex-start;
    justify-content: flex-start;
}

#previewContainer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Image zoom */
#previewContainer.preview-zoom-enabled {
    overflow: auto;
}

#previewContainer img.preview-image {
    cursor: zoom-in;
}

#previewContainer img.preview-image.is-zoomed {
    cursor: zoom-out;
    max-width: none;
    max-height: none;
}

#previewContainer video,
#previewContainer video.preview-video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* アスペクト比を維持して収める */
    display: block;
    margin: 0 auto;
}

#previewContainer iframe {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
}

.preview-details {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0; /* 詳細エリアが縮まないようにする */
    max-height: 30%; /* 必要なら高さ制限 */
    overflow-y: auto;
}

/* ZIP preview */
.zip-preview {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.zip-preview-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}

.zip-dir {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-primary);
    width: 100%;
}

.zip-dir-summary {
    cursor: pointer;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.zip-dir-children {
    padding: 6px 12px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zip-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--bg-secondary);
}

.zip-file-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.zip-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.zip-file-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    font-size: 16px;
}

.zip-file-name {
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 520px;
}

.zip-file-right {
    font-size: 12px;
    color: var(--text-secondary);
    flex: 0 0 auto;
}

.zip-empty {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* PDF Scroll View */
.pdf-preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px 0;
}

.pdf-preview-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.detail-value {
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Custom Video Player */
.custom-video-player {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
}

.custom-video-player.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    z-index: 9999;
}


.custom-video-player video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.video-controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

.video-center-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    transform: scale(0.9);
}

.custom-video-player.paused .video-center-btn {
    opacity: 1;
    transform: scale(1);
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    padding: 32px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
    box-sizing: border-box;
}

.custom-video-player:hover .video-controls,
.custom-video-player.paused .video-controls {
    opacity: 1;
}

/* Progress Bar */
.video-progress-container {
    width: 100%;
    height: 20px; /* larger hit area */
    display: flex;
    align-items: center;
    cursor: pointer;
}

.video-progress-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    transition: height 0.1s;
}

.video-progress-container:hover .video-progress-bg {
    height: 6px;
    border-radius: 3px;
}

.video-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: var(--primary, #3b82f6);
    transition: width 0.1s linear;
}

.video-progress-buf {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    background: rgba(255, 255, 255, 0.5);
    transition: width 0.2s ease;
}

/* Controls Row */
.video-controls-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    color: #fff;
}

.video-btn {
    background: none;
    border: none;
    padding: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.video-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.video-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.video-speed-btn {
    font-family: monospace;
    font-size: 12px;
    line-height: 1;
    padding: 6px 8px;
    min-width: 44px;
    justify-content: center;
}

.video-time {
    font-family: monospace;
    font-size: 12px;
    color: #eee;
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
}

.video-volume-container {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    max-width: 120px;
    flex-shrink: 0;
}

.video-volume-slider {
    flex: 1;
    height: 4px;
    min-width: 50px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
    outline: none;
}

.video-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.video-spacer {
    flex: 1;
    min-width: 8px;
}

/* モバイル対応: 狭い画面では音量スライダーを隠す */
@media (max-width: 480px) {
    .video-volume-slider {
        display: none;
    }
    .video-volume-container {
        min-width: auto;
        max-width: none;
    }
    .video-time {
        min-width: 70px;
        font-size: 11px;
    }
}
