/* ===========================
   席替えジェネレーター
   =========================== */

/* === 印刷（A4横向き・座席最大） === */
@page {
    size: A4 landscape;
    margin: 8mm;
}

@media print {
    html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }

    /* ロゴ・フッター・広告・操作UIをすべて非表示 */
    .class-mode-toggle,
    .ad-left, .ad-right, .ad-horizontal,
    header, footer,
    .no-print,
    .instructions { display: none !important; }

    .site-wrapper { display: block !important; }
    .container { max-width: 100%; padding: 0; margin: 0; box-shadow: none; }

    /* 結果エリアのみ表示 */
    .result-area { display: block !important; }
    .view-tabs { display: none !important; }
    .print-only { display: block !important; }

    /* 座席表をA4横向きページいっぱいに */
    .seat-view {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 2mm);
        padding: 0;
    }

    .blackboard-bar {
        font-size: 9pt;
        padding: 2px 8px;
        margin-bottom: 3px;
        flex-shrink: 0;
        display: inline-block;
        align-self: center;
    }

    .seat-grid-result {
        flex: 1;
        min-height: 0;
        gap: 2px;
    }

    .result-cell {
        min-height: unset;
        font-size: var(--print-name-size, 14pt);
        font-weight: 700;
        border: 0.5pt solid #555;
        border-radius: 1px;
        padding: 0;
        flex-direction: column;
        gap: 0;
    }

    .cell-furigana {
        font-size: 0.5em;   /* セルのfont-size基準で半分 */
        color: #555;
    }

    .result-cell.inactive { background: #ececec !important; border-color: #ccc !important; }
    .result-cell.empty { border-style: dashed; }
}

/* instructions / step-section / section-title / hint は common/css/components.css で定義 */

/* === フォームグループ === */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
}

/* === 名簿テキストエリア === */
#nameInput {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1.5px solid #ccc;
    border-radius: var(--border-radius-small);
    font-size: 0.95rem;
    font-family: var(--font-family-mono);
    line-height: 1.7;
    resize: vertical;
    transition: border-color 0.2s;
}

#nameInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 96, 100, 0.1);
}

/* === カウントラベル === */
.count-label {
    text-align: right;
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 500;
    margin-top: 4px;
}

/* === アクションバー === */
.action-bar {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    padding: var(--spacing-md) 0;
}

/* step-badge は common/css/components.css で定義 */

/* === 黒板ラベル === */
.blackboard-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #333;
    color: white;
    padding: 5px 14px;
    border-radius: var(--border-radius-small);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.print-only {
    display: none;
}

/* === レイアウト入力 === */
.layout-inputs {
    display: flex;
    align-items: flex-end;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-md);
}

.layout-inputs .form-group {
    margin-bottom: 0;
}

.layout-inputs input[type="number"] {
    width: 80px;
}

/* === グリッドエディタ === */
.grid-area-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grid-editor-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.grid-col-labels {
    display: flex;
    gap: 4px;
    margin-left: 32px;
    margin-bottom: 2px;
}

.grid-col-labels span {
    width: 90px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--accent-color);
    flex-shrink: 0;
}

.grid-body {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.grid-row-labels {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 28px;
    flex-shrink: 0;
}

.grid-row-labels span {
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    color: var(--accent-color);
}

.seat-grid-editor {
    display: grid;
    gap: 4px;
}

.seat-cell {
    width: 90px;
    height: 62px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-small);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: var(--primary-color);
    font-size: 1.1rem;
    transition: var(--transition-smooth);
    user-select: none;
}

.seat-cell:hover {
    background: rgba(0, 96, 100, 0.08);
}

.seat-cell.inactive {
    background: #e8e8e8;
    border-color: #bbb;
    color: #bbb;
}

.seat-cell.inactive:hover {
    background: #ddd;
}

/* 固定席セル */
.seat-cell.fixed {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    cursor: default;
    font-size: 0.65rem;
    line-height: 1.2;
    padding: 2px;
}

