
:root {
    --sidebar-width: 400px;
}

/* When detail page is active, remove the margin from the main nav container to eliminate the gap */
body.detail-page-active .nav-container {
    margin-bottom: 0;
}

body.detail-page-active {
    padding: 0;
}

.page-image-detail {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    overflow: hidden;
}

/* Hide any scrollbars on the page container */
.page-image-detail::-webkit-scrollbar {
    display: none;
}

.page-image-detail {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === Header Styles Moved ===
 * .image-detail-header is now unified in header-navigation-unified.css
 * This eliminates duplicate definitions across multiple files
 * ========================== */

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-navigation {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}


/* .image-counter はTailwindCSSに統一（index.html内の@layer components） */

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background-color: transparent;
    color: #9ca3af;
    border: 1px solid #374151;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
    background-color: #374151;
    color: #f3f4f6;
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.action-btn.secondary {
    background-color: #374151;
    color: #f3f4f6;
}

.action-btn.secondary:hover:not(:disabled) {
    background-color: #4b5563;
}

.image-detail-main-content {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    height: calc(95vh - 125px); /* 95vh + ヘッダー分 */
    min-height: 0;
}

.image-viewer-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: #191919;
    padding: 0.5rem; /* パディングを最小限に */
    min-height: 0;
    height: 100%;
    max-height: calc(100vh - 125px); /* ヘッダー分のみ */
    margin-right: 0.5rem; /* 右側のマージンを縮小 */
    overflow: hidden; /* 追加: はみ出した部分を隠す */
}

.image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1; /* nav-arrowより低いz-index */
}

#detail-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1; /* nav-arrowより低いz-index */
    pointer-events: auto; /* 画像自体はクリック可能にしておく */
    transition: opacity 0.2s ease; /* スムーズな画像切り替え */
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* 非常に高いz-index */
    transition: all 0.2s ease;
    backdrop-filter: blur(4px); /* ブラー効果で視認性向上 */
    pointer-events: auto; /* クリックイベントを確実に受け取る */
}

.nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1); /* ホバー時に少し拡大 */
    backdrop-filter: blur(6px);
}

.nav-arrow.prev {
    left: 1rem;
}

.nav-arrow.next {
    right: 1rem;
}

.nav-arrow .material-symbols-outlined {
    font-size: 2rem;
}

/* 静的な情報サイドバー */
.image-info-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: #1f2937;
    border-left: 1px solid #374151; /* ボーダーを復活 */
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-left: 0.5rem; /* 左側のマージンを縮小 */
    margin-right: 0.5rem; /* 右側のマージンを縮小 */
    box-sizing: border-box; /* パディング含むサイズ計算 */
    overflow: hidden; /* 子要素の適切な制約 */
}

