/* PDF ビューワ画面専用スタイル。
   デザイン source: SOURCE_MATERIAL/template/nikko-eBook/viewer.html の <style> ブロック。
   DearFlip の自動生成 UI（.df-ui, .df-ui-btn, .df-controls-bottom 等）に CSS で寄せる。 */

:root {
    --primary-color: #0F3F83;
    --primary-dark:  #0a2d5e;
    --topbar-height: 52px;
    --toolbar-height: 42px;
    --sample-banner-height: 40px;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background: #111;
    color: #fff;
    overflow: hidden;
}

/* ============================================================
   Top Bar
   ============================================================ */
.viewer-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    z-index: 9999;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.topbar-back {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}
.topbar-back:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff;
}
.topbar-back svg { width: 16px; height: 16px; flex-shrink: 0; }

.viewer-title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-left: 24px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.topbar-dl {
    /* ゴールド地に白文字が沈むため紺文字に切り替え（viewer は common.css 未読込のためリテラル #0F3F83 を使用） */
    color: #0F3F83;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700; /* 金地×紺字は太字で可読性を確保 */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(255, 210, 31, 0.85); /* premium-color #FFD21F */
    transition: all 0.25s ease;
}
.topbar-dl:hover {
    background: #FFD21F;
    color: #000;
}
.topbar-dl svg { width: 14px; height: 14px; }

.topbar-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.topbar-brand .brand-main {
    font-size: 0.85rem; font-weight: 700; color: #fff; opacity: 0.7;
}
.topbar-brand .brand-divider {
    width: 1px; height: 14px; background: rgba(255,255,255,0.25);
    display: inline-block; vertical-align: middle;
}
.topbar-brand .brand-sub {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem; font-weight: 400; color: #fff; opacity: 0.6; letter-spacing: 0.5px;
}

/* ============================================================
   Sample Banner
   ============================================================ */
.sample-banner {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0; right: 0;
    height: var(--sample-banner-height);
    background: #fff3cd;
    color: #856404;
    z-index: 9998;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid #ffeeba;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0 12px;
    gap: 8px;
    text-align: center;
}
.sample-banner .btn-banner {
    display: inline-flex;
    align-items: center;
    background: #856404;
    color: #fff !important;
    text-decoration: none !important;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.sample-banner .btn-banner:hover {
    background: #6d5203;
    transform: translateY(-1px);
}
/* 帯は販売URL登録時のみ body へ付与される has-banner で表示・領域確保する。 */
body.has-banner .sample-banner { display: flex; }

/* ============================================================
   Viewer Body
   ============================================================ */
.viewer-body {
    position: absolute;
    top: var(--topbar-height);
    left: 0; right: 0;
    bottom: var(--toolbar-height);
    overflow: hidden;
    background: #111;
}
body.has-banner .viewer-body {
    top: calc(var(--topbar-height) + var(--sample-banner-height));
}

/* DearFlip コンテナを viewer-body 全面に */
.dflip-container,
.viewer-body ._df_book {
    width: 100% !important;
    height: 100% !important;
    background: #111 !important;
}

/* DearFlip 内部ステージ（PDF レンダリング領域）の影 */
.viewer-body ._df_book canvas,
.viewer-body .df-book {
    filter: drop-shadow(0 12px 40px rgba(0, 0, 0, 0.6));
}

/* ============================================================
   Bottom Toolbar （DearFlip 生成、CSS で SOURCE_MATERIAL に寄せる）
   ============================================================ */
.df-ui,
.df-ui.df-controls-bottom,
.df-ui.df-controls-top {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    transform: none !important; /* DearFlip 側の translateX(-50%) を打ち消す */
    height: var(--toolbar-height) !important;
    background: var(--primary-color) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    z-index: 9999 !important;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3) !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
}
/* DearFlip 親コンテナのレイアウトも打ち消し */
.df-container.df-float.df-controls-bottom,
.df-container.df-float.df-controls-top {
    position: static !important;
    transform: none !important;
    width: auto !important;
}

.df-ui .df-ui-btn,
.df-ui-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    color: rgba(255, 255, 255, 0.65) !important;
    background: transparent !important; /* dflip.css のデフォルト background-color:#fff を打ち消す */
    cursor: pointer;
    border-radius: 4px !important;
    transition: all 0.2s ease;
    position: relative;
    font-size: 18px !important;
    padding: 0 !important; /* dflip.css の padding:10px 5px も打ち消す（アイコン中央配置のため） */
}
.df-ui .df-ui-btn:hover,
.df-ui-btn:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}
.df-ui .df-ui-btn.df-active,
.df-ui-btn.df-active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.15) !important;
}
.df-ui .df-ui-btn.df-disabled,
.df-ui-btn.df-disabled,
.df-ui-btn.disabled {
    opacity: 0.3 !important;
    pointer-events: none;
}

