/**
 * Equation Solver - Mobile Optimized
 * 方程式ソルバー - スマホ最適化版
 *
 * Strategy:
 * - 3つのタブ（一次方程式、二次方程式、連立方程式）をモバイル対応
 * - 入力と結果の縦配置（モバイル）、横配置（デスクトップ）
 * - タブ切り替えUIの最適化
 *
 * Version: 1.0
 * Created: 2025-11-02
 */

/* ========================================
   1. タブナビゲーション
   ======================================== */

.equation-type-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e5e7eb;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    padding: 10px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    background: #f3f4f6;
}

.tab-btn.active {
    color: #0066cc;
    border-bottom-color: #0066cc;
    font-weight: 600;
}

/* ========================================
   2. ソルバーパネル
   ======================================== */

.solver-panel {
    display: none;
}

.solver-panel.active {
    display: block;
}

.solver-panel h3 {
    font-size: 1.2em;
    color: #374151;
    margin-bottom: 12px;
}

.equation-format {
    font-size: 1.1em;
    font-family: 'Courier New', monospace;
    color: #0066cc;
    margin: 12px 0;
    padding: 12px;
    background: #f0f9ff;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
    text-align: center;
}

/* ========================================
   3. 入力フォーム（モバイル優先）
   ======================================== */

.equation-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.input-group input,
.equation-row input {
    padding: 10px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}

.input-group input:focus,
.equation-row input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* 連立方程式の行 */
.equation-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.equation-row label {
    min-width: 80px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.equation-row input {
    flex: 1;
    min-width: 60px;
    max-width: 80px;
}

.equation-row span {
    font-weight: 500;
    color: #6b7280;
    font-size: 14px;
}

/* 計算ボタン */
.btn-primary {
    width: 100%;
    padding: 12px;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
}

.btn-primary:hover {
    background: #0052a3;
}

.btn-primary:active {
    background: #003d7a;
}

/* ========================================
   4. 結果表示ボックス
   ======================================== */

.result-box {
    margin-top: 20px;
    padding: 16px;
    background: #f0f9ff;
    border: 2px solid #0066cc;
    border-radius: 8px;
}

.result-box h4 {
    color: #0066cc;
    margin: 0 0 12px 0;
    font-size: 1.1em;
}

.solution-content {
    font-size: 1em;
    line-height: 1.6;
}

.solution-step {
    margin: 8px 0;
    padding: 10px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

.solution-step strong {
    color: #374151;
}

/* 答えの強調表示 */
.solution-step[style*="e0f2fe"] {
    background: #e0f2fe !important;
    border-color: #0066cc !important;
    font-weight: bold;
}

/* 警告（複素数解など） */
.solution-step[style*="fef3c7"] {
    background: #fef3c7 !important;
    border-color: #f59e0b !important;
}

/* ========================================
   5. Desktop Layout (769px+)
   ======================================== */

@media (min-width: 769px) {
    .equation-type-tabs {
        gap: 8px;
    }

    .tab-btn {
        padding: 12px 24px;
        font-size: 1em;
    }

    .equation-inputs {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 16px;
    }

    .input-group {
        flex: 1;
        min-width: 150px;
    }

    .btn-primary {
        width: auto;
        min-width: 150px;
        flex-shrink: 0;
    }

    .equation-row {
        flex-wrap: nowrap;
    }

    .equation-row label {
        min-width: 100px;
    }

    .equation-row input {
        max-width: 100px;
    }

    .equation-row span {
        font-size: 1em;
    }

    .equation-format {
        font-size: 1.2em;
    }

    .solution-content {
        font-size: 1.1em;
    }
}

/* ========================================
   6. Small Mobile (640px-)
   ======================================== */

@media (max-width: 640px) {
    .equation-type-tabs {
        gap: 2px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .equation-format {
        font-size: 1em;
        padding: 10px;
    }

    .input-group label,
    .equation-row label {
        font-size: 13px;
    }

    .input-group input,
    .equation-row input {
        padding: 8px;
        font-size: 15px;
    }

    .btn-primary {
        padding: 10px;
        font-size: 15px;
    }

    .result-box {
        padding: 12px;
    }

    .result-box h4 {
        font-size: 1em;
    }

    .solution-content {
        font-size: 0.95em;
    }

    .solution-step {
        padding: 8px;
        font-size: 0.9em;
    }

    .equation-row {
        gap: 4px;
    }

    .equation-row input {
        min-width: 50px;
        max-width: 70px;
    }

    .equation-row span {
        font-size: 13px;
    }
}

/* ========================================
   7. エラーメッセージ
   ======================================== */

.alert-danger {
    background: #fee2e2;
    border: 2px solid #dc2626;
    border-radius: 6px;
    padding: 12px;
    margin-top: 16px;
}

.alert-danger .alert-content {
    color: #991b1b;
    font-weight: 600;
}
