/* ========================================
   Secure PDF Viewer - Frontend Styles
   ======================================== */

.spv-container {
    position: relative;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 1.5em 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ツールバー */
.spv-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #1f2937;
    color: #e5e7eb;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 8px;
    user-select: none;
}

.spv-toolbar-left,
.spv-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* テーマのグローバルスタイルをリセットしてから独自スタイルを適用 */
.spv-container .spv-btn {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    line-height: 1;
    font-family: inherit;
    font-size: inherit;
    text-transform: none;
    text-decoration: none;
    letter-spacing: normal;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.spv-container .spv-btn:hover {
    background: #374151;
    color: #fff;
    text-decoration: none;
    box-shadow: none;
    border: none;
}

.spv-container .spv-btn:focus {
    outline: 2px solid #60a5fa;
    outline-offset: 1px;
    box-shadow: none;
    border: none;
}

.spv-container .spv-btn:active {
    background: #4b5563;
    box-shadow: none;
    border: none;
    transform: none;
}

.spv-container .spv-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.spv-container .spv-btn:disabled:hover {
    background: transparent;
    color: #d1d5db;
}

.spv-container .spv-page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #d1d5db;
}

.spv-container .spv-page-input {
    all: unset;
    width: 42px;
    text-align: center;
    border: 1px solid #4b5563;
    border-radius: 4px;
    background: #374151;
    color: #fff;
    font-size: 13px;
    padding: 3px 4px;
    box-sizing: border-box;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
}

.spv-container .spv-page-input:focus {
    outline: 2px solid #60a5fa;
    outline-offset: 0;
}

.spv-container .spv-page-input::-webkit-outer-spin-button,
.spv-container .spv-page-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ページスライダー */
.spv-container .spv-page-slider {
    all: unset;
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 4px;
    background: #4b5563;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0 4px;
    vertical-align: middle;
}

.spv-container .spv-page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.spv-container .spv-page-slider::-webkit-slider-thumb:hover {
    background: #fff;
}

.spv-container .spv-page-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
}

.spv-container .spv-page-slider::-moz-range-thumb:hover {
    background: #fff;
}

.spv-container .spv-page-slider::-moz-range-track {
    background: #4b5563;
    height: 4px;
    border-radius: 2px;
    border: none;
}

.spv-container .spv-zoom-level {
    font-size: 12px;
    min-width: 36px;
    text-align: center;
    color: #9ca3af;
}

/* ズームスライダー */
.spv-container .spv-zoom-slider {
    all: unset;
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 4px;
    background: #4b5563;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    margin: 0 2px;
    vertical-align: middle;
}

.spv-container .spv-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.spv-container .spv-zoom-slider::-webkit-slider-thumb:hover {
    background: #fff;
}

.spv-container .spv-zoom-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #d1d5db;
    border: none;
    cursor: pointer;
}

.spv-container .spv-zoom-slider::-moz-range-thumb:hover {
    background: #fff;
}

.spv-container .spv-zoom-slider::-moz-range-track {
    background: #4b5563;
    height: 4px;
    border-radius: 2px;
    border: none;
}

/* ビューア本体 */
.spv-viewer {
    position: relative;
    overflow: auto;
    background: #6b7280;
    text-align: center;
}

.spv-canvas-wrapper {
    display: inline-flex;
    justify-content: center;
    align-items: flex-start;
    padding: 8px;
}

.spv-canvas {
    display: block;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    background: #fff;
    /* canvasのピクセルサイズをCSS側で変形させない */
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

/* ローディング */
.spv-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background: rgba(31, 41, 55, 0.85);
    color: #e5e7eb;
    font-size: 14px;
    z-index: 10;
    transition: opacity 0.3s;
}

.spv-loading.spv-hidden {
    opacity: 0;
    pointer-events: none;
}

.spv-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spv-spin 0.7s linear infinite;
}

@keyframes spv-spin {
    to { transform: rotate(360deg); }
}

/* フルスクリーン */
.spv-container.spv-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
}

.spv-container.spv-fullscreen .spv-viewer {
    height: calc(100vh - 48px) !important;
}

/* 右クリック・選択の抑止（テキストレイヤーなしのため補助） */
.spv-viewer,
.spv-canvas {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* ========================================
   パスワード認証フォーム
   ======================================== */

.spv-password-wall {
    background: #f9fafb;
}

.spv-password-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    gap: 16px;
}

.spv-lock-icon {
    opacity: 0.5;
}

.spv-password-label {
    margin: 0;
    font-size: 15px;
    color: #4b5563;
    font-weight: 500;
}

.spv-password-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.spv-container .spv-password-input {
    all: unset;
    width: 220px;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #1f2937;
    box-sizing: border-box;
}

.spv-container .spv-password-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.spv-container .spv-password-submit {
    all: unset;
    padding: 10px 20px;
    background: #2563eb;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    box-sizing: border-box;
    white-space: nowrap;
}

.spv-container .spv-password-submit:hover {
    background: #1d4ed8;
}

.spv-container .spv-password-submit:active {
    background: #1e40af;
}

.spv-container .spv-password-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.spv-password-error {
    margin: 0;
    font-size: 13px;
    color: #dc2626;
    min-height: 20px;
}

/* ========================================
   ダウンロードボタン（ツールバー内・目立つスタイル）
   ======================================== */

.spv-container .spv-btn-download {
    all: unset;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 12px;
    border-radius: 6px;
    background: #2563eb;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    line-height: 1;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.spv-container .spv-btn-download:hover {
    background: #1d4ed8;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.spv-container .spv-btn-download:active {
    background: #1e40af;
}

.spv-container .spv-btn-download svg {
    flex-shrink: 0;
}

/* ========================================
   ロックボタン（ツールバー内）
   ======================================== */

.spv-container .spv-lock {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #d1d5db;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    line-height: 1;
}

.spv-container .spv-lock:hover {
    background: #374151;
    color: #fbbf24;
}

/* レスポンシブ */
@media (max-width: 480px) {
    .spv-container .spv-toolbar {
        padding: 6px 8px;
        font-size: 12px;
    }
    .spv-container .spv-btn {
        width: 28px;
        height: 28px;
    }
    .spv-container .spv-zoom-level {
        display: none;
    }
    .spv-container .spv-zoom-slider {
        display: none;
    }
    .spv-container .spv-page-slider {
        display: none;
    }
    .spv-container .spv-btn-download span {
        display: none;
    }
    .spv-container .spv-btn-download {
        padding: 0 8px;
        width: 28px;
        height: 28px;
        justify-content: center;
    }
}
