/* ============================================================================
   stock-modal.css - らねこシステム 在庫マネージャー専用 スタイルシート
   メインCSSに干渉しないプレフィックス設計
   ============================================================================ */

#stock-manager-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 24900;
    align-items: center;
    justify-content: center;
}

.stock-modal-container {
    background: #ffffff;
    width: 96%;
    max-width: 1380px;
    height: 92vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    border-top: 5px solid #059669;
}

/* ヘッダー */
.stock-modal-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    flex-shrink: 0;
}

.stock-modal-title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-modal-title {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    user-select: text;
}

.stock-modal-subtitle {
    font-size: 11.5px;
    color: #64748b;
    user-select: text;
}

/* ツールバー */
.stock-modal-toolbar {
    padding: 10px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stock-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px;
    border: 3px solid #64748b;
    border-radius: 9px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stock-filter-btn {
    border: 2px solid #cbd5e1;
    background: #ffffff;
    color: #64748b;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.stock-filter-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #334155;
}

/* 要対応のみ表示（注意・警告）: 通常のアクティブ時（要対応0件時） */
#btn-filter-required.active {
    background: #dc2626 !important;
    border-color: #b91c1c !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(220, 38, 38, 0.4);
}

/* 要対応が1件以上ある場合: アクティブ時の呼吸パルス発光アニメーション */
@keyframes stockPulseRedActive {
    0%, 100% {
        background-color: #dc2626;
        border-color: #b91c1c;
        color: #ffffff;
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% {
        background-color: #ef4444;
        border-color: #f87171;
        color: #ffffff;
        box-shadow: 0 0 14px 3px rgba(239, 68, 68, 0.75);
    }
}

/* 要対応が1件以上ある場合: 非アクティブ時（全件・非表示表示中）の呼吸パルスアニメーション */
@keyframes stockPulseRedInactive {
    0%, 100% {
        background-color: #ffffff;
        border-color: #f87171;
        color: #dc2626;
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
    50% {
        background-color: #fee2e2;
        border-color: #ef4444;
        color: #991b1b;
        box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.5);
    }
}

/* パルス点滅適用ルール（transition競合を排除してスムーズに動作） */
#btn-filter-required.stock-pulse-warning.active {
    animation: stockPulseRedActive 2.3s ease-in-out infinite !important;
    transition: none !important;
    font-weight: 800 !important;
}

#btn-filter-required.stock-pulse-warning:not(.active) {
    animation: stockPulseRedInactive 2.3s ease-in-out infinite !important;
    transition: none !important;
    font-weight: 800 !important;
}

/* 全件表示: 選択時はしっかり濃い青 */
#btn-filter-all.active {
    background: #2563eb !important;
    border-color: #1d4ed8 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.4);
}

/* 非表示品目: 選択時はしっかり濃い紫 */
#btn-filter-hidden.active {
    background: #7c3aed !important;
    border-color: #6d28d9 !important;
    color: #ffffff !important;
    box-shadow: 0 2px 5px rgba(124, 58, 237, 0.4);
}

.stock-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 一覧テーブルエリア */
.stock-table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
    background: #ffffff;
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
    user-select: text;
}

.stock-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 9px 12px;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    user-select: text;
}

.stock-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    user-select: text;
}

/* チェックボックスセル（セル全体ボタン化） */
.stock-check-cell {
    cursor: pointer !important;
    user-select: none !important;
    transition: background-color 0.15s ease;
    text-align: center;
}

.stock-check-cell:hover {
    background-color: rgba(37, 99, 235, 0.12) !important;
}

.stock-check-cell input[type="checkbox"] {
    cursor: pointer;
    transform: scale(1.15);
}

/* 行状態ハイライト */
.stock-row-warning {
    background: #fef2f2 !important;
}

.stock-row-caution {
    background: #fffbeb !important;
}

.stock-row-completed td {
    box-shadow: inset 0 -3px 0 #2563eb;
}

.stock-row-completed td:first-child {
    border-left: 6px solid #2563eb !important;
}

.stock-row-completed .stock-check-cell {
    background-color: #dbeafe !important;
}

/* バッジ */
.stock-badge-warning {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 800;
    color: #dc2626;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    white-space: nowrap;
}

.stock-badge-caution {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 800;
    color: #d97706;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    white-space: nowrap;
}

.stock-badge-normal {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 600;
    color: #16a34a;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    white-space: nowrap;
}

.stock-badge-dismissed {
    display: inline-block;
    padding: 2px 7px;
    font-size: 10.5px;
    font-weight: 700;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    white-space: nowrap;
}

/* ステッパー＆数値入力 */
.stock-stepper-box {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    overflow: hidden;
    background: #ffffff;
}

.stock-stepper-btn {
    border: none;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
    width: 24px;
    height: 26px;
    cursor: pointer;
    transition: background 0.1s;
}

.stock-stepper-btn:hover {
    background: #e2e8f0;
}

.stock-input-val {
    border: none;
    width: 44px;
    height: 26px;
    text-align: center;
    font-size: 12.5px;
    font-weight: 700;
    color: #0f172a;
    box-sizing: border-box;
}

.stock-copy-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 4px;
}

.stock-copy-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* モール直行ボタン */
.stock-mall-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
}

.stock-btn-rakuten {
    background: #ffffff;
    color: #dc2626;
    border: 1px solid #dc2626;
}

.stock-btn-rakuten:hover {
    background: #fef2f2;
    border-color: #b91c1c;
    color: #b91c1c;
}

