/**
 * プレビューページ共通スタイルシート
 * 
 * PC版・スマホ版プレビューラッパーページで共通使用
 * ライトモード（デフォルト） / ダークモード 切り替え対応
 */

/* ============================================
   リセット（プレビューページ内のみ）
   ============================================ */
body.preview-mobile,
body.preview-pc {
    margin: 0;
    padding: 0;
}

body.preview-mobile *,
body.preview-mobile *::before,
body.preview-mobile *::after,
body.preview-pc *,
body.preview-pc *::before,
body.preview-pc *::after {
    box-sizing: border-box;
}

/* ============================================
   CSS変数 - ライトモード（デフォルト）
   ============================================ */
:root {
    --pv-bg-body: #f5f5f7;
    --pv-bg-header: #ffffff;
    --pv-bg-card: #ffffff;
    --pv-bg-overlay: rgba(0, 0, 0, 0.6);
    --pv-text-primary: #1d1d1f;
    --pv-text-secondary: rgba(0, 0, 0, 0.5);
    --pv-text-muted: #666;
    --pv-border-color: rgba(0, 0, 0, 0.08);
    --pv-shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.3);
    --pv-font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ============================================
   ダークモード（:root に限定）
   ============================================ */
:root[data-theme="dark"] {
    --pv-bg-body: #0f0f1a;
    --pv-bg-header: #1a1a2e;
    --pv-bg-card: #16162a;
    --pv-bg-overlay: rgba(0, 0, 0, 0.8);
    --pv-text-primary: #f3f4f6;
    --pv-text-secondary: rgba(255, 255, 255, 0.6);
    --pv-text-muted: #9ca3af;
    --pv-border-color: rgba(255, 255, 255, 0.1);
    --pv-shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.6);
}

/* ============================================
   PC版プレビュー共通
   ============================================ */
body.preview-pc {
    background: var(--pv-bg-body);
    min-height: 100vh;
    font-family: var(--pv-font-family);
}

.preview-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--pv-bg-header);
    border-bottom: 1px solid var(--pv-border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 0 20px;
}

.preview-mode-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.preview-mode-badge:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.preview-mode-badge .material-icons {
    font-size: 18px;
    opacity: 0.8;
}

