/* ==========================================================================
   共通マスターピッカー（点検者・設備士 / 測定機器）
   - 帳票プレビュー左余白の緑チップ（印刷非表示）
   - 入力パネル内の呼び出し・登録ボタン
   - 呼び出し＆登録・編集・削除・一括反映モーダル
   ========================================================================== */

/* 帳票プレビュー上の緑チップ */
.bousai-master-chip {
    position: absolute;
    z-index: 35;
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    border: 1.5px solid #1e8449;
    border-radius: 6px;
    background: #27ae60;
    color: #ffffff;
    font-size: 15px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.bousai-master-chip:hover {
    background: #2ecc71;
    border-color: #27ae60;
    transform: translateY(-1px) scale(1.06);
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.45);
}

.bousai-master-chip:active {
    transform: scale(0.95);
}

/* 軽量CSSツールチップ */
.bousai-master-chip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 26, 22, 0.94);
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid #27ae60;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.14s ease, visibility 0.14s ease;
    z-index: 60;
}

.bousai-master-chip[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 入力パネル内の統一緑ボタン */
.bousai-master-panel-btn-wrap {
    display: flex;
    gap: 6px;
    margin: 0 0 10px 0;
}

.bousai-master-panel-btn {
    width: 100%;
    padding: 8px 11px;
    background: #27ae60;
    color: #ffffff;
    border: 1px solid #2ecc71;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.bousai-master-panel-btn:hover {
    background: #219150;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.35);
}

.bousai-master-panel-btn:active {
    transform: scale(0.98);
}

/* モーダルオーバーレイ */
.bousai-master-modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(2px);
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
}

.bousai-master-modal {
    width: 100%;
    max-width: 720px;
    max-height: 88vh;
    background: #1e2220;
    color: #f1f5f2;
    border: 1px solid #2e4a38;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

html[data-theme="light"] .bousai-master-modal {
    background: #ffffff;
    color: #1f2937;
    border-color: #cbd5e1;
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.25);
}

.bousai-master-modal * {
    box-sizing: border-box;
}

/* モーダルヘッダー */
.bmp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #2f3b34;
    background: #171c19;
    flex-shrink: 0;
}

html[data-theme="light"] .bmp-header {
    background: #f0fdf4;
    border-bottom-color: #d1fae5;
}

.bmp-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    color: #2ecc71;
    display: flex;
    align-items: center;
    gap: 8px;
}

html[data-theme="light"] .bmp-title {
    color: #15803d;
}

.bmp-close-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #9ca3af;
    font-size: 1.25rem;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bmp-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

html[data-theme="light"] .bmp-close-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #111827;
}