.stock-btn-au {
    background: #ffffff;
    color: #ea580c;
    border: 1px solid #ea580c;
}

.stock-btn-au:hover {
    background: #fff7ed;
    border-color: #c2410c;
    color: #c2410c;
}

.stock-btn-yahoo {
    background: #ffffff;
    color: #e11d48;
    border: 1px solid #e11d48;
    box-sizing: border-box;
}

.stock-btn-yahoo:hover {
    background: #fff1f2;
    border-color: #be123c;
    color: #be123c;
}


/* ============================================================================
   親商品グループ カード化＆枠囲みデザイン（グループ明確差別化）
   ============================================================================ */

/* グループ間スペーサー（余白行） */
.stock-group-spacer td {
    height: 12px !important;
    background: #f1f5f9 !important;
    border: none !important;
    padding: 0 !important;
}

/* --- パターン1: まとめられた親商品グループ（バリエーション2件以上） --- */
.stock-group-multi.stock-parent-header-row td {
    background: #eff6ff !important;
    border-top: 3px solid #2563eb !important;
    border-bottom: 1px solid #bfdbfe !important;
    padding: 9px 12px;
}
.stock-group-multi td:first-child {
    border-left: 4px solid #2563eb !important;
}
.stock-group-multi td:last-child {
    border-right: 2px solid #bfdbfe !important;
}

/* まとめグループの配下子SKU行 */
.stock-branch-multi td {
    border-bottom: 1px solid #e2e8f0;
}
.stock-branch-multi td:first-child {
    border-left: 4px solid #2563eb !important;
}
.stock-branch-multi td:last-child {
    border-right: 2px solid #bfdbfe !important;
}
.stock-branch-multi.stock-group-last-row td {
    border-bottom: 3px solid #2563eb !important;
}

/* --- パターン2: 親コード未設定グループ --- */
.stock-group-unassigned.stock-parent-header-row td {
    background: #fffbeb !important;
    border-top: 2px dashed #f59e0b !important;
    border-bottom: 1px solid #fde68a !important;
    padding: 8px 12px;
}
.stock-group-unassigned td:first-child {
    border-left: 4px solid #f59e0b !important;
}
.stock-group-unassigned td:last-child {
    border-right: 1px solid #fde68a !important;
}
.stock-branch-unassigned td {
    border-bottom: 1px solid #fef3c7;
}
.stock-branch-unassigned td:first-child {
    border-left: 4px solid #f59e0b !important;
}
.stock-branch-unassigned td:last-child {
    border-right: 1px solid #fde68a !important;
}
.stock-branch-unassigned.stock-group-last-row td {
    border-bottom: 2px solid #f59e0b !important;
}

/* --- パターン3: 単品商品グループ（バリエーション1件のみ） --- */
.stock-group-single.stock-parent-header-row td {
    background: #f8fafc !important;
    border-top: 2px solid #cbd5e1 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 8px 12px;
}
.stock-group-single td:first-child {
    border-left: 4px solid #94a3b8 !important;
}
.stock-group-single td:last-child {
    border-right: 1px solid #e2e8f0 !important;
}
.stock-branch-single td {
    border-bottom: 1px solid #f1f5f9;
}
.stock-branch-single td:first-child {
    border-left: 4px solid #94a3b8 !important;
}
.stock-branch-single td:last-child {
    border-right: 1px solid #e2e8f0 !important;
}
.stock-branch-single.stock-group-last-row td {
    border-bottom: 2px solid #cbd5e1 !important;
}

/* SKUコード部分選択ハイライト（視認性向上） */
.sku-copyable-target::selection {
    background-color: #38bdf8 !important;
    color: #0f172a !important;
}

.sku-copyable-target::-moz-selection {
    background-color: #38bdf8 !important;
    color: #0f172a !important;
}

/* 商品コードダブルクリック編集・ホバーリンクスタイル */
.stock-clickable-sku {
    cursor: pointer;
    user-select: text;
    transition: color 0.15s;
}
.stock-clickable-sku:hover {
    color: #2563eb !important;
}
.stock-sub-sku-badge {
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.stock-sub-sku-badge:hover {
    background-color: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #1e293b !important;
}

/* 親商品サムネイル ＆ ホバー拡大プレビュー */
.stock-parent-thumb-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.stock-parent-thumb-wrap:hover .stock-parent-thumb-hover {
    display: block !important;
}

/* --- モール直行連携・親商品グループ選択枠強調（赤色の8px実線枠で強調） --- */
.stock-parent-header-row.stock-parent-selected td {
    border-top: 8px solid #dc2626 !important;
}
.stock-parent-header-row.stock-parent-selected td:first-child {
    border-left: 8px solid #dc2626 !important;
}
.stock-parent-header-row.stock-parent-selected td:last-child {
    border-right: 8px solid #dc2626 !important;
}

tr:not(.stock-parent-header-row).stock-parent-selected td:first-child {
    border-left: 8px solid #dc2626 !important;
}
tr:not(.stock-parent-header-row).stock-parent-selected td:last-child {
    border-right: 8px solid #dc2626 !important;
}
tr:not(.stock-parent-header-row).stock-group-last-row.stock-parent-selected td {
    border-bottom: 8px solid #dc2626 !important;
}
.stock-parent-header-row.stock-parent-selected.stock-group-last-row td,
.stock-parent-header-row.stock-parent-selected.stock-parent-collapsed td {
    border-bottom: 8px solid #dc2626 !important;
}