.seat-cell.fixed:hover {
    background: var(--primary-color);
    opacity: 0.9;
}

.cell-name {
    text-align: center;
    word-break: break-all;
    overflow: hidden;
    max-height: 100%;
}

/* 選択モード */
.seat-cell.selectable {
    border-color: var(--warning-color);
    cursor: crosshair;
    animation: seat-pulse 1.2s infinite;
}

.seat-cell.selectable:hover {
    background: rgba(245, 124, 0, 0.15);
    border-color: var(--warning-color);
}

.seat-cell.inactive.selectable {
    animation: none;
    cursor: not-allowed;
}

@keyframes seat-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 124, 0, 0.35); }
    50% { box-shadow: 0 0 0 5px rgba(245, 124, 0, 0); }
}

/* 選択中メッセージ */
.selection-message {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--warning-color);
    color: white;
    padding: 8px 16px;
    border-radius: var(--border-radius-small);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 10px;
}

/* 固定席 位置表示 */
.fixed-position {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary-color);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.condition-entry.selecting {
    border-color: var(--warning-color);
    background: rgba(245, 124, 0, 0.05);
}

.seat-count-info {
    margin-top: 10px;
    font-size: 0.95rem;
    color: var(--accent-color);
    font-weight: 500;
}

/* === 条件ブロック === */
.condition-block {
    background: var(--background-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.condition-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0 0 var(--spacing-sm) 0;
}

.empty-condition {
    color: #999;
    font-size: 0.92rem;
    font-style: italic;
    margin: 0 0 var(--spacing-sm) 0;
}

.condition-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1.5px solid #ddd;
    border-radius: var(--border-radius-small);
    padding: 10px 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    transition: border-color 0.2s;
}

.condition-entry.failing {
    border-color: var(--danger-color);
    background: rgba(244, 67, 54, 0.04);
}

.condition-label {
    font-size: 0.92rem;
    color: var(--accent-color);
    white-space: nowrap;
}

.fixed-name,
.pair-name-a,
.pair-name-b {
    width: 140px;
    font-size: 0.92rem;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-small);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.fixed-name:focus,
.pair-name-a:focus,
.pair-name-b:focus {
    outline: none;
    border-color: var(--primary-color);
}

.pair-type,
.pair-range {
    font-size: 0.92rem;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius-small);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.pair-type:focus,
.pair-range:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* === 結果エリア === */
.view-tabs {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.view-tab {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: var(--border-radius);
    padding: 8px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.view-tab.active {
    background: var(--primary-color);
    color: white;
}

.view-tab:hover:not(.active) {
    background: rgba(0, 96, 100, 0.08);
}

.print-btn {
    margin-left: auto;
}

.seat-view {
    padding: var(--spacing-sm) 0;
}

.seat-grid-result {
    display: grid;
    gap: 6px;
    width: 100%;
}

.result-cell {
    min-height: 70px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius-small);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 2px;
    overflow: hidden;
    background: white;
    gap: 0;
}

.cell-name {
    white-space: nowrap;
    line-height: 1.1;
}

.cell-furigana {
    display: block;
    font-size: 0.5em;   /* セルのfont-size基準で常に半分 */
    font-weight: 400;
    color: #666;
    line-height: 1.2;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.result-cell .cell-name {
    display: block;
    white-space: nowrap;
    line-height: 1.1;
}

.result-cell.inactive {
    background: #f0f0f0;
    border-color: #ddd;
    color: transparent;
}

.result-cell.empty {
    background: rgba(0, 96, 100, 0.02);
    border-style: dashed;
    border-color: #ccc;
}

/* === モーダル === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal {
    background: white;
    border-radius: var(--border-radius-large);
    padding: var(--spacing-xl);
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-xlarge);
}

.confirm-modal h3 {
    margin: 0 0 var(--spacing-md) 0;
    color: var(--warning-color);
}

.confirm-modal p {
    margin: 0 0 var(--spacing-lg) 0;
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}