.preview-info {
    position: absolute;
    left: 20px;
    color: var(--pv-text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-info .material-icons {
    font-size: 18px;
}

.preview-container-pc {
    padding-top: 50px;
    height: 100vh;
}

.preview-container-pc iframe {
    width: 100%;
    height: calc(100vh - 50px);
    border: none;
}

/* スマホ幅で PC プレビューを開いたとき（管理画面から「プレビュー」等）
   ラッパーのヘッダー/バッジは非表示。iframe 内のテナント固定ヘッダー直下にバッジを出す */
@media (max-width: 768px) {
    body.preview-pc .preview-header {
        display: none;
    }

    body.preview-pc .preview-container-pc {
        padding-top: 0;
        height: 100vh;
    }

    body.preview-pc .preview-container-pc iframe {
        height: 100vh;
    }
}

/* ============================================
   モバイル版プレビュー共通
   ============================================ */
body.preview-mobile {
    background: var(--pv-bg-body);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    color: var(--pv-text-primary);
    margin: 0;
    overflow-x: auto;
}

.preview-container-mobile {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    min-height: 100vh;
    min-width: 450px;
}

.preview-wrapper {
    position: relative;
}

.device-info {
    text-align: center;
    color: var(--pv-text-secondary);
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
}

.preview-mode-info {
    text-align: center;
    margin-bottom: 12px;
}

/* モバイル版バッジ（小さめ） */
.preview-mobile .preview-mode-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    gap: 4px;
}

.preview-mobile .preview-mode-badge .material-icons {
    font-size: 12px;
}

/* ============================================
   iPhone 16 Pro フレーム - チタニウム風
   ============================================ */
.phone-frame {
    background: linear-gradient(145deg, #3a3a3c 0%, #1c1c1e 50%, #2c2c2e 100%);
    border-radius: 55px;
    padding: 10px;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
}

/* サイドボタン */
.phone-frame::before {
    content: '';
    position: absolute;
    right: -3px;
    top: 140px;
    width: 3px;
    height: 80px;
    background: linear-gradient(180deg, #4a4a4c, #2a2a2c);
    border-radius: 0 2px 2px 0;
}

.phone-frame::after {
    content: '';
    position: absolute;
    left: -3px;
    top: 120px;
    width: 3px;
    height: 35px;
    background: linear-gradient(180deg, #4a4a4c, #2a2a2c);
    border-radius: 2px 0 0 2px;
    box-shadow: 0 55px 0 #3a3a3c, 0 100px 0 #3a3a3c;
}

.phone-inner {
    background: #000;
    border-radius: 47px;
    overflow: hidden;
    width: 393px;
    position: relative;
}

/* ステータスバー */
.status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 28px 8px 28px;
    z-index: 100;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Dynamic Island */
.dynamic-island {
    position: absolute;
    top: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 126px;
    height: 37px;
    background: #000;
    border-radius: 22px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.status-left {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    letter-spacing: -0.3px;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 電波アイコン */
.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 12px;
}

.signal-bar {
    width: 3px;
    background: #000;
    border-radius: 1.5px;
}

.signal-bar:nth-child(1) { height: 3px; }
.signal-bar:nth-child(2) { height: 5px; }
.signal-bar:nth-child(3) { height: 8px; }
.signal-bar:nth-child(4) { height: 11px; }

/* Wi-Fiアイコン */
.wifi-icon {
    width: 17px;
    height: 12px;
    position: relative;
}

.wifi-icon::before {
    content: '';
    position: absolute;
    width: 17px;
    height: 17px;
    border: 2.5px solid transparent;
    border-top-color: #000;
    border-radius: 50%;
    top: -3px;
    left: 0;
    transform: rotate(-45deg);
}

.wifi-icon::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid transparent;
    border-top-color: #000;
    border-radius: 50%;
    top: 1px;
    left: 3.5px;
    transform: rotate(-45deg);
}

.wifi-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #000;
    border-radius: 50%;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* バッテリーアイコン */
.battery-icon {
    display: flex;
    align-items: center;
}

.battery-body {
    width: 27px;
    height: 13px;
    border: 1.5px solid rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    position: relative;
    padding: 2px;
}

.battery-level {
    background: #000;
    height: 100%;
    width: 85%;
    border-radius: 2px;
}

.battery-cap {
    width: 2px;
    height: 5px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0 2px 2px 0;
    margin-left: 1px;
}

/* コンテンツエリア（iframe） */
.content-area {
    height: 659px;
    background: var(--pv-bg-card);
    margin-top: 54px;
}

.content-area iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Safari UI（下部） */
.safari-bottom {
    position: relative;
    background: linear-gradient(180deg, rgba(250, 250, 252, 0.92) 0%, rgba(245, 245, 247, 0.98) 100%);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}

/* Safari URL バー */
.url-bar {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
}

.url-input {
    background: rgba(120, 120, 128, 0.12);
    border-radius: 12px;
    height: 36px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #3c3c43;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-weight: 400;
    letter-spacing: -0.2px;
    position: relative;
    box-shadow:
        inset 0 0 0 0.5px rgba(0, 0, 0, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.04);
}

.url-input .lock-icon {
    font-size: 13px;
    margin-right: 5px;
    opacity: 0.6;
}

/* Safari ナビゲーションバー */
.nav-bar {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
}

.nav-btn {
    width: 50px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007aff;
    font-size: 22px;
    border-radius: 10px;
    transition: background 0.15s ease;
}

.nav-btn:hover {
    background: rgba(0, 122, 255, 0.1);
}

.nav-btn.disabled {
    color: rgba(60, 60, 67, 0.3);
}

.nav-btn.disabled:hover {
    background: transparent;
}

/* ホームインジケーター */
.home-indicator-area {
    height: 34px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8px;
}

.home-indicator {
    width: 134px;
    height: 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 100px;
}

/* ============================================
   警告モーダル（PC・モバイル共通）
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--pv-bg-overlay);
    backdrop-filter: blur(5px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-content {
    background: var(--pv-bg-card);
    color: var(--pv-text-primary);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: var(--pv-shadow-modal);
    max-width: 450px;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s ease;
}

.modal-icon {
    font-size: 50px;
    margin-bottom: 15px;
}

.modal-title {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: bold;
    color: var(--pv-text-primary);
}

.modal-warning {
    margin: 0;
    font-size: 15px;
    color: #d9534f;
    font-weight: bold;
    line-height: 1.6;
}

.modal-note {
    margin: 15px 0 0 0;
    font-size: 13px;
    color: var(--pv-text-muted);
}

.modal-btn {
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.modal-btn:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

/* モバイル版モーダル調整 */
.preview-mobile .modal-content {
    padding: 25px 30px;
    max-width: 400px;
}

.preview-mobile .modal-btn {
    padding: 10px 25px;
    font-size: 14px;
}

/* ============================================
   レスポンシブ対応（モバイルプレビュー）
   ============================================ */
@media (max-width: 500px) {
    .preview-container-mobile {
        padding: 10px 0;
        /* スマホ幅では 450px の最小幅を解除し横スクロールを防ぐ */
        min-width: 0;
        width: 100%;
    }

    .preview-container-mobile .phone-frame {
        border-radius: 0;
        padding: 0;
        box-shadow: none;
    }

    .preview-container-mobile .phone-frame::before,
    .preview-container-mobile .phone-frame::after {
        display: none;
    }

    .preview-container-mobile .phone-inner {
        border-radius: 0;
        width: 100vw;
    }

    .preview-container-mobile .content-area {
        height: calc(100vh - 200px);
    }

    .device-info {
        display: none;
    }
}
