/* ページ切替タブ（共通ヘッダー内） */
.page-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #4a90d9;
}
.page-tab {
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: bold;
    text-decoration: none;
    border: 1px solid #4a90d9;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #eef4fb;
    color: #4a90d9;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}
.page-tab-active {
    background: #4a90d9;
    color: #fff;
}
.page-tab:not(.page-tab-active):hover {
    background: #d4e6f7;
}

/* number input のスピナーボタンを非表示 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textbox;
    appearance: textbox;
}

/* Dash dcc.Input の増減ボタンを非表示 */
.dash-input-group .input-group-addon {
    display: none !important;
}
.dash-input-group {
    flex-wrap: nowrap;
}
.dash-input-group input {
    border-radius: 4px !important;
}

/* マニュアルモーダル */
.manual-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.manual-modal-content {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    width: 90vw;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.manual-modal-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
}
.manual-modal-content th,
.manual-modal-content td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
}
.manual-modal-content th {
    background: #f5f5f5;
}

/* ソルバー計算中スピナー */
@keyframes solver-spin {
    to { transform: rotate(360deg); }
}

/* ── dash_daq NumericInput の余白調整 ── */
.numeric-input {
    margin: 0 !important;
}
.numeric-input input {
    font-size: 1rem !important;
}

/* ── PC: 絆入力を7列1行に固定 ── */
.bond-fields {
    display: grid !important;
    grid-template-columns: repeat(7, auto) !important;
    gap: 8px !important;
}

/* ── モバイル対応 ── */
@media (max-width: 768px) {
    /* 2カラム → 縦積み */
    .main-columns {
        flex-direction: column !important;
        gap: 12px !important;
    }

    /* サイドバーを横幅いっぱいに */
    .sidebar {
        width: 100% !important;
        position: static !important;
    }

    /* メインコンテンツを横幅いっぱいに */
    .main-columns > div:last-child {
        width: 100% !important;
    }

    /* ページ全体のパディングを縮小 */
    .page-container {
        padding: 10px !important;
    }

    /* 共通ヘッダー */
    .site-header-wrap {
        padding: 10px 10px 0 !important;
    }
    .site-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
    }
    .site-header > div {
        margin-left: 0 !important;
    }
    .site-title {
        font-size: 1.2rem !important;
    }

    /* タブバー: はみ出す場合は横スクロール */
    .page-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .page-tab {
        padding: 8px 10px !important;
        font-size: 0.8rem !important;
    }

    /* ヘッダー行: 縦積み中央揃え */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }
    .page-header h1 {
        font-size: 1.25rem !important;
    }
    .page-header-right {
        width: 100% !important;
        justify-content: space-between !important;
        margin-left: 0 !important;
    }

    /* 衣装カード */
    .student-card {
        padding: 10px !important;
    }
    .student-card-header input[type="text"] {
        font-size: 0.9rem !important;
    }

    /* 衣装カード内の絆入力: 4列固定 → 4+3 の2行 */
    .bond-fields {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    .bond-fields > div {
        min-width: 0 !important;
    }
    .bond-fields input {
        font-size: 0.95rem !important;
        padding: 6px 4px !important;
    }

    /* 絆ランク入力行 */
    .bond-rank-row {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
        gap: 8px !important;
    }
    .bond-rank-section {
        padding: 10px !important;
    }

    /* 全ボタン: タッチしやすい最小高さ */
    button,
    .dash-dropdown .Select-control {
        min-height: 44px !important;
    }

    /* 衣装追加ボタン */
    .add-student-btn {
        width: 100% !important;
        padding: 10px 16px !important;
        font-size: 1rem !important;
    }

    /* 計算ボタン: 画面下部に固定 */
    .calc-btn-wrapper {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        padding: 10px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(8px) !important;
        -webkit-backdrop-filter: blur(8px) !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1) !important;
        z-index: 100 !important;
    }
    .calc-btn-wrapper button {
        border-radius: 8px !important;
    }

    /* 結果エリア: 固定ボタン分の余白 */
    .chart-result-area {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 72px !important;
    }

    /* 結果テーブルの可読性向上 */
    .chart-result-area table {
        font-size: 0.85rem !important;
    }
    .chart-result-area th,
    .chart-result-area td {
        padding: 6px 8px !important;
        white-space: nowrap;
    }

    /* プリセットセクション: ドロップダウンを1行、ボタンを次の行 */
    .preset-section .dash-dropdown {
        width: 100% !important;
    }
    #load-preset-btn {
        padding: 8px 16px !important;
    }

    /* モーダル */
    .manual-modal-content {
        width: 95vw !important;
        max-height: 90vh !important;
        padding: 16px !important;
        border-radius: 8px !important;
    }

    /* 削除ボタン: タップしやすく */
    .remove-student-btn {
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* ── 小さいスマホ対応 (360px以下) ── */
@media (max-width: 360px) {
    .page-header h1 {
        font-size: 1.1rem !important;
    }
    .bond-fields {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}