/* ボタン疑似要素アイコンの色 */
.df-ui .df-ui-btn:before { color: inherit !important; }

/* ボタン内のテキスト span（タイトル）はアイコン化するため隠す */
.df-ui-btn > span { display: none !important; }

/* hover で title をツールチップ表示（SOURCE_MATERIAL 準拠） */
.df-ui-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 44px;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

/* ページ番号表示 */
.df-ui-page,
.df-ui .df-ui-page {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* DearFlip はラベルへ内容幅(例 99px)を inline で付与する一方、バー側の
       .df-ui-btn が width:38px を強制するためテキストが枠外へはみ出す。
       内容に合わせて伸縮させ、枠内に収める（最小幅は確保）。 */
    width: auto !important;
    min-width: 60px;
    padding: 0 6px !important;
    height: 32px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 4px !important;
    margin: 0 6px !important;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.df-ui-page input { display: none !important; }
.df-ui-page label {
    color: #fff !important;
    cursor: pointer;
    /* DearFlip が付与する inline の固定 width を打ち消し、内容幅で表示する */
    width: auto !important;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* セパレータ */
.df-ui-sep,
.df-ui .df-ui-sep {
    width: 1px !important;
    height: 22px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    margin: 0 4px !important;
}

/* もっと見るメニュー */
.df-ui-more-popup,
.df-more-container {
    background: var(--primary-dark) !important;
    color: #fff !important;
    border-radius: 8px !important;
    padding: 6px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    min-width: 180px !important;
}
.df-ui-more-popup a,
.df-ui-more-popup .df-ui-btn,
.df-more-container .df-ui-btn {
    width: 100% !important;
    height: 34px !important;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 0 12px !important;
    font-size: 14px !important;
    color: rgba(255, 255, 255, 0.85) !important;
}
.df-ui-more-popup a:hover,
.df-more-container .df-ui-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}

/* 「最初のページへ」「最後のページへ」を中央ボタン群（メニュー）の両端へ。
   .df-ui は justify-content:center の flex なので、order で先頭/末尾に寄せると
   中央クラスタの左右端に収まる（画面端ではなくメニュー内の両端）。
   端であることを示すため、隣接ボタンとの間に少し余白を取る。 */
.df-ui .df-ui-btn.df-ui-start {
    order: -1;
    margin-right: 8px;
}
.df-ui .df-ui-btn.df-ui-end {
    order: 1;
    margin-left: 8px;
}

/* ============================================================
   サイドパネル（目次・サムネ・検索・シェア）
   ============================================================ */
.df-outline-container,
.df-popup-thumb,
.df-search-container,
.df-share-wrapper {
    background: var(--primary-dark) !important;
    color: #fff !important;
}
.df-outline-item,
.df-thumb-number { color: #fff !important; }
.df-outline-item:hover { background: rgba(255, 255, 255, 0.08) !important; }

.df-search-form input.df-search-text {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
}
.df-search-form input.df-search-text::placeholder { color: rgba(255, 255, 255, 0.55); }
.df-search-btn { color: #fff !important; }
.df-search-highlight {
    background: #FFD21F !important;
    color: #000 !important;
}

/* サムネポップアップ */
.df-popup-thumb {
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* サムネ一覧 */
.df-thumb {
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}
.df-thumb.df-active,
.df-thumb:hover { border-color: #FFD21F !important; }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 767.98px) {
    .viewer-topbar { padding: 0 12px; }
    .topbar-back { font-size: 12px; padding: 5px 10px; }
    .viewer-title { font-size: 12px; margin-left: 12px; }
    .topbar-brand { display: none; }
    .df-ui-btn,
    .df-ui .df-ui-btn { width: 34px !important; height: 34px !important; font-size: 16px !important; }
    .df-ui-page label { font-size: 11px; }
    .sample-banner { font-size: 12px; }
    .sample-banner .btn-banner { font-size: 11px; padding: 3px 8px; }
}

@media (max-width: 480px) {
    .viewer-title { max-width: 140px; }
    .topbar-dl span,
    .topbar-dl { padding: 4px 8px; font-size: 0; }
    .topbar-dl svg { width: 16px; height: 16px; }
}
