/*  弾道計算機 プロフェッショナル完全版 v2.7 (名前空間安全対応)
    変更点:
      - #bcalc-app      → #abcalc-app
      - #bcalc-chart    → #abcalc-chart
      - #hopup-group    → #abcalc-hopup-group
      - #sc-hopup-rpm   → #abcalc-sc-hopup-rpm
      - .extra-col      → .abcalc-extra-col
      - .unit-label     → .bcalc-unit-label
      - .tiny-btn       → .abcalc-tiny-btn (admin-view.php 側で定義済み)
*/

:root {
    --biz-blue: #2c3e50;
    --biz-accent: #1a73e8;
    --biz-light-blue: #f1f6fb;
    --biz-border: #dcdfe6;
    --text-dark: #333333;
    --negative-red: #d93025;
}

/* 全体コンテナ */
.bcalc-container {
    background: #ffffff;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--biz-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    max-width: 100%;
    margin: 10px auto;
    color: var(--text-dark) !important;
    box-sizing: border-box;
}

/* セレクター部分 */
.bcalc-unit-selector {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 35px;
    flex-wrap: wrap;
    gap: 20px;
}

/* ラベル高さ統一 */
.bcalc-form-item > label {
    min-height: 2.4em;
}

/* BC モデル行 */
.bcalc-bc-row {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: center !important;
    margin-bottom: 0 !important;
}

.bcalc-bc-model-select {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    padding: 8px 10px !important;
    border: 1px solid var(--biz-border) !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: var(--text-dark) !important;
    font-family: inherit !important;
    font-size: 1em !important;
    width: auto !important;
    pointer-events: auto !important;
}

.bcalc-bc-val-input {
    width: 90px !important;
    flex-shrink: 0 !important;
    padding: 8px 10px !important;
    border: 1px solid var(--biz-border) !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: var(--text-dark) !important;
    font-family: inherit !important;
    font-size: 1em !important;
    text-align: right;
}

.bcalc-show-extra-label {
    background: var(--biz-light-blue) !important;
    padding: 8px 16px !important;
    border-radius: 6px;
    border: 1px solid #d0e1f5;
    color: var(--biz-blue) !important;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
}

/* フォームレイアウト */
.bcalc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 40px;
    width: 100%;
}

.bcalc-form-item {
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column !important;
}

.bcalc-form-item label {
    display: block !important;
    margin-bottom: 8px !important;
    font-weight: 600 !important;
    color: var(--text-dark) !important;
    text-align: left !important;
}

.bcalc-form-item input[type="number"],
.bcalc-form-item input[type="text"],
.bcalc-form-item input[type="range"],
.bcalc-form-item select {
    display: block !important;
    width: 100% !important;
    margin-bottom: 8px !important;
    box-sizing: border-box !important;
}

.bcalc-form-item input[type="number"],
.bcalc-form-item input[type="text"],
.bcalc-form-item select {
    padding: 8px 10px !important;
    border: 1px solid var(--biz-border) !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    color: var(--text-dark) !important;
    font-family: inherit !important;
    font-size: 1em !important;
}

.bcalc-form-item > div {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.bcalc-form-item > div > input[type="number"],
.bcalc-form-item > div > select {
    display: block !important;
    width: 100% !important;
}

/* スライダー */
.bcalc-slider {
    width: 100% !important;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    -webkit-appearance: none;
    margin: 12px 0;
    pointer-events: none !important; /* トラッククリック無効、つまみのみ有効 */
}

.bcalc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    background: var(--biz-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: grab;
    pointer-events: auto !important;
}

.bcalc-slider::-webkit-slider-thumb:active { cursor: grabbing; }

.bcalc-slider::-moz-range-thumb {
    pointer-events: auto !important;
    cursor: grab;
}

/* テーブル */
table.bcalc-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.bcalc-table th {
    background-color: #f8f9fa !important;
    color: var(--biz-blue) !important;
    padding: 8px 4px !important;
    font-size: 16px !important;
    text-align: center !important;
    border-bottom: 1px solid var(--biz-border) !important;
    white-space: nowrap;
    min-width: 60px;
    line-height: 1.2 !important;
    vertical-align: bottom !important;
}

.bcalc-table td {
    padding: 8px 4px !important;
    border-bottom: 1px solid #eeeeee !important;
    text-align: center !important;
    color: var(--text-dark) !important;
    font-size: 16px !important;
    font-family: inherit !important;
    font-weight: 500;
    min-width: 60px;
}

.bcalc-table td.bcalc-negative {
    color: var(--negative-red) !important;
    font-weight: bold !important;
    font-size: 1.1em !important;
}

.bcalc-table td.bcalc-transonic {
    background-color: #fff3cd !important;
    color: #856404 !important;
    font-weight: bold !important;
    border-left: 3px solid #ffc107 !important;
}

/* 詳細列（.abcalc-extra-col） */
.bcalc-table th.abcalc-extra-col,
.bcalc-table td.abcalc-extra-col {
    /* 表示制御は JS 側で style.display を操作 */
}

/* チャート */
.bcalc-chart-container {
    border-radius: 8px;
    overflow: hidden;
}

#abcalc-chart {
    width: 100% !important;
    height: auto !important;
    display: block;
}