/* モーダル本文 */
.bmp-body {
    padding: 14px 18px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 上部ツールバー */
.bmp-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.bmp-btn {
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}

.bmp-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.bmp-btn-green {
    background: #27ae60;
    border-color: #2ecc71;
    color: #ffffff;
}

.bmp-btn-green:hover:not(:disabled) {
    background: #219150;
}

.bmp-btn-teal {
    background: #0d9488;
    border-color: #14b8a6;
    color: #ffffff;
}

.bmp-btn-teal:hover:not(:disabled) {
    background: #0f766e;
}

.bmp-btn-gray {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.bmp-btn-gray:hover:not(:disabled) {
    background: #4b5563;
}

html[data-theme="light"] .bmp-btn-gray {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

html[data-theme="light"] .bmp-btn-gray:hover:not(:disabled) {
    background: #e2e8f0;
}

.bmp-btn-red {
    background: #3f1d1d;
    border-color: #7f1d1d;
    color: #fca5a5;
}

.bmp-btn-red:hover:not(:disabled) {
    background: #991b1b;
    color: #ffffff;
}

html[data-theme="light"] .bmp-btn-red {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

html[data-theme="light"] .bmp-btn-red:hover:not(:disabled) {
    background: #dc2626;
    color: #ffffff;
}

/* 検索行 */
.bmp-search-row {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.bmp-input,
.bmp-select,
.bmp-textarea {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #3f4a43;
    background: #141816;
    color: #f3f4f6;
    font-size: 0.85rem;
    outline: none;
}

.bmp-input:focus,
.bmp-select:focus,
.bmp-textarea:focus {
    border-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.22);
}

html[data-theme="light"] .bmp-input,
html[data-theme="light"] .bmp-select,
html[data-theme="light"] .bmp-textarea {
    background: #ffffff;
    color: #111827;
    border-color: #cbd5e1;
}

/* アイテムカード一覧 */
.bmp-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bmp-empty {
    text-align: center;
    padding: 28px 14px;
    color: #9ca3af;
    font-size: 0.86rem;
    border: 1px dashed #374151;
    border-radius: 8px;
}

html[data-theme="light"] .bmp-empty {
    color: #64748b;
    border-color: #cbd5e1;
}

.bmp-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #323c36;
    background: #252b27;
    transition: border-color 0.14s ease, background 0.14s ease;
}

.bmp-card:hover {
    border-color: #27ae60;
    background: #28322c;
}

.bmp-card.bmp-selected {
    border-color: #2ecc71;
    background: #1d3225;
}

html[data-theme="light"] .bmp-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .bmp-card:hover {
    background: #f0fdf4;
    border-color: #27ae60;
}

html[data-theme="light"] .bmp-card.bmp-selected {
    background: #dcfce7;
    border-color: #16a34a;
}

.bmp-card-check {
    width: 18px !important;
    height: 18px !important;
    display: inline-block !important;
    accent-color: #27ae60;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

.bmp-card-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.bmp-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.bmp-tag {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: #1d3540;
    color: #93c5fd;
    border: 1px solid #2563eb;
}

html[data-theme="light"] .bmp-tag {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.bmp-qual-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.71rem;
    background: #183022;
    color: #6ee7b7;
    border: 1px solid #27ae60;
    margin: 2px 4px 0 0;
}

html[data-theme="light"] .bmp-qual-badge {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.bmp-card-meta {
    font-size: 0.76rem;
    color: #9ca3af;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

html[data-theme="light"] .bmp-card-meta {
    color: #475569;
}

.bmp-card-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.bmp-card-actions .bmp-btn {
    padding: 5px 9px;
    font-size: 0.75rem;
}

/* マージ確認バナー */
.bmp-merge-banner {
    background: #1b2e22;
    border: 1px solid #27ae60;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

html[data-theme="light"] .bmp-merge-banner {
    background: #f0fdf4;
    border-color: #22c55e;
}

.bmp-merge-banner p {
    margin: 0 0 10px 0;
    font-size: 0.84rem;
    line-height: 1.5;
}

/* 登録・編集フォーム */
.bmp-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.bmp-form-full {
    grid-column: 1 / -1;
}

.bmp-field-label {
    display: block;
    font-size: 0.76rem;
    font-weight: 600;
    color: #a7b4ac;
    margin-bottom: 4px;
}

html[data-theme="light"] .bmp-field-label {
    color: #475569;
}

.bmp-req {
    color: #f87171;
    margin-left: 3px;
}

.bmp-qual-section {
    border-top: 1px solid #323c36;
    padding-top: 12px;
    margin-top: 8px;
}

html[data-theme="light"] .bmp-qual-section {
    border-top-color: #e2e8f0;
}

.bmp-qual-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto;
    gap: 6px;
    align-items: end;
    padding: 8px;
    border-radius: 6px;
    background: #171c19;
    border: 1px solid #2e3832;
    margin-bottom: 8px;
}

html[data-theme="light"] .bmp-qual-row {
    background: #f8fafc;
    border-color: #e2e8f0;
}

/* フッター（測定機器の一括反映バー・フォーム保存バー） */
.bmp-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid #2f3b34;
    background: #171c19;
    flex-shrink: 0;
}

html[data-theme="light"] .bmp-footer {
    background: #f8fafc;
    border-top-color: #e2e8f0;
}

.bmp-mode-group {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
}

.bmp-mode-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    margin: 0;
}

.bmp-mode-label input[type="radio"] {
    display: inline-block !important;
    width: auto !important;
    margin: 0;
    accent-color: #27ae60;
}

/* トースト通知 */
.bmp-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #1b3b28;
    color: #ffffff;
    border: 1px solid #2ecc71;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.86rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    z-index: 13000;
    pointer-events: none;
    animation: bmpToastIn 0.18s ease;
}

@keyframes bmpToastIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 680px) {
    .bmp-form-grid {
        grid-template-columns: 1fr;
    }
    .bmp-qual-row {
        grid-template-columns: 1fr 1fr;
    }
    .bmp-card {
        flex-wrap: wrap;
    }
}

/* 印刷・PDF出力時は一切表示しない */
@media print {
    button.bousai-master-chip,
    .bousai-master-chip,
    .no-print-chip,
    .bousai-master-panel-btn-wrap,
    .bousai-master-panel-btn,
    .bousai-master-modal-overlay,
    .bmp-toast {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}