/* タブナビゲーション */
.sidebar-tab-nav {
    display: flex;
    background-color: #191919;
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

/* .sidebar-tab-btn はTailwindCSSに統一（index.html内の@layer components） */

/* タブパネル */
.tab-panel {
    display: none;
    height: 100%;
}

.tab-panel.active {
    display: block;
}

.sidebar-content {
    padding: 0.75rem 10px; /* 上下12px、左右10px */
    flex-grow: 1;
    overflow-y: auto;
    min-height: 0;
    height: calc(100vh - 165px - 1.5rem); /* ナビゲーション+ヘッダー+サイドバーヘッダー + 上下パディング分 */
    box-sizing: border-box; /* パディングを含むボックスサイズ計算 */
}

/* Sidebar scrollbar styling */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
    margin-right: -6px; /* スクロールバーを右端に寄せる */
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* スクロールバーがパディングを侵食しないよう調整 */
.sidebar-content {
    scrollbar-gutter: stable;
}

.info-section {
    margin-bottom: 2rem;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h4 {
    color: #9ca3af;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.info-list {
    margin: 0;
}

.info-list dt {
    color: #9ca3af;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.info-list dd {
    color: #f3f4f6;
    font-size: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    word-break: break-all;
}

.info-list dd:last-child {
    margin-bottom: 0;
}

/* AI生成情報のプロンプト表示 */
.info-list dd.ai-prompt {
    max-height: 150px;
    overflow-y: auto;
    padding: 0.5rem;
    background-color: #191919;
    border: 1px solid #374151;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.info-list dd.ai-prompt::-webkit-scrollbar {
    width: 4px;
}

.info-list dd.ai-prompt::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 2px;
}

.note-editor {
    width: 100%;
    min-height: 21rem;
    max-height: 56rem;
    padding: 0.75rem;
    border: 2px solid #444;
    border-radius: 0.5rem;
    background-color: #191919;
    color: #f3f4f6;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.note-editor:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.note-editor::placeholder {
    color: #888;
    font-style: italic;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #374151;
    color: #f3f4f6;
    font-size: 0.75rem;
    border-radius: 1rem;
    font-weight: 500;
}

/* Responsive styles */
@media (max-width: 1024px) {
    .image-info-sidebar {
        width: 350px;
    }
}

@media (max-width: 768px) {
    .image-detail-main-content {
        flex-direction: column;
        height: calc(95vh - 125px); /* モバイル時も95vh */
    }
    
    .image-info-sidebar {
        width: 100%;
        height: 40vh; /* 明示的な高さ設定 */
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid #374151;
        order: 2;
        margin-left: 0; /* モバイル時は左マージンをリセット */
        margin-right: 0; /* モバイル時は右マージンもリセット */
        flex-shrink: 0; /* 高さを維持 */
    }
    
    .sidebar-content {
        padding: 0.75rem 10px; /* モバイル時: 上下12px、左右10px */
        height: calc(40vh - 80px); /* モバイル時: 40%から固定要素分を除く */
    }
    
    .image-viewer-container {
        order: 1;
        flex-grow: 1;
        height: calc(60vh - 125px); /* モバイル時: ヘッダー分のみ */
        max-height: calc(60vh - 125px);
        min-height: 0;
        margin-right: 0; /* モバイル時は右マージンをリセット */
        padding: 0.5rem; /* パディングを最小限に */
    }
}

@media (max-width: 480px) {
    .sidebar-header {
        padding: 1rem 1.5rem;
    }
    
    .sidebar-content {
        padding: 0.75rem 10px; /* 小画面時: 上下12px、左右10px */
        height: calc(40vh - 70px); /* 小画面時: 40%から固定要素分を除く */
    }
    
    .info-section {
        margin-bottom: 1.5rem;
    }
    
    .image-viewer-container {
        padding: 0.5rem; /* パディングを最小限に */
        height: calc(60vh - 125px); /* 小画面時も125px分を除く */
        max-height: calc(60vh - 125px);
    }
}

/* フルスクリーンモード */
body.fullscreen-mode {
    background-color: #000;
}

/* フルスクリーンモードでナビゲーションを完全に非表示 */
body.fullscreen-mode .image-detail-header,
body.fullscreen-mode .nav-container,
body.fullscreen-mode .tab-navigation,
body.fullscreen-mode nav.nav-container,
body.fullscreen-mode #tab-navigation,
body.fullscreen-mode.detail-page-active #tab-navigation,
body.fullscreen-mode .main-content.spa-active #tab-navigation {
    display: none !important;
    visibility: hidden !important;
}

/* より高い詳細度で確実に非表示 */
body.fullscreen-mode.detail-page-active .main-content.spa-active #tab-navigation {
    display: none !important;
    visibility: hidden !important;
}

body.fullscreen-mode .page-image-detail {
    height: 100vh;
    padding: 0;
    margin: 0;
}

body.fullscreen-mode .image-detail-main-content {
    height: 100vh;
    background-color: #000;
    margin: 0;
}

body.fullscreen-mode .image-viewer-container {
    background-color: #000;
    padding: 0;
    margin: 0;
    max-height: 100vh;
    height: 100vh;
}

body.fullscreen-mode .image-info-sidebar {
    display: none;
}

body.fullscreen-mode #detail-image {
    max-width: 100vw;
    max-height: 100vh;
    object-fit: contain;
    box-shadow: none;
}

body.fullscreen-mode .nav-arrow {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

body.fullscreen-mode .nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

/* Hide all scrollbars in fullscreen mode */
body.fullscreen-mode::-webkit-scrollbar {
    display: none;
}

body.fullscreen-mode {
    -ms-overflow-style: none;
    scrollbar-width: none;
    overflow: hidden;
}

/* フルスクリーン終了ボタン */
body.fullscreen-mode .fullscreen-exit-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.7;
}

body.fullscreen-mode .fullscreen-exit-overlay:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.fullscreen-exit-overlay {
    display: none;
}