/* 単位表示 */
.bcalc-unit-label {
    font-size: 0.8em;
    color: #666;
    font-weight: normal;
}

/* ボタン類は pointer-events: none の影響を受けないよう強制許可 */
.bcalc-container button,
.bcalc-container input[type="radio"],
.bcalc-container input[type="checkbox"],
.bcalc-container select {
    pointer-events: auto !important;
}

/* ホップアップ：空気銃モード時に半透明で無効化 */
#abcalc-hopup-group.bcalc-disabled {
    opacity: 0.4 !important;
    pointer-events: none !important;
}
#abcalc-hopup-group:not(.bcalc-disabled) {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ホップアップ RPM スライダーつまみ（拡大） */
#abcalc-sc-hopup-rpm::-webkit-slider-thumb {
    background: #1a73e8 !important;
    width: 32px !important;
    height: 32px !important;
}

/* フォーム間隔 */
.bcalc-form-item {
    margin-top: 15px;
    margin-bottom: 5px;
}

/* ======================================================
   モード切り替えトグルスイッチ
   ====================================================== */
.bcalc-mode-switch-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 28px;
    padding: 14px 20px;
    background: var(--biz-light-blue);
    border: 1px solid #d0e1f5;
    border-radius: 50px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    user-select: none;
}

.bcalc-mode-label {
    font-size: 1em;
    font-weight: bold;
    color: #888;
    transition: color 0.25s;
    white-space: nowrap;
}

.bcalc-mode-switch-wrap[data-mode="airsoft"] #abcalc-mode-label-airsoft,
.bcalc-mode-switch-wrap[data-mode="airgun"]  #abcalc-mode-label-airgun {
    color: var(--biz-accent);
}

.bcalc-toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
    flex-shrink: 0;
}

.bcalc-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    pointer-events: auto !important;
}

.bcalc-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--biz-accent);
    border-radius: 30px;
    transition: background 0.25s;
    cursor: pointer;
    display: block;
    pointer-events: auto !important;
}

.bcalc-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    pointer-events: none;
}

.bcalc-toggle-switch input:checked ~ .bcalc-toggle-track .bcalc-toggle-thumb {
    transform: translateX(26px);
}

.bcalc-toggle-switch input:checked ~ .bcalc-toggle-track {
    background: #2e7d32;
}

.bcalc-toggle-switch input:focus-visible ~ .bcalc-toggle-track {
    outline: 3px solid #90caf9;
    outline-offset: 2px;
}

/* ======================================================
   モバイル (max-width: 600px)
   ====================================================== */
@media screen and (max-width: 600px) {
    .bcalc-container { padding: 12px !important; }
    .bcalc-grid { grid-template-columns: 1fr !important; }
    .bcalc-form-item { width: 100% !important; box-sizing: border-box !important; }
    .bcalc-form-item input[type="number"],
    .bcalc-form-item input[type="text"],
    .bcalc-form-item input[type="range"],
    .bcalc-form-item select { display: block !important; width: 100% !important; box-sizing: border-box !important; }
    .bcalc-slider { width: 100% !important; box-sizing: border-box !important; }
    .bcalc-bc-row { flex-direction: row !important; }
    .bcalc-bc-val-input { width: 80px !important; }
    table.bcalc-table { table-layout: fixed !important; width: 100% !important; max-width: 100% !important; }
    .bcalc-table th, .bcalc-table td { padding: 6px 2px !important; text-align: center !important; font-size: 13px !important; word-break: break-all; }
    .bcalc-table td.bcalc-energy-j { font-size: 11px !important; }
}
